-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-32421][SQL] Add code-gen for shuffled hash join #29277
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
6fe1079
ab2e172
83e6a6f
b352035
43d286a
3e2406a
ac64864
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 |
---|---|---|
|
@@ -34,7 +34,7 @@ import org.apache.spark.sql.catalyst.plans.physical.Partitioning | |
import org.apache.spark.sql.catalyst.rules.Rule | ||
import org.apache.spark.sql.execution.aggregate.HashAggregateExec | ||
import org.apache.spark.sql.execution.columnar.InMemoryTableScanExec | ||
import org.apache.spark.sql.execution.joins.{BroadcastHashJoinExec, SortMergeJoinExec} | ||
import org.apache.spark.sql.execution.joins.{BroadcastHashJoinExec, ShuffledHashJoinExec, SortMergeJoinExec} | ||
import org.apache.spark.sql.execution.metric.SQLMetrics | ||
import org.apache.spark.sql.internal.SQLConf | ||
import org.apache.spark.sql.types._ | ||
|
@@ -50,6 +50,7 @@ trait CodegenSupport extends SparkPlan { | |
private def variablePrefix: String = this match { | ||
case _: HashAggregateExec => "agg" | ||
case _: BroadcastHashJoinExec => "bhj" | ||
case _: ShuffledHashJoinExec => "shj" | ||
case _: SortMergeJoinExec => "smj" | ||
case _: RDDScanExec => "rdd" | ||
case _: DataSourceScanExec => "scan" | ||
|
@@ -903,6 +904,10 @@ case class CollapseCodegenStages( | |
// The children of SortMergeJoin should do codegen separately. | ||
j.withNewChildren(j.children.map( | ||
child => InputAdapter(insertWholeStageCodegen(child)))) | ||
case j: ShuffledHashJoinExec => | ||
// The children of ShuffledHashJoin should do codegen separately. | ||
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 and 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. @viirya - sure, wondering what kind of wording you are expecting here? does it look better with:
|
||
j.withNewChildren(j.children.map( | ||
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 can remove this now. ShuffledHashJoin now does codegen like BroadcastHashJoin. 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. @viirya - I don't think we can remove this. We have to do shuffled hash join codegen separately, as we have a hardcoded dependency for build side input E.g.
If we don't codegen shuffled hash join children separately, we will get something like:
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 we only need to do it for the build side? 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. Yea, that's 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. @cloud-fan, @viirya - if we only codegen separately for build side, we would still have the same problem as above for multiple SHJs right? Essentially we would fuse multiple stream sides codegen together in one codegen method, so we will have multiple build side initialized in init(), and naming collision as above. Let me know if it doesn't make sense, or I can create a counter example here. 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. @cloud-fan - sounds good, non-trivial for me now as well. Will try to resolve it in the future. Thanks. 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. And there are more problems if we have many shuffle hash join stay together. We need to accumulate the
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.
Yes. Agreed. 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.
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. Hm, it still has some problems. Will think about it if I have more time. |
||
child => InputAdapter(insertWholeStageCodegen(child)))) | ||
case p => p.withNewChildren(p.children.map(insertInputAdapter)) | ||
} | ||
} | ||
|
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.
codegen children of
ShuffledHashJoinExec
separately same asSortMergeJoinExec
.