-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40885] Sort may not take effect when it is the last 'Transform' operator
#38356
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 |
|---|---|---|
|
|
@@ -220,6 +220,23 @@ class PartitionedWriteSuite extends QueryTest with SharedSparkSession { | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-40885: V1 write uses the sort with partitionBy operator") { | ||
| withTempPath { f => | ||
| Seq((20, 30, "partition"), (15, 20, "partition"), | ||
| (30, 70, "partition"), (18, 40, "partition")) | ||
| .toDF("id", "sort_col", "p") | ||
| .repartition(1) | ||
| .sortWithinPartitions("p", "sort_col") | ||
| .write | ||
| .partitionBy("p") | ||
|
Contributor
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'm not very sure what the problem is.
Contributor
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.
Why does
Contributor
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.
See #38356 (comment): The
Contributor
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. Seems
Contributor
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. yeah we can rewrite the ordering to preverse the attribute before alias like
Contributor
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. Be aware that
Contributor
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. we only add empty2null for string type partition columns, maybe we shouldn't optimize this case anyway.
Contributor
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. Adding |
||
| .parquet(f.getAbsolutePath) | ||
| val sortColList = spark.read.parquet(f.getAbsolutePath) | ||
| .map(_.getInt(1)).collect().toList | ||
| val expectList = List(20, 30, 40, 70) | ||
| assert(sortColList == expectList) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
@EnricoMi
There is a constraint on the order of the sorting fields. If outer Sort("p") added in the first place., will this constraint be broken, will it affect the efficiency or other?