maropu commented on a change in pull request #29721:
URL: https://github.com/apache/spark/pull/29721#discussion_r486797845
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -104,6 +104,16 @@ class HiveQuerySuite extends HiveComparisonTest with
SQLTestUtils with BeforeAnd
| LIMIT 20
""".stripMargin
+ test("should fail if errors happen when generating expr code") {
Review comment:
Sure!
##########
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.
##########
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`.
##########
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:
okay ~
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -104,6 +104,16 @@ class HiveQuerySuite extends HiveComparisonTest with
SQLTestUtils with BeforeAnd
| LIMIT 20
""".stripMargin
+ test("should fail if errors happen when generating expr code") {
Review comment:
Sure!
##########
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.
##########
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`.
##########
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:
okay ~
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -104,6 +104,16 @@ class HiveQuerySuite extends HiveComparisonTest with
SQLTestUtils with BeforeAnd
| LIMIT 20
""".stripMargin
+ test("should fail if errors happen when generating expr code") {
Review comment:
Sure!
##########
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.
##########
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`.
##########
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:
okay ~
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -104,6 +104,16 @@ class HiveQuerySuite extends HiveComparisonTest with
SQLTestUtils with BeforeAnd
| LIMIT 20
""".stripMargin
+ test("should fail if errors happen when generating expr code") {
Review comment:
Sure!
##########
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.
##########
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`.
##########
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:
okay ~
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -104,6 +104,16 @@ class HiveQuerySuite extends HiveComparisonTest with
SQLTestUtils with BeforeAnd
| LIMIT 20
""".stripMargin
+ test("should fail if errors happen when generating expr code") {
Review comment:
Sure!
##########
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.
##########
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`.
##########
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:
okay ~
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -104,6 +104,16 @@ class HiveQuerySuite extends HiveComparisonTest with
SQLTestUtils with BeforeAnd
| LIMIT 20
""".stripMargin
+ test("should fail if errors happen when generating expr code") {
Review comment:
Sure!
##########
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.
##########
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`.
##########
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:
okay ~
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -104,6 +104,16 @@ class HiveQuerySuite extends HiveComparisonTest with
SQLTestUtils with BeforeAnd
| LIMIT 20
""".stripMargin
+ test("should fail if errors happen when generating expr code") {
Review comment:
Sure!
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -104,6 +104,16 @@ class HiveQuerySuite extends HiveComparisonTest with
SQLTestUtils with BeforeAnd
| LIMIT 20
""".stripMargin
+ test("should fail if errors happen when generating expr code") {
Review comment:
Sure!
##########
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.
##########
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`.
##########
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:
okay ~
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -104,6 +104,16 @@ class HiveQuerySuite extends HiveComparisonTest with
SQLTestUtils with BeforeAnd
| LIMIT 20
""".stripMargin
+ test("should fail if errors happen when generating expr code") {
Review comment:
Sure!
##########
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.
##########
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`.
##########
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:
okay ~
----------------------------------------------------------------
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]