-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22219][SQL] Refactor code to get a value for "spark.sql.codegen.comments" #19449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -751,6 +751,12 @@ object SQLConf { | |
| .booleanConf | ||
| .createWithDefault(true) | ||
|
|
||
| val MAX_CASES_BRANCHES = buildConf("spark.sql.codegen.maxCaseBranches") | ||
|
||
| .internal() | ||
| .doc("The maximum number of switches supported with codegen.") | ||
| .intConf | ||
| .createWithDefault(20) | ||
|
|
||
| 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.") | ||
|
|
@@ -1539,6 +1545,10 @@ class SQLConf extends Serializable with Logging { | |
|
|
||
| def codegenFallback: Boolean = getConf(CODEGEN_FALLBACK) | ||
|
|
||
| def maxCaseBranchesForCodegen: Int = getConf(MAX_CASES_BRANCHES) | ||
|
|
||
| def codegenComments: Boolean = getConf(StaticSQLConf.CODEGEN_COMMENTS) | ||
|
|
||
| def loggingMaxLinesForCodegen: Int = getConf(CODEGEN_LOGGING_MAX_LINES) | ||
|
|
||
| def hugeMethodLimit: Int = getConf(WHOLESTAGE_HUGE_METHOD_LIMIT) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ package org.apache.spark.sql.internal | |
|
|
||
| import org.apache.spark.SparkFunSuite | ||
| import org.apache.spark.sql.{AnalysisException, SparkSession} | ||
| import org.apache.spark.sql.execution.debug.codegenStringSeq | ||
| import org.apache.spark.sql.functions.col | ||
| import org.apache.spark.sql.test.SQLTestUtils | ||
|
|
||
| class ExecutorSideSQLConfSuite extends SparkFunSuite with SQLTestUtils { | ||
|
|
@@ -82,4 +84,22 @@ class ExecutorSideSQLConfSuite extends SparkFunSuite with SQLTestUtils { | |
| assert(checks.forall(_ == true)) | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-22219: refactor to control to generate comment") { | ||
| withSQLConf(StaticSQLConf.CODEGEN_COMMENTS.key -> "false") { | ||
| val res = codegenStringSeq(spark.range(10).groupBy(col("id") * 2).count() | ||
| .queryExecution.executedPlan) | ||
| assert(res.length == 2) | ||
| assert(res.forall{ case (_, code) => | ||
| !code.contains("* Codegend pipeline") && !code.contains("// input[")}) | ||
| } | ||
|
|
||
| withSQLConf(StaticSQLConf.CODEGEN_COMMENTS.key -> "true") { | ||
| val res = codegenStringSeq(spark.range(10).groupBy(col("id") * 2).count() | ||
| .queryExecution.executedPlan) | ||
| assert(res.length == 2) | ||
| assert(res.forall{ case (_, code) => | ||
| code.contains("* Codegend pipeline") && code.contains("// input[")}) | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. combine these two? |
||
| } | ||
| } | ||
There was a problem hiding this comment.
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.