Skip to content

Commit c42dc46

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

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.apache.spark.metrics.source.CodegenMetrics
3939
import org.apache.spark.sql.catalyst.InternalRow
4040
import org.apache.spark.sql.catalyst.expressions._
4141
import org.apache.spark.sql.catalyst.util.{ArrayData, MapData}
42+
import org.apache.spark.sql.internal.SQLConf
4243
import org.apache.spark.sql.types._
4344
import org.apache.spark.unsafe.Platform
4445
import org.apache.spark.unsafe.types._
@@ -1050,12 +1051,14 @@ object CodeGenerator extends Logging {
10501051
case e: JaninoRuntimeException =>
10511052
val msg = s"failed to compile: $e"
10521053
logError(msg, e)
1053-
logInfo(s"\n${CodeFormatter.format(code, maxLines = 1000)}")
1054+
val maxLines = new SQLConf().loggingMaxLinesForCodegen
1055+
logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
10541056
throw new JaninoRuntimeException(msg, e)
10551057
case e: CompileException =>
10561058
val msg = s"failed to compile: $e"
10571059
logError(msg, e)
1058-
logInfo(s"\n${CodeFormatter.format(code, maxLines = 1000)}")
1060+
val maxLines = new SQLConf().loggingMaxLinesForCodegen
1061+
logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
10591062
throw new CompileException(msg, e.getLocation)
10601063
}
10611064
evaluator.getClazz().newInstance().asInstanceOf[GeneratedClass]

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,12 @@ object SQLConf {
562562
.intConf
563563
.createWithDefault(20)
564564

565+
val CODEGEN_LOGGING_MAX_LINES = buildConf("spark.sql.codegen.logging.maxLines")
566+
.internal()
567+
.doc("The maximum number of codegen lines to log when errors occur.")
568+
.intConf
569+
.createWithDefault(1000)
570+
565571
val FILES_MAX_PARTITION_BYTES = buildConf("spark.sql.files.maxPartitionBytes")
566572
.doc("The maximum number of bytes to pack into a single partition when reading files.")
567573
.longConf
@@ -1002,6 +1008,8 @@ class SQLConf extends Serializable with Logging {
10021008

10031009
def maxCaseBranchesForCodegen: Int = getConf(MAX_CASES_BRANCHES)
10041010

1011+
def loggingMaxLinesForCodegen: Int = getConf(CODEGEN_LOGGING_MAX_LINES)
1012+
10051013
def tableRelationCacheSize: Int =
10061014
getConf(StaticSQLConf.FILESOURCE_TABLE_RELATION_CACHE_SIZE)
10071015

0 commit comments

Comments
 (0)