-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-51513][SQL] Fix RewriteMergeIntoTable rule produces unresolved plan #50281
base: master
Are you sure you want to change the base?
Conversation
cc @cloud-fan |
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.
Thank you for the fix, @wangyum .
@@ -1091,6 +1092,8 @@ object FoldablePropagation extends Rule[LogicalPlan] { | |||
object SimplifyCasts extends Rule[LogicalPlan] { | |||
def apply(plan: LogicalPlan): LogicalPlan = plan.transformAllExpressionsWithPruning( | |||
_.containsPattern(CAST), ruleId) { | |||
case c @ Cast(e: Attribute, StringType, _, _) |
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.
does it have to be Attribute? I think we should match NamedExpression
so that nested fields can also be covered.
@aokolnychyi can you also take a look? |
LGTM |
@@ -449,7 +449,8 @@ class Analyzer(override val catalogManager: CatalogManager) extends RuleExecutor | |||
Batch("DML rewrite", fixedPoint, | |||
RewriteDeleteFromTable, | |||
RewriteUpdateTable, | |||
RewriteMergeIntoTable), | |||
RewriteMergeIntoTable, | |||
ResolveOutputRelation), |
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.
can we add some comments to explain how these rules above can make the plan unresolved and we need to run ResolveOutputRelation
to re-resolve it?
What changes were proposed in this pull request?
This patch addresses the issue where the
RewriteMergeIntoTable
rule produces an unresolved plan. The changes ensure that the MERGE INTO operation correctly handles cases where the source table contains rows that need to be inserted into the target table.Why are the changes needed?
Fix query failure.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Unit test.
Was this patch authored or co-authored using generative AI tooling?
No.