maropu commented on a change in pull request #29721:
URL: https://github.com/apache/spark/pull/29721#discussion_r486941617



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala
##########
@@ -2555,6 +2555,24 @@ class DataFrameSuite extends QueryTest
     val df = Seq(0.0 -> -0.0).toDF("pos", "neg")
     checkAnswer(df.select($"pos" > $"neg"), Row(false))
   }
+
+  test("SPARK-32851: should fail if errors happen when generating expr code") {
+    val errMsg = intercept[SparkException] {
+      withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> "false") {
+        val df = spark.range(1)
+        df.select(Column(FailedCodegenExpr(df("id").expr)) :: Nil: _*).show()
+      }
+    }.getCause.getMessage
+    assert(errMsg.contains("failed to compile:"))
+  }
 }
 
 case class GroupByKey(a: Int, b: Int)
+
+case class FailedCodegenExpr(child: Expression) extends UnaryExpression with 
CodegenFallback {
+  private lazy val proj = FailedCodegenProjection.createObject(child :: Nil)
+  override def dataType: DataType = LongType
+  override def eval(input: InternalRow): Any = {
+    proj(input).getLong(0)

Review comment:
       >  It's just used to trigger FailedCodegenProjection
   
   Yea, yes. This test just triggers the the codegen failure of 
`FailedCodegenProjection` in executor sides and it checks the failure correctly 
propagates to a driver side in `SharedSparkSession` by setting the config 
`CODEGEN_FACTORY_MODE`=`codegen_only` in `SparkConf`:
   
https://github.com/apache/spark/pull/29721/files#diff-ef6933b96996929c402e3a36296b2590R71
   
   `CodeGeneratorWithInterpretedFallbackSuite` is placed in the catalyst 
package, so it is not related to adding the config in `SharedSparkSession`. 
But, if the existing tests in  `CodeGeneratorWithInterpretedFallbackSuite` look 
enough, I think it is okay to drop the added tests and just add the config 
`CODEGEN_FACTORY_MODE` in `SharedSparkSession`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to