-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19426][SQL] Custom coalesce for Dataset #16766
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0f1060c
custom coalesce
mariusvniekerk 2742457
Adapted unit test for custom coalesce from the one in RDDSuite
mariusvniekerk 2499364
Addressing review comments.
mariusvniekerk 00b2a7a
Indentation fixup
mariusvniekerk e99cebc
Fixed style issues
mariusvniekerk 1d1b2fa
Fixed failing tests
mariusvniekerk 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ import org.apache.spark.api.java.JavaRDD | |
| import org.apache.spark.api.java.function._ | ||
| import org.apache.spark.api.python.{PythonRDD, SerDeUtil} | ||
| import org.apache.spark.broadcast.Broadcast | ||
| import org.apache.spark.rdd.RDD | ||
| import org.apache.spark.rdd.{PartitionCoalescer, RDD} | ||
| import org.apache.spark.sql.catalyst._ | ||
| import org.apache.spark.sql.catalyst.analysis._ | ||
| import org.apache.spark.sql.catalyst.catalog.CatalogRelation | ||
|
|
@@ -2590,7 +2590,7 @@ class Dataset[T] private[sql]( | |
| } | ||
|
|
||
| /** | ||
| * Returns a new Dataset that has exactly `numPartitions` partitions, when the fewer partitions | ||
| * Returns a new Dataset that has at most `numPartitions` partitions. | ||
| * are requested. If a larger number of partitions is requested, it will stay at the current | ||
| * number of partitions. Similar to coalesce defined on an `RDD`, this operation results in | ||
| * a narrow dependency, e.g. if you go from 1000 partitions to 100 partitions, there will not | ||
|
|
@@ -2603,12 +2603,27 @@ class Dataset[T] private[sql]( | |
| * current upstream partitions will be executed in parallel (per whatever | ||
| * the current partitioning is). | ||
| * | ||
| * A [[PartitionCoalescer]] can also be supplied allowing the behavior of the partitioning to be | ||
| * customized similar to [[RDD.coalesce]]. | ||
|
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. I think it should be |
||
| * | ||
| * @group typedrel | ||
| * @since 2.2.0 | ||
| */ | ||
| def coalesce(numPartitions: Int, partitionCoalescer: Option[PartitionCoalescer]): Dataset[T] = | ||
| withTypedPlan { | ||
| PartitionCoalesce(numPartitions, partitionCoalescer, logicalPlan) | ||
| } | ||
|
|
||
| /** | ||
| * Returns a new Dataset that has exactly `numPartitions` partitions. | ||
| * Similar to coalesce defined on an `RDD`, this operation results in a narrow dependency, e.g. | ||
| * if you go from 1000 partitions to 100 partitions, there will not be a shuffle, instead each of | ||
| * the 100 new partitions will claim 10 of the current partitions. | ||
| * | ||
| * @group typedrel | ||
| * @since 1.6.0 | ||
| */ | ||
| def coalesce(numPartitions: Int): Dataset[T] = withTypedPlan { | ||
| Repartition(numPartitions, shuffle = false, logicalPlan) | ||
| } | ||
| def coalesce(numPartitions: Int): Dataset[T] = coalesce(numPartitions, None) | ||
|
|
||
| /** | ||
| * Returns a new Dataset that contains only the unique rows from this Dataset. | ||
|
|
||
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.
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.
Sounds this trait is unable to be generated as is in Java. Simply wrapping
`...`would be fine.