@@ -21,19 +21,18 @@ package org.apache.comet
2121
2222import scala .util .Random
2323
24+ import org .apache .hadoop .fs .Path
2425import org .apache .parquet .hadoop .ParquetOutputFormat
2526import org .apache .spark .sql .{CometTestBase , DataFrame }
2627import org .apache .spark .sql .functions .lit
2728import org .apache .spark .sql .internal .SQLConf
2829import org .apache .spark .sql .types .{DataTypes , StringType , StructField , StructType }
2930
31+ import org .apache .comet .serde .CometElt
3032import org .apache .comet .testing .{DataGenOptions , FuzzDataGenerator }
3133
3234class CometStringExpressionSuite extends CometTestBase {
3335
34- private val WRONG_NUM_ARGS_WITHOUT_SUGGESTION_EXCEPTION_MSG =
35- " [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `elt` requires > 1 parameters but the actual number is 1."
36-
3736 test(" lpad string" ) {
3837 testStringPadding(" lpad" )
3938 }
@@ -396,7 +395,12 @@ class CometStringExpressionSuite extends CometTestBase {
396395 }
397396
398397 test(" elt" ) {
399- withSQLConf(SQLConf .ANSI_ENABLED .key -> " false" ) {
398+ val wrongNumArgsWithoutSuggestionExceptionMsg =
399+ " [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `elt` requires > 1 parameters but the actual number is 1."
400+ withSQLConf(
401+ SQLConf .ANSI_ENABLED .key -> " false" ,
402+ SQLConf .OPTIMIZER_EXCLUDED_RULES .key ->
403+ " org.apache.spark.sql.catalyst.optimizer.ConstantFolding" ) {
400404 val r = new Random (42 )
401405 val fieldsCount = 10
402406 val indexes = Seq .range(1 , fieldsCount)
@@ -420,13 +424,13 @@ class CometStringExpressionSuite extends CometTestBase {
420424 sql(s " SELECT elt(cast(null as int), ${schema.fieldNames.mkString(" ," )}) FROM t1 " ))
421425 checkSparkAnswerMaybeThrows(sql(" SELECT elt(1) FROM t1" )) match {
422426 case (Some (spark), Some (comet)) =>
423- assert(spark.getMessage.contains(WRONG_NUM_ARGS_WITHOUT_SUGGESTION_EXCEPTION_MSG ))
424- assert(comet.getMessage.contains(WRONG_NUM_ARGS_WITHOUT_SUGGESTION_EXCEPTION_MSG ))
427+ assert(spark.getMessage.contains(wrongNumArgsWithoutSuggestionExceptionMsg ))
428+ assert(comet.getMessage.contains(wrongNumArgsWithoutSuggestionExceptionMsg ))
425429 case (spark, comet) =>
426430 fail(
427431 s " Expected Spark and Comet to throw exception, but got \n Spark: $spark\n Comet: $comet" )
428432 }
433+ checkSparkAnswerAndOperator(" SELECT elt(2, 'a', 'b', 'c')" )
429434 }
430435 }
431-
432436}
0 commit comments