fix: preserve quoted aliases in CTAS (cherry-pick #25926) - #25932
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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/mysqlandpkg/sql/plantests 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 vetpassed 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.
What type of PR is this?
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
SELECTinto an internalINSERT ... SELECTstatement 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 ... USINGcolumns, qualified names, and target table names. It includes parser, planner, and end-to-end CTAS regression coverage.Validation on
4.1-dev:go vetpassed;