Skip to content

Conversation

@zhengruifeng
Copy link
Contributor

@zhengruifeng zhengruifeng commented Dec 22, 2023

What changes were proposed in this pull request?

1, make following helper functions keep the plan id in transformation:

  • resolveOperatorsDownWithPruning
  • resolveOperatorsUpWithNewOutput

2, change the way to keep plan id in ResolveNaturalAndUsingJoin:
before:

Project <- tag hiddenOutputTag
  - Join <- tag PLAN_ID_TAG

after:

Project <- tag hiddenOutputTag & PLAN_ID_TAG
  - Join

3, to verify this fix, this PR also reverts previous tags copying changes in the rules

Why are the changes needed?

we had make following rules keep the plan id:
1, ResolveNaturalAndUsingJoin in 167bbca

  • using resolveOperatorsUpWithPruning, it set the tag Project.hiddenOutputTag internally, so copyTagsFrom (only works if tags.isEmpty) in resolveOperatorsUpWithPruning takes no effect

2, ExtractWindowExpressions in 185a0a5

  • using resolveOperatorsDownWithPruning, which doesn't copy tags

3, WidenSetOperationTypes in 17c206f

  • using resolveOperatorsUpWithNewOutput -> transformUpWithNewOutput, which doesn't copy tags

4, ResolvePivot in 1a89bdc

  • using resolveOperatorsWithPruning -> resolveOperatorsDownWithPruning, which doesn't copy tags

5, CTESubstitution in 79d1cde

  • using both resolveOperatorsDownWithPruning and resolveOperatorsUp -> resolveOperatorsUpWithPruning, the former does't copy tags

But plan id missing issue still keep popping up (see #44454), so this PR attempt to cover more cases by fixing the helper functions which are used to build the rules

6, ResolveUnpivot

  • using resolveOperatorsWithPruning -> resolveOperatorsDownWithPruning, which doesn't copy tags

7, UnpivotCoercion

  • using resolveOperators -> resolveOperatorsWithPruning -> resolveOperatorsDownWithPruning, which doesn't copy tags

Does this PR introduce any user-facing change?

no

How was this patch tested?

ut

Was this patch authored or co-authored using generative AI tooling?

no

@zhengruifeng zhengruifeng marked this pull request as draft December 22, 2023 11:50
@zhengruifeng zhengruifeng changed the title [SPARK-46484][SQL][CONNECT] Make resolveOperators* functions keep the plan id [SPARK-46484][WIP][SQL][CONNECT] Make resolveOperators* functions keep the plan id Dec 24, 2023
@zhengruifeng zhengruifeng marked this pull request as ready for review December 24, 2023 01:24
@zhengruifeng
Copy link
Contributor Author

cc @cloud-fan @HyukjinKwon

@zhengruifeng zhengruifeng changed the title [SPARK-46484][WIP][SQL][CONNECT] Make resolveOperators* functions keep the plan id [WIP][SPARK-46484][SQL][CONNECT] Make resolveOperators* functions keep the plan id Dec 24, 2023
@dongjoon-hyun dongjoon-hyun marked this pull request as draft December 24, 2023 22:34
@dongjoon-hyun
Copy link
Member

I converted it to Draft because of [WIP] tag, @zhengruifeng .

@zhengruifeng zhengruifeng changed the title [WIP][SPARK-46484][SQL][CONNECT] Make resolveOperators* functions keep the plan id [WIP][SPARK-46484][SQL][CONNECT] Make resolveOperators* helper functions keep the plan id Dec 25, 2023
@zhengruifeng zhengruifeng marked this pull request as ready for review December 28, 2023 11:52
@zhengruifeng zhengruifeng changed the title [WIP][SPARK-46484][SQL][CONNECT] Make resolveOperators* helper functions keep the plan id [SPARK-46484][SQL][CONNECT] Make resolveOperators* helper functions keep the plan id Dec 28, 2023
@zhengruifeng
Copy link
Contributor Author

@cloud-fan I think it is ready for a review

newPlan.copyTagsFrom(self)
newPlan
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method resolveOperatorsDownWithPruning is very similar to TreeNode#transformDownWithPruning. Would be good if we can refactor and unify them. cc @beliefer

@zhengruifeng
Copy link
Contributor Author

thanks @cloud-fan and @HyukjinKwon

merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants