-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-31078][SQL] Respect aliases in output ordering #27842
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 |
|---|---|---|
|
|
@@ -604,6 +604,18 @@ abstract class BucketedReadSuite extends QueryTest with SQLTestUtils { | |
| } | ||
| } | ||
|
|
||
| test("sort should not be introduced when aliases are used") { | ||
| withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "0") { | ||
| withTable("t") { | ||
| df1.repartition(1).write.format("parquet").bucketBy(8, "i").sortBy("i").saveAsTable("t") | ||
|
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. Could you add more tests, e.g., orderBy cases?
Contributor
Author
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. Do you mean something like the following? Extra
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. Ah, I see. How about the aggregate case?
Contributor
Author
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. I added a test for |
||
| val t1 = spark.table("t") | ||
| val t2 = t1.selectExpr("i as ii") | ||
| val plan = t1.join(t2, t1("i") === t2("ii")).queryExecution.executedPlan | ||
| assert(plan.collect { case sort: SortExec => sort }.isEmpty) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("bucket join should work with SubqueryAlias plan") { | ||
| withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "0") { | ||
| withTable("t") { | ||
|
|
||
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.
FYI, this is 5 without the fix.
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.
why do we have sorts between
SortAggregateExecandSortMergeJoinExec?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.
Oh, nothing between them. Two sorts under
SortAggregateExec: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.
ah i see