Skip to content

[SPARK-52991][SQL][FOLLOW-UP] Revise MergeIntoTable to use lazy val and add a new test#52362

Closed
szehon-ho wants to merge 1 commit intoapache:masterfrom
szehon-ho:merge_schema_evolution_follow
Closed

[SPARK-52991][SQL][FOLLOW-UP] Revise MergeIntoTable to use lazy val and add a new test#52362
szehon-ho wants to merge 1 commit intoapache:masterfrom
szehon-ho:merge_schema_evolution_follow

Conversation

@szehon-ho
Copy link
Copy Markdown
Member

@szehon-ho szehon-ho commented Sep 17, 2025

What changes were proposed in this pull request?

Minor follow up for #51698

  1. Small optimization for MergeIntoTable node (@aokolnychyi noticed post-commit that the new states can be calculated once using lazy val, as each time rules will copy the node so the state never changes).
  2. Relocate left, right, withNewChildrenInternal
  3. Add test to validate that default values work in schema evolution case.

Why are the changes needed?

Small analysis performance improvement and increase test coverage

Does this PR introduce any user-facing change?

No

How was this patch tested?

Run existing tests, and the patch adds another test

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

No

@github-actions github-actions bot added the SQL label Sep 17, 2025
@szehon-ho szehon-ho changed the title [SPARK-52991][SQL][FOLLOW-UP] Small optimization for MERGE INTO with SCHEMA EVOLUTION and add test [SPARK-52991][SQL][FOLLOW-UP] Small optimization for MERGE INTO WITH SCHEMA EVOLUTION and add test Sep 17, 2025
override def right: LogicalPlan = sourceTable
override protected def withNewChildrenInternal(
newLeft: LogicalPlan, newRight: LogicalPlan): MergeIntoTable =
copy(targetTable = newLeft, sourceTable = newRight)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi, @szehon-ho . May I ask why you propose to move the above 5 lines as an optimization? This doesn't look like an optimization. If this is a simple relocation, I'd ask you revert this change from this PR because this PR's title is Small optimization for ....

Copy link
Copy Markdown
Member Author

@szehon-ho szehon-ho Sep 17, 2025

Choose a reason for hiding this comment

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

Hi @dongjoon-hyun thanks for looking at it, yes its a minor cleanup, i noticed the other lazy vals are above the left, right, etc and move these ones to join them. I can revert it tomorrow if its an issue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Got it. No problem. Let me revise the PR title and description a little and merge this, @szehon-ho. Thank you.

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-52991][SQL][FOLLOW-UP] Small optimization for MERGE INTO WITH SCHEMA EVOLUTION and add test [SPARK-52991][SQL][FOLLOW-UP] Revise MergeIntoTable to use lazy val and add a new test Sep 17, 2025
Copy link
Copy Markdown
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM.

@dongjoon-hyun
Copy link
Copy Markdown
Member

Merged to master for Apache Spark 4.1.0-preview2.

Thank you, @szehon-ho .

@szehon-ho
Copy link
Copy Markdown
Member Author

Thank you, @dongjoon-hyun !

huangxiaopingRD pushed a commit to huangxiaopingRD/spark that referenced this pull request Nov 25, 2025
…l` and add a new test

### What changes were proposed in this pull request?
Minor follow up for apache#51698

1. Small optimization for MergeIntoTable node (aokolnychyi noticed post-commit that the new states can be calculated once using `lazy val`, as each time rules will copy the node so the state never changes).
2. Relocate `left`, `right`, `withNewChildrenInternal`
3. Add test to validate that default values work in schema evolution case.

### Why are the changes needed?
Small analysis performance improvement and increase test coverage

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Run existing tests, and the patch adds another test

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

Closes apache#52362 from szehon-ho/merge_schema_evolution_follow.

Authored-by: Szehon Ho <szehon.apache@gmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants