-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-47463][SQL] Use V2Predicate to wrap expression with return type of boolean #45589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
5f6223c
065345b
efb183e
07b88ae
a8a5ed5
e176461
08426d1
3ecacd1
ffebea2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -966,6 +966,44 @@ class DataSourceV2Suite extends QueryTest with SharedSparkSession with AdaptiveS | |
| ) | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-47463: Pushed down v2 filter with (if / case when / nvl) expression") { | ||
| withTempView("t1") { | ||
| withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") { | ||
| 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 | ||
| |(select nvl(cast(i as boolean), false) c from t1) t | ||
wForget marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| |where t.c is true | ||
| |""".stripMargin | ||
| ) | ||
| val result3 = df3.collect() | ||
| assert(result3.length > 0) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| case class RangeInputPartition(start: Int, end: Int) extends InputPartition | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reserved
isPredicate=truefor conditions of casewhen