Skip to content

fix: preserve quoted aliases in CTAS (cherry-pick #25926) - #25932

Merged
XuPeng-SH merged 6 commits into
matrixorigin:4.1-devfrom
ck89119:issue-25923-4.1-dev
Jul 21, 2026
Merged

fix: preserve quoted aliases in CTAS (cherry-pick #25926)#25932
XuPeng-SH merged 6 commits into
matrixorigin:4.1-devfrom
ck89119:issue-25923-4.1-dev

Conversation

@ck89119

@ck89119 ck89119 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

fixes #25923

What this PR does / why we need it:

This backports #25926 to 4.1-dev.

CTAS serializes its source SELECT into an internal INSERT ... SELECT statement and parses that SQL again. The serialization did not consistently quote identifiers, so valid aliases using non-ASCII characters, reserved words, spaces, or embedded backticks could become invalid during the rewrite.

This PR makes CTAS identifier serialization complete across SELECT aliases, table and CTE aliases, alias column lists, JOIN ... USING columns, qualified names, and target table names. It includes parser, planner, and end-to-end CTAS regression coverage.

Validation on 4.1-dev:

  • parser and planner package builds passed;
  • parser and planner go vet passed;
  • complete parser and planner package tests passed;
  • CTAS BVT: 953 passed, 0 failed, 30 ignored.

@mergify
mergify Bot requested a review from XuPeng-SH July 21, 2026 04:32
@mergify mergify Bot added the kind/bug Something isn't working label Jul 21, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Jul 21, 2026
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed current head 19a5d600c7b2 against 4.1-dev. No blocking findings.

The six-commit backport is semantically equivalent to #25926; the differences are limited to branch line offsets and expected-result formatting. I traced the CTAS closure from parser AST formatting through generated INSERT ... SELECT reparsing and checked target names, qualified names, SELECT/table/CTE aliases, alias column lists, JOIN ... USING, index hints, embedded backticks, non-ASCII/reserved/space-containing identifiers, interval restoration, user variables, and global/session system-variable scope.

Validation on the exact head:

  • focused parser and planner regressions passed;
  • complete pkg/sql/parsers/dialect/mysql and pkg/sql/plan tests passed;
  • additional review-only round-trip cases passed for CTE, UNION, subquery, window, CASE, GROUP/HAVING/ORDER, interval, user-variable, and global-variable paths;
  • go vet passed for both packages;
  • required UT, SCA, and executed BVT checks are green; Coverage is still pending and remains controlled by CI.

Non-blocking hygiene: git diff --check reports trailing whitespace in two generated .result rows, but this does not affect the fix or runtime behavior.

@XuPeng-SH
XuPeng-SH merged commit a185c23 into matrixorigin:4.1-dev Jul 21, 2026
23 checks passed
@ck89119
ck89119 deleted the issue-25923-4.1-dev branch July 21, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants