Skip to content

Commit a795db2

Browse files
author
pj.fanning
committed
[SPARK-20871][SQL] add check on SQLConf internal property: spark.sql.codegen.logging.maxLines
1 parent c42dc46 commit a795db2

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,13 +1051,13 @@ object CodeGenerator extends Logging {
10511051
case e: JaninoRuntimeException =>
10521052
val msg = s"failed to compile: $e"
10531053
logError(msg, e)
1054-
val maxLines = new SQLConf().loggingMaxLinesForCodegen
1054+
val maxLines = SQLConf.get.loggingMaxLinesForCodegen
10551055
logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
10561056
throw new JaninoRuntimeException(msg, e)
10571057
case e: CompileException =>
10581058
val msg = s"failed to compile: $e"
10591059
logError(msg, e)
1060-
val maxLines = new SQLConf().loggingMaxLinesForCodegen
1060+
val maxLines = SQLConf.get.loggingMaxLinesForCodegen
10611061
logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
10621062
throw new CompileException(msg, e.getLocation)
10631063
}

sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,10 @@ object SQLConf {
564564

565565
val CODEGEN_LOGGING_MAX_LINES = buildConf("spark.sql.codegen.logging.maxLines")
566566
.internal()
567-
.doc("The maximum number of codegen lines to log when errors occur.")
567+
.doc("The maximum number of codegen lines to log when errors occur. Use -1 for unlimited.")
568568
.intConf
569+
.checkValue(maxLines => maxLines >= -1, "The maximum must be a positive integer, 0 to " +
570+
"disable logging or -1 to apply no limit.")
569571
.createWithDefault(1000)
570572

571573
val FILES_MAX_PARTITION_BYTES = buildConf("spark.sql.files.maxPartitionBytes")

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeFormatterSuite.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ class CodeFormatterSuite extends SparkFunSuite {
129129
""".stripMargin
130130
}
131131

132+
testCase("function calls with maxLines=0") (
133+
"""
134+
|foo(
135+
|a,
136+
|b,
137+
|c)
138+
""".stripMargin,
139+
maxLines = 0
140+
) {
141+
"""
142+
|/* 001 */ [truncated to 0 lines (total lines is 4)]
143+
""".stripMargin
144+
}
145+
132146
testCase("function calls with maxLines=2") (
133147
"""
134148
|foo(

0 commit comments

Comments
 (0)