Repository navigation
[fix](view) Quote view column names in SHOW CREATE VIEW output - #66467
Merged
englefly merged 2 commits intoAug 10, 2026
Merged
Conversation
### 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
englefly
requested review from
CalvinKirs,
dataroaring and
morningman
as code owners
August 5, 2026 05:53
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
FE Regression Coverage ReportIncrement line coverage |
Contributor
TPC-H: Total hot run time: 29478 ms |
Contributor
TPC-DS: Total hot run time: 166744 ms |
Contributor
ClickBench: Total hot run time: 23.86 s |
…s in SHOW CREATE VIEW ### What problem does this PR solve? 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. ### Release note None ### Check List (For Author) - 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
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 29241 ms |
Contributor
TPC-DS: Total hot run time: 158818 ms |
Contributor
ClickBench: Total hot run time: 23.83 s |
Contributor
FE Regression Coverage ReportIncrement line coverage |
morrySnow
approved these changes
Aug 10, 2026
Contributor
|
replace chinese by english in description |
Contributor
|
PR approved by at least one committer and no changes requested. |
Contributor
|
PR approved by anyone and no changes requested. |
CalvinKirs
approved these changes
Aug 10, 2026
wyxxxcat
pushed a commit
to wyxxxcat/doris
that referenced
this pull request
Aug 17, 2026
…e#66467) ### 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.
morningman
added a commit
to morningman/doris
that referenced
this pull request
Nov 17, 2026
…ZED VIEW ### Background `SHOW CREATE MATERIALIZED VIEW <mv>` prints the statement that creates an async materialized view (MTMV): its name and column list, refresh method, key, partitioning, distribution, properties and query, so that users can copy it or re-create the MV. `Env.getMTMVDdl` builds the statement. Since apache#66467 it quotes the column names with `SqlUtils.getIdentSql`, as `SHOW CREATE TABLE` and `SHOW CREATE VIEW` quote table and view names. ### What problem does this PR solve? Issue Number: None Related PR: apache#36188 (introduced SHOW CREATE MATERIALIZED VIEW), apache#66467 (quoted the column names of the same statement) PR Type: Bugfix Problem Summary: `SHOW CREATE MATERIALIZED VIEW` prints the materialized view's name without backquotes, so the statement it prints fails to execute when the name needs them: a reserved word such as `select`, a name with `-` or `$`, or a name that `enable_unicode_name_support` allows. Users who re-create an MV from it, and tools that parse it, get a syntax error. This PR quotes the name with `SqlUtils.getIdentSql`, as the column list already is. ### Details - **Frequency:** Always, for a name that needs quoting. For an MV created as `` `mv-dash` ``, the output starts with `CREATE MATERIALIZED VIEW mv-dash`, and executing it fails with `Possibly unquoted identifier mv-dash detected`; for an MV named `select`, it fails with `mismatched input 'select'`. - **Root cause:** `Env.getMTMVDdl` appends `mtmv.getName()` as it is, since apache#36188 added the statement. apache#66467 fixed the same problem for the column list and left the name. - **Why existing tests missed it:** Unit tests: `ShowCreateMTMVTest` re-executes the DDL, but every MV in it has a plain name. Regression: `mtmv_p0/test_show_create_mtmv` re-executes the output for the plain name `test_show_create_mtmv_mv`, and the other suites that run the statement use plain names too. - **Fix:** quote the name with `SqlUtils.getIdentSql`, as the column list is. `Env.getMTMVDdl` is the only place that builds the statement. - **Other paths and branches:** `SHOW CREATE TABLE` refuses async MVs; it and `SHOW CREATE VIEW` already quote names, and a synchronous MV (`SHOW CREATE MATERIALIZED VIEW mv ON tbl`) prints the statement as the user wrote it. branch-3.1, branch-4.0, branch-4.1 and branch-4.2 print the bare name; apache#66467 reached only 4.1 and 4.2, so 3.1 and 4.0 print the column list bare too. Since released output changes, this PR targets master; picks are the committers' call. - **Behavior change:** the first line gains backquotes for every MV, as in `CREATE MATERIALIZED VIEW `mv1``. The statement still executes, but scripts that match that line literally see the change. ### Testing - FE UT `ShowCreateMTMVTest#testShowCreateQuotesMVName` creates MVs named `select` and `mv-show-quoted-name`, checks that the DDL starts with the quoted name, and re-creates a copy from it. `run-fe-ut.sh --run org.apache.doris.catalog.ShowCreateMTMVTest`: 11 tests, 0 failures; with `Env.java` reverted to master, the new test fails (`... but got: CREATE MATERIALIZED VIEW select`) and the other 10 pass. - Regression `mtmv_p0/test_show_create_mtmv` adds an MV named `test_show_create_mtmv-mv`: the output starts with the quoted name, and re-executing it re-creates the MV with the same output. On the unfixed FE the suite fails at that assertion (the output starts with `CREATE MATERIALIZED VIEW test_show_create_mtmv-mv`); on the fixed FE it passes. - Both ran locally on a single-FE, single-BE cluster: an FE built from this PR and a BE built from 6991e76 (the change is FE-only). The unfixed FE is apache/master e125ea8 plus apache#70523, which touches only `TableIf.java`; its `Env.java` equals this PR's base. ### Notes for Reviewers - The suite drops `test_show_create_mtmv-mv` at its end, unlike the usual practice of keeping objects for debugging: `check_before_quit` runs `show create table` on every table with the name unquoted, and records a failure for a name that needs quoting. ### Release note `SHOW CREATE MATERIALIZED VIEW` quotes the materialized view's name with backquotes, so the statement it prints executes for names such as `select` or `mv-1`. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Claude Code (Claude Opus 5.5) - Generated: code, tests, this description - Human review: not stated - Prompts: While integrating OpenMetadata with Doris, asked to fix Doris output that is unreasonable in Doris instead of working around it in OpenMetadata; after the agent reported that SHOW CREATE MATERIALIZED VIEW prints the name bare, asked for a Doris PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hello-stephen
pushed a commit
that referenced
this pull request
Nov 17, 2026
…ZED VIEW (#70539) ### Background `SHOW CREATE MATERIALIZED VIEW <mv>` prints the statement that creates an async materialized view (MTMV): its name and column list, refresh method, key, partitioning, distribution, properties and query, so that users can copy it or re-create the MV. `Env.getMTMVDdl` builds the statement. Since #66467 it quotes the column names with `SqlUtils.getIdentSql`, as `SHOW CREATE TABLE` and `SHOW CREATE VIEW` quote table and view names. ### What problem does this PR solve? Issue Number: None Related PR: #36188 (introduced SHOW CREATE MATERIALIZED VIEW), #66467 (quoted the column names of the same statement) PR Type: Bugfix Problem Summary: `SHOW CREATE MATERIALIZED VIEW` prints the materialized view's name without backquotes, so the statement it prints fails to execute when the name needs them: a reserved word such as `select`, a name with `-` or `$`, or a name that `enable_unicode_name_support` allows. Users who re-create an MV from it, and tools that parse it, get a syntax error. This PR quotes the name with `SqlUtils.getIdentSql`, as the column list already is. ### Details - **Frequency:** Always, for a name that needs quoting. For an MV created as `` `mv-dash` ``, the output starts with `CREATE MATERIALIZED VIEW mv-dash`, and executing it fails with `Possibly unquoted identifier mv-dash detected`; for an MV named `select`, it fails with `mismatched input 'select'`. - **Root cause:** `Env.getMTMVDdl` appends `mtmv.getName()` as it is, since #36188 added the statement. #66467 fixed the same problem for the column list and left the name. - **Why existing tests missed it:** Unit tests: `ShowCreateMTMVTest` re-executes the DDL, but every MV in it has a plain name. Regression: `mtmv_p0/test_show_create_mtmv` re-executes the output for the plain name `test_show_create_mtmv_mv`, and the other suites that run the statement use plain names too. - **Fix:** quote the name with `SqlUtils.getIdentSql`, as the column list is. `Env.getMTMVDdl` is the only place that builds the statement. - **Other paths and branches:** `SHOW CREATE TABLE` refuses async MVs; it and `SHOW CREATE VIEW` already quote names, and a synchronous MV (`SHOW CREATE MATERIALIZED VIEW mv ON tbl`) prints the statement as the user wrote it. branch-3.1, branch-4.0, branch-4.1 and branch-4.2 print the bare name; #66467 reached only 4.1 and 4.2, so 3.1 and 4.0 print the column list bare too. Since released output changes, this PR targets master; picks are the committers' call. - **Behavior change:** the first line gains backquotes for every MV, as in `CREATE MATERIALIZED VIEW `mv1``. The statement still executes, but scripts that match that line literally see the change. ### Testing - FE UT `ShowCreateMTMVTest#testShowCreateQuotesMVName` creates MVs named `select` and `mv-show-quoted-name`, checks that the DDL starts with the quoted name, and re-creates a copy from it. `run-fe-ut.sh --run org.apache.doris.catalog.ShowCreateMTMVTest`: 11 tests, 0 failures; with `Env.java` reverted to master, the new test fails (`... but got: CREATE MATERIALIZED VIEW select`) and the other 10 pass. - Regression `mtmv_p0/test_show_create_mtmv` adds an MV named `test_show_create_mtmv-mv`: the output starts with the quoted name, and re-executing it re-creates the MV with the same output. On the unfixed FE the suite fails at that assertion (the output starts with `CREATE MATERIALIZED VIEW test_show_create_mtmv-mv`); on the fixed FE it passes. - Both ran locally on a single-FE, single-BE cluster: an FE built from this PR and a BE built from 6991e76 (the change is FE-only). The unfixed FE is apache/master e125ea8 plus #70523, which touches only `TableIf.java`; its `Env.java` equals this PR's base. ### Notes for Reviewers - The suite drops `test_show_create_mtmv-mv` at its end, unlike the usual practice of keeping objects for debugging: `check_before_quit` runs `show create table` on every table with the name unquoted, and records a failure for a name that needs quoting. ### Release note `SHOW CREATE MATERIALIZED VIEW` quotes the materialized view's name with backquotes, so the statement it prints executes for names such as `select` or `mv-1`. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Claude Code (Claude Opus 5.5) - Generated: code, tests, this description - Human review: not stated - Prompts: While integrating OpenMetadata with Doris, asked to fix Doris output that is unreasonable in Doris instead of working around it in OpenMetadata; after the agent reported that SHOW CREATE MATERIALIZED VIEW prints the name bare, asked for a Doris PR. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: None
Related PR: #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 #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 VIEWv((第一列)) 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)
mvn compile -pl fe-core -ampassedWhat problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)