Github user kiszk commented on a diff in the pull request:
https://github.com/apache/spark/pull/19971#discussion_r156913421
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/TPCDSQuerySuite.scala ---
@@ -348,13 +351,37 @@ class TPCDSQuerySuite extends QueryTest with
SharedSQLContext with BeforeAndAfte
"q81", "q82", "q83", "q84", "q85", "q86", "q87", "q88", "q89", "q90",
"q91", "q92", "q93", "q94", "q95", "q96", "q97", "q98", "q99")
+ private def checkGeneratedCode(plan: SparkPlan): Unit = {
+ val codegenSubtrees = new
collection.mutable.HashSet[WholeStageCodegenExec]()
+ plan foreach {
+ case s: WholeStageCodegenExec =>
+ codegenSubtrees += s
+ case s => s
+ }
+ codegenSubtrees.toSeq.foreach { subtree =>
+ val code = subtree.doCodeGen()._2
+ try {
+ // Just check the generated code can be properly compiled
+ CodeGenerator.compile(code)
+ } catch {
+ case e: Exception =>
+ logError(s"failed to compile: $e", e)
--- End diff --
I followed the following code in `CodeGenerator.scala`
```
val maxCodeSize = try {
evaluator.cook("generated.java", code.body)
updateAndGetCompilationStats(evaluator)
} catch {
case e: InternalCompilerException =>
val msg = s"failed to compile: $e"
logError(msg, e)
val maxLines = SQLConf.get.loggingMaxLinesForCodegen
logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
throw new InternalCompilerException(msg, e)
case e: CompileException =>
val msg = s"failed to compile: $e"
logError(msg, e)
val maxLines = SQLConf.get.loggingMaxLinesForCodegen
logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
throw new CompileException(msg, e.getLocation)
}
```
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]