-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-52921][SQL] Specify outputPartitioning for UnionExec for partitioner aware case #51623
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
Open
viirya
wants to merge
10
commits into
apache:master
Choose a base branch
from
viirya:union_outputpartition
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+82
−4
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
888c1d5
Specify outputPartitioning for UnionExec for partitioner aware case
viirya 9b87f96
add comment
viirya 22fb207
add test
viirya 9263c89
try to fix tests
viirya 7c6921c
more
viirya eaf34bf
clean up
viirya b35516b
more
viirya 9465cca
fix
viirya 5d2e336
for review
viirya 1ee11a5
fix
viirya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1606,11 +1606,16 @@ class SparkContext(config: SparkConf) extends Logging { | |
new ReliableCheckpointRDD[T](this, path) | ||
} | ||
|
||
// Note that input rdds must be all non-empty, i.e., rdds.filter(_.partitions.isEmpty).isEmpty | ||
protected[spark] def isPartitionerAwareUnion[T: ClassTag](rdds: Seq[RDD[T]]): Boolean = { | ||
assert(!rdds.exists(_.partitions.isEmpty), "Must not have empty RDDs") | ||
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. Nice! |
||
rdds.forall(_.partitioner.isDefined) && rdds.flatMap(_.partitioner).toSet.size == 1 | ||
} | ||
|
||
/** Build the union of a list of RDDs. */ | ||
def union[T: ClassTag](rdds: Seq[RDD[T]]): RDD[T] = withScope { | ||
val nonEmptyRdds = rdds.filter(!_.partitions.isEmpty) | ||
val partitioners = nonEmptyRdds.flatMap(_.partitioner).toSet | ||
if (nonEmptyRdds.forall(_.partitioner.isDefined) && partitioners.size == 1) { | ||
if (isPartitionerAwareUnion(nonEmptyRdds)) { | ||
new PartitionerAwareUnionRDD(this, nonEmptyRdds) | ||
} else { | ||
new UnionRDD(this, nonEmptyRdds) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5993,6 +5993,16 @@ object SQLConf { | |
.booleanConf | ||
.createWithDefault(true) | ||
|
||
val UNION_OUTPUT_PARTITIONING = | ||
buildConf("spark.sql.unionOutputPartitioning") | ||
.internal() | ||
.doc("When set to true, the output partitioning of UnionExec will be the same as the " + | ||
"input partitioning if its children have same partitioner. Otherwise, it will be a " + | ||
"default partitioning.") | ||
.version("4.1.0") | ||
.booleanConf | ||
.createWithDefault(true) | ||
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. For safety, added an internal config for it. |
||
|
||
val LEGACY_PARSE_QUERY_WITHOUT_EOF = buildConf("spark.sql.legacy.parseQueryWithoutEof") | ||
.internal() | ||
.doc( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you add a comment about the assumption,
rdds.filter(!_.partitions.isEmpty)
? Otherwise, it may cause correctness issues later if we use this blindly.Otherwise, we had better include the assumption inside this method.
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.
Added comment and a check.