gstvg commented on code in PR #3611:
URL: https://github.com/apache/datafusion-comet/pull/3611#discussion_r3080724110
##########
spark/src/test/scala/org/apache/comet/CometArrayExpressionSuite.scala:
##########
@@ -1036,6 +1036,35 @@ class CometArrayExpressionSuite extends CometTestBase
with AdaptiveSparkPlanHelp
}
}
+ test("array_exists - DataFrame API with timestamp") {
+ val table = "t1"
+ withTable(table) {
+ sql(s"create table $table(arr array<timestamp>) using parquet")
+ sql(
+ s"insert into $table values (array(timestamp'2024-01-01 00:00:00',
timestamp'2024-06-15 12:30:00'))")
+ sql(s"insert into $table values (array(timestamp'2023-01-01 00:00:00'))")
+
+ val df = spark.table(table)
+ checkSparkAnswerAndOperator(
+ df.select(exists(col("arr"), x => x > lit("2024-03-01
00:00:00").cast("timestamp"))))
+ }
+ }
+
+ test("array_exists - CaseWhen/If in lambda") {
+ val table = "t1"
+ withTable(table) {
+ sql(s"create table $table(arr array<int>) using parquet")
+ sql(s"insert into $table values (array(1, 2, 3))")
+ sql(s"insert into $table values (array(-1, 0, 1))")
+ sql(s"insert into $table values (null)")
+
+ val df = spark.table(table)
+ checkSparkAnswerAndOperator(
+ df.selectExpr("exists(arr, x -> CASE WHEN x > 0 THEN true ELSE false
END)"))
+ checkSparkAnswerAndOperator(df.selectExpr("exists(arr, x -> IF(x > 0,
true, false))"))
Review Comment:
I should have specified before, my bad, but I believe that an expression
like `IF(x > 0, x+1, x-1)` is needed to trigger the projection. Even if this
doesn't get optimized to just `x > 0`, a scalar or scalar expression doesn't
trigger the projection:
https://github.com/apache/datafusion/blob/961c5fc454c64bee0cb1cc8b0e32336e3cffc012/datafusion/physical-expr/src/expressions/case.rs#L661-L671
--
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]