fred-db commented on code in PR #38497:
URL: https://github.com/apache/spark/pull/38497#discussion_r1026198667
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/EliminateResolvedHint.scala:
##########
@@ -31,20 +34,35 @@ object EliminateResolvedHint extends Rule[LogicalPlan] {
// This is also called in the beginning of the optimization phase, and as a
result
// is using transformUp rather than resolveOperators.
def apply(plan: LogicalPlan): LogicalPlan = {
- val pulledUp = plan transformUp {
+ val joinsWithHints = plan transformUp {
case j: Join if j.hint == JoinHint.NONE =>
val (newLeft, leftHints) = extractHintsFromPlan(j.left)
val (newRight, rightHints) = extractHintsFromPlan(j.right)
val newJoinHint = JoinHint(mergeHints(leftHints),
mergeHints(rightHints))
j.copy(left = newLeft, right = newRight, hint = newJoinHint)
}
- pulledUp.transformUp {
+ val shouldPullHintsIntoSubqueries =
SQLConf.get.getConf(SQLConf.PULL_HINTS_INTO_SUBQUERIES)
+ val joinsAndSubqueriesWithHints = if (shouldPullHintsIntoSubqueries) {
+ pullHintsIntoSubqueries(joinsWithHints)
+ } else {
+ joinsWithHints
+ }
+ joinsAndSubqueriesWithHints.transformUp {
case h: ResolvedHint =>
hintErrorHandler.joinNotFoundForJoinHint(h.hints)
h.child
}
}
+ def pullHintsIntoSubqueries(plan: LogicalPlan): LogicalPlan = {
+
plan.transformAllExpressionsUpWithPruning(_.containsPattern(PLAN_EXPRESSION)) {
Review Comment:
Yes you are right, I forgot for a second that it's not a logical plan node.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]