Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19971#discussion_r156861190
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/TPCDSQuerySuite.scala ---
@@ -348,13 +351,38 @@ 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.map { 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)
+ val msg =
+ s"Subtree:\n$subtree\n" +
+ s"Generated code:\n${CodeFormatter.format(code)}\n"
+ logDebug(msg)
--- End diff --
it's more useful to include the error message in the exception, e.g. `throw
new Exception(msg, e)`
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]