Skip to content

branch-4.1 [fix](view) Quote view column names in SHOW CREATE VIEW output - #67398

Draft
englefly wants to merge 2 commits into
apache:branch-4.1from
englefly:pick-66467-4.1
Draft

branch-4.1 [fix](view) Quote view column names in SHOW CREATE VIEW output#67398
englefly wants to merge 2 commits into
apache:branch-4.1from
englefly:pick-66467-4.1

Conversation

@englefly

@englefly englefly commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Cherry-pick of #66467 to branch-4.1

fix Quote view column names in SHOW CREATE VIEW output

### What problem does this PR solve?

Issue Number: None

Related PR: apache#55819

Problem Summary:
When a view is created with a column name containing special characters
(e.g. `create view v as select 1 as '(第一列)'` with enable_unicode_name_support
enabled), SHOW CREATE VIEW emits an unquoted column definition list like
`((第一列))` — the outer parens are the list, the inner `(第一列)` is the raw
column name emitted without backtick quoting. The generated DDL is not
re-executable: the CREATE VIEW column list grammar requires an identifier
(DorisParser.g4 simpleColumnDef -> identifier), and an unquoted name with
parens fails to parse (`mismatched input '第一列'`).

The column list itself was introduced by apache#55819 to preserve explicit column
definitions/comments in SHOW CREATE VIEW, but Env.addColNameAndComment
(Env.java) emitted column names verbatim.

Fix: quote every column name with SqlUtils.getIdentSql (backtick-quoting with
embedded-backtick escaping) and escape single quotes in column comments.
After the fix SHOW CREATE VIEW outputs
`CREATE VIEW `v` (`(第一列)`) AS select 1 as `(第一列)`;` which is valid SQL
and round-trips.

### Release note

SHOW CREATE VIEW now quotes view column names in the column definition list,
so the output stays re-executable even when column names contain special
characters (e.g. created via string-literal aliases with
enable_unicode_name_support).

### Check List (For Author)

- Test:
    - FE compile: `mvn compile -pl fe-core -am` passed
    - Ad-hoc parser verification passed (fixed DDL parses, old unquoted DDL rejected)
    - Regression suite ddl_p0/create_view_nereids run and
      test_create_view_nereids.out regenerated with the fixed output;
      the other 7 affected .out files still need regeneration
- Behavior changed: Yes (SHOW CREATE VIEW output format)
- Does this need documentation: No
…column names in SHOW CREATE VIEW

Issue Number: None

Related PR: apache#55819

Problem Summary: The SHOW CREATE VIEW column-list quoting fix (SqlUtils.getIdentSql in Env.addColNameAndComment) changes the emitted DDL: every view column name in the column definition list is now backtick-quoted, e.g. (user_id,cost) becomes (`user_id`,`cost`). The 7 affected regression .out files are regenerated accordingly, and the hardcoded assertion in mtmv_p0/test_show_create_mtmv is updated to expect the quoted column list (`aa` comment 'aa_comment',`bb`). The replica-3 golden blocks in test_show_create_table_and_views_nereids.out are unchanged by this PR and are preserved.

None

- Test: Regression test (all 8 listed suites run with -forceGenOut to regenerate, then re-run without the flag and verified passing)
- Behavior changed: No (test-only changes)
- Does this need documentation: No
@englefly

englefly commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

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.

2 participants