coderfender commented on code in PR #3269:
URL: https://github.com/apache/datafusion-comet/pull/3269#discussion_r2730613941


##########
spark/src/test/scala/org/apache/comet/CometStringExpressionSuite.scala:
##########
@@ -391,4 +392,38 @@ class CometStringExpressionSuite extends CometTestBase {
     }
   }
 
+  test("elt") {
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
+      val r = new Random(42)
+      val fieldsCount = 10
+      val indexes = Seq.range(1, fieldsCount)
+      val edgeCasesIndexes = Seq(-1, 0, -100, fieldsCount + 100)
+      val schema = indexes
+        .foldLeft(new StructType())((schema, idx) =>
+          schema.add(s"c$idx", StringType, nullable = true))
+      val df = FuzzDataGenerator.generateDataFrame(
+        r,
+        spark,
+        schema,
+        100,
+        DataGenOptions(maxStringLength = 6))
+      df.withColumn(
+        "idx",
+        lit(Random.shuffle(indexes ++ 
edgeCasesIndexes).headOption.getOrElse(-1)))
+        .createOrReplaceTempView("t1")
+      checkSparkAnswerAndOperator(
+        sql(s"SELECT elt(idx, ${schema.fieldNames.mkString(",")}) FROM t1"))
+      checkSparkAnswerAndOperator(
+        sql(s"SELECT elt(cast(null as int), 
${schema.fieldNames.mkString(",")}) FROM t1"))
+      checkSparkAnswerMaybeThrows(sql("SELECT elt(1) FROM t1")) match {
+        case (Some(spark), Some(comet)) =>
+          
assert(spark.getMessage.contains("WRONG_NUM_ARGS.WITHOUT_SUGGESTION"))

Review Comment:
   minor : perhaps a good idea to capture the error msg 
`"WRONG_NUM_ARGS.WITHOUT_SUGGESTION"`  in a string ? 



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

To unsubscribe, e-mail: [email protected]

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