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



##########
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:
       This test proves that, if the codegen of `proj` fails, the query fails.  
If `CODEGEN_FACTORY_MODE`=fallback, `proj` falls back into an interpreted one.




----------------------------------------------------------------
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