-
Notifications
You must be signed in to change notification settings - Fork 307
feat: Support sort merge join #178
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9b4b87d
feat: Support sort merge join
viirya 04d928e
Update PlanStability
viirya 4b78e4f
Update Spark diff
viirya 15eb659
For review
viirya 68418ac
Fix format
viirya 08db759
For review
viirya 80e58ea
Add CometJoinSuite
viirya fc03003
Remove uuid
viirya 1e5465f
Fix diff
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
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
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 |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ import org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat | |
| import org.apache.spark.sql.execution.datasources.v2.BatchScanExec | ||
| import org.apache.spark.sql.execution.datasources.v2.parquet.ParquetScan | ||
| import org.apache.spark.sql.execution.exchange.{BroadcastExchangeExec, ReusedExchangeExec, ShuffleExchangeExec} | ||
| import org.apache.spark.sql.execution.joins.SortMergeJoinExec | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.sql.types._ | ||
|
|
||
|
|
@@ -223,13 +224,10 @@ class CometSparkSessionExtensions | |
| // spotless:on | ||
| private def transform(plan: SparkPlan): SparkPlan = { | ||
| def transform1(op: SparkPlan): Option[Operator] = { | ||
| val allNativeExec = op.children.map { | ||
| case childNativeOp: CometNativeExec => Some(childNativeOp.nativeOp) | ||
| case _ => None | ||
| } | ||
|
|
||
| if (allNativeExec.forall(_.isDefined)) { | ||
| QueryPlanSerde.operator2Proto(op, allNativeExec.map(_.get): _*) | ||
| if (op.children.forall(_.isInstanceOf[CometNativeExec])) { | ||
| QueryPlanSerde.operator2Proto( | ||
| op, | ||
| op.children.map(_.asInstanceOf[CometNativeExec].nativeOp): _*) | ||
| } else { | ||
| None | ||
| } | ||
|
|
@@ -337,6 +335,26 @@ class CometSparkSessionExtensions | |
| op | ||
| } | ||
|
|
||
| case op: SortMergeJoinExec | ||
| if isCometOperatorEnabled(conf, "sort_merge_join") && | ||
| op.children.forall(isCometNative(_)) => | ||
| val newOp = transform1(op) | ||
| newOp match { | ||
| case Some(nativeOp) => | ||
| CometSortMergeJoinExec( | ||
| nativeOp, | ||
| op, | ||
| op.leftKeys, | ||
| op.rightKeys, | ||
| op.joinType, | ||
| op.condition, | ||
| op.left, | ||
| op.right, | ||
| SerializedPlan(None)) | ||
| case None => | ||
| op | ||
| } | ||
|
|
||
| case c @ CoalesceExec(numPartitions, child) | ||
| if isCometOperatorEnabled(conf, "coalesce") | ||
| && isCometNative(child) => | ||
|
|
@@ -576,7 +594,9 @@ object CometSparkSessionExtensions extends Logging { | |
|
|
||
| private[comet] def isCometOperatorEnabled(conf: SQLConf, operator: String): Boolean = { | ||
| val operatorFlag = s"$COMET_EXEC_CONFIG_PREFIX.$operator.enabled" | ||
| conf.getConfString(operatorFlag, "false").toBoolean || isCometAllOperatorEnabled(conf) | ||
| val operatorDisabledFlag = s"$COMET_EXEC_CONFIG_PREFIX.$operator.disabled" | ||
| conf.getConfString(operatorFlag, "false").toBoolean || isCometAllOperatorEnabled(conf) && | ||
| !conf.getConfString(operatorDisabledFlag, "false").toBoolean | ||
|
Comment on lines
+597
to
+599
Member
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. This "disable" flag is useful to disable a particular operator in unit test. For example, I disable sort merge join in one existing test below. |
||
| } | ||
|
|
||
| private[comet] def isCometBroadCastEnabled(conf: SQLConf): Boolean = { | ||
|
|
||
Oops, something went wrong.
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.