Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Initial commit
  • Loading branch information
kiszk committed Jul 16, 2018
commit 9c26e2e765ce40fc1ded22e69155b8d85f4e1598
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,7 @@ class CodegenContext {
// be extremely expensive in certain cases, such as deeply-nested expressions which operate over
// inputs with wide schemas. For more details on the performance issues that motivated this
// flat, see SPARK-15680.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move these comments to the SQLConf description.

if (force ||
SparkEnv.get != null && SparkEnv.get.conf.getBoolean("spark.sql.codegen.comments", false)) {
if (force || SQLConf.get.codegenComments) {
val name = if (placeholderId != "") {
assert(!placeHolderToComments.contains(placeholderId))
placeholderId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,19 @@ object SQLConf {
.booleanConf
.createWithDefault(true)

val MAX_CASES_BRANCHES = buildConf("spark.sql.codegen.maxCaseBranches")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh..., I will remove this

.internal()
.doc("The maximum number of switches supported with codegen.")
.intConf
.createWithDefault(20)

val CODEGEN_COMMENTS = buildConf("spark.sql.codegen.comments")
.internal()
.doc("When true, put comment in the generated code. Since computing huge comments " +
"can be extremely expensive in certain cases, default is false.")
.booleanConf
.createWithDefault(false)

val CODEGEN_LOGGING_MAX_LINES = buildConf("spark.sql.codegen.logging.maxLines")
.internal()
.doc("The maximum number of codegen lines to log when errors occur. Use -1 for unlimited.")
Expand Down Expand Up @@ -1539,6 +1552,10 @@ class SQLConf extends Serializable with Logging {

def codegenFallback: Boolean = getConf(CODEGEN_FALLBACK)

def maxCaseBranchesForCodegen: Int = getConf(MAX_CASES_BRANCHES)

def codegenComments: Boolean = getConf(CODEGEN_COMMENTS)

def loggingMaxLinesForCodegen: Int = getConf(CODEGEN_LOGGING_MAX_LINES)

def hugeMethodLimit: Int = getConf(WHOLESTAGE_HUGE_METHOD_LIMIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,20 @@ class DebuggingSuite extends SparkFunSuite with SharedSQLContext {
assert(res.forall{ case (subtree, code) =>
subtree.contains("Range") && code.contains("Object[]")})
}

test("check to generate comment") {
withSQLConf("spark.sql.codegen.comments" -> "false") {
val res = codegenStringSeq(spark.range(10).groupBy("id").count().queryExecution.executedPlan)
assert(res.length == 2)
assert(res.forall{ case (_, code) =>
!code.contains("* Codegend pipeline") && !code.contains("// input[")})
}

withSQLConf("spark.sql.codegen.comments" -> "true") {
val res = codegenStringSeq(spark.range(10).groupBy("id").count().queryExecution.executedPlan)
assert(res.length == 2)
assert(res.forall{ case (_, code) =>
code.contains("* Codegend pipeline") && code.contains("// input[")})
}
}
}