cloud-fan commented on code in PR #45589:
URL: https://github.com/apache/spark/pull/45589#discussion_r1560375469
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2Suite.scala:
##########
@@ -966,6 +966,41 @@ class DataSourceV2Suite extends QueryTest with
SharedSparkSession with AdaptiveS
)
}
}
+
+ test("SPARK-47463: Pushed down v2 filter with (if / case when/ nullif)
expression") {
+ withTempView("t1") {
+
spark.read.format(classOf[AdvancedDataSourceV2WithV2Filter].getName).load()
+ .createTempView("t1")
+ val df1 = sql(
+ s"""
+ |select * from
+ |(select if(i = 1, i, 0) as c from t1) t
+ |where t.c > 0
+ |""".stripMargin
+ )
+ val result1 = df1.collect()
+ assert(result1.length == 1)
+
+ val df2 = sql(
+ s"""
+ |select * from
+ |(select case when i = 1 then i else 0 end as c from t1) t
+ |where t.c > 0
+ |""".stripMargin
+ )
+ val result2 = df2.collect()
+ assert(result2.length == 1)
+
+ val df3 = sql(
+ s"""
+ |select * from t1
+ |where nullif(i, 1) is null
Review Comment:
`nullif` is not a real function and will be replaced by binary comparisons,
we don't need to test it.
--
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]