Skip to content

fix(datafusion): preserve quoted aliases in MERGE statements - #1271

Closed
slfan1989 wants to merge 2 commits into
apache:mainfrom
slfan1989:paimon-rust-1269
Closed

slfan1989 wants to merge 2 commits into
apache:mainfrom
slfan1989:paimon-rust-1269

Conversation

@slfan1989

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: closes #1269

Fix MERGE statements failing with aliases containing spaces, reserved words, embedded quotes, or case-sensitive names.

Brief change log

  • Preserve aliases as sqlparser Ident values throughout MERGE execution.
  • Retain quoting, escaping, and case when generating SQL and rewriting column qualifiers.
  • Add regression coverage for table and subquery aliases on ordinary and Data Evolution tables.

Tests

  • Confirmed both new regression tests fail before the fix.

API and Format

No.

Documentation

No.

@slfan1989

Copy link
Copy Markdown
Contributor Author

Hi @JingsongLi, @QuakeWang Could you please review this PR when you have time? It fixes quoted alias handling in MERGE statements and adds regression tests. Thanks!

@JingsongLi

Copy link
Copy Markdown
Contributor

Requirement fit against current main: superseded by #1315. Implementation: CLEAN at 63e1c70; the 26 MERGE tests pass in an isolated worktree.

The native MERGE implementation now merged at 062f1bc removes the SQL reconstruction and textual alias comparisons changed here. DataFusion resolves quoted aliases before Paimon binds columns by schema position; partition pruning also uses resolved target/source columns.

I verified current main with independent public-SQL round trips covering all six alias forms from this PR, ordinary and data-evolution tables, table and subquery sources, and matched UPDATE / unmatched INSERT followed by DELETE (24 combinations). All pass. The four case-sensitive partition/normalization scenarios from the follow-up fix also pass, alongside the 16 existing native MERGE integration tests.

Closing this implementation as superseded: merging it would restore changes to a replaced execution path without adding observable behavior. The regression cases are useful and can be retained separately in the native MERGE test suite if desired. Please reopen with a failing example on current main if any quoted-alias case remains unsupported.

@JingsongLi JingsongLi closed this Nov 3, 2026
@slfan1989

Copy link
Copy Markdown
Contributor Author

@JingsongLi Thanks for your help and review! Closing this PR makes sense since #1315 has resolved the issue.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MERGE fails with quoted table aliases

3 participants