andygrove commented on code in PR #3269:
URL: https://github.com/apache/datafusion-comet/pull/3269#discussion_r2747458905
##########
spark/src/test/scala/org/apache/comet/CometStringExpressionSuite.scala:
##########
@@ -391,4 +395,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(
Review Comment:
It would also be worth adding a literal test with constant folding disabled,
something like:
```scala
withSQLConf(SQLConf.OPTIMIZER_EXCLUDED_RULES.key ->
"org.apache.spark.sql.catalyst.optimizer.ConstantFolding") {
checkSparkAnswerAndOperator("SELECT elt(2, 'a', 'b', 'c')")
```
It is totally fine to fall back to Spark if all inputs are literal.
--
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]