-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24696][SQL] ColumnPruning rule fails to remove extra Project #21674
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 all commits
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 |
|---|---|---|
|
|
@@ -2792,4 +2792,25 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext { | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-24696 ColumnPruning rule fails to remove extra Project") { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test in Jira is simpler than this. Do we need to have two tables and a join? Why not just use the test in Jira?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new unit test in |
||
| withTable("fact_stats", "dim_stats") { | ||
| val factData = Seq((1, 1, 99, 1), (2, 2, 99, 2), (3, 1, 99, 3), (4, 2, 99, 4)) | ||
| val storeData = Seq((1, "BW", "DE"), (2, "AZ", "US")) | ||
| spark.udf.register("filterND", udf((value: Int) => value > 2).asNondeterministic) | ||
| factData.toDF("date_id", "store_id", "product_id", "units_sold") | ||
| .write.mode("overwrite").partitionBy("store_id").format("parquet").saveAsTable("fact_stats") | ||
| storeData.toDF("store_id", "state_province", "country") | ||
| .write.mode("overwrite").format("parquet").saveAsTable("dim_stats") | ||
| val df = sql( | ||
| """ | ||
| |SELECT f.date_id, f.product_id, f.store_id FROM | ||
| |(SELECT date_id, product_id, store_id | ||
| | FROM fact_stats WHERE filterND(date_id)) AS f | ||
| |JOIN dim_stats s | ||
| |ON f.store_id = s.store_id WHERE s.country = 'DE' | ||
| """.stripMargin) | ||
| checkAnswer(df, Seq(Row(3, 99, 1))) | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
We can just use
Rand(seed: Long). Seeobject RandinrandomExpressions.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.
Since we already have a bunch of expressions here, I don't think it would hurt to add this one?
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 mean:
def rand(e: Long): Expression = Rand(e).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 addressed the comment when I merged the code.