Skip to content

[fix](mtmv) Report MaterializedView as the ENGINE of async materialized views - #70523

Merged
morningman merged 1 commit into
apache:masterfrom
morningman:fix-mtmv-engine-name
Nov 18, 2026
Merged

morningman merged 1 commit into
apache:masterfrom
morningman:fix-mtmv-engine-name

Conversation

@morningman

Copy link
Copy Markdown
Contributor

Background

information_schema.tables reports each table's TABLE_TYPE and ENGINE, and SHOW TABLE STATUS reads the same columns. The FE takes ENGINE from TableIf.TableType.toEngineName(): Doris for OLAP tables, View for views, and Hive, jdbc, Stream and so on for the other kinds. An async materialized view (MTMV) is an OLAP table whose type is MATERIALIZED_VIEW; since #38797 its TABLE_TYPE is BASE TABLE.

What problem does this PR solve?

Issue Number: None
Related PR: #38797 (made the TABLE_TYPE of an MTMV BASE TABLE), #14930 (gave MATERIALIZED_VIEW its first MySQL table type)
PR Type: Bugfix

Problem Summary:

ENGINE is NULL for every async materialized view in information_schema.tables and SHOW TABLE STATUS, while every other table, and every view, names its engine. Clients that classify tables by ENGINE have no value to go on for them; the OpenMetadata Doris connector, for example, ingests them as regular tables. This PR reports MaterializedView, spelled like InlineView and ElasticSearch; the REST meta API's tableType changes with it (see Behavior change).

Details

  • Frequency: Always. CREATE MATERIALIZED VIEW mv BUILD DEFERRED REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 1 PROPERTIES ("replication_num" = "1") AS SELECT k, v FROM t; SELECT TABLE_TYPE, ENGINE FROM information_schema.tables WHERE TABLE_NAME = 'mv'; returns BASE TABLE and NULL.
  • Root cause: TableIf.TableType.toEngineName() has no case for MATERIALIZED_VIEW and returns null from its default branch. The type got a MySQL table type in [feature-wip](MTMV) Support mapping the partition rule of base table to the materialized view #14930 (VIEW) and [enhance](mtmv)change mysql table type of mtmv to table #38797 (BASE TABLE), but never an engine name.
  • Why existing tests missed it: Unit tests: no test read the engine of an MTMV; MTMVTest covers its info string, refresh state, and persistence. Regression: mtmv_p0/test_build_mtmv only checks that the MTMV's name appears in SHOW FULL TABLES WHERE Table_type = 'BASE TABLE' and in information_schema.tables; mtmv_p0/ivm/test_ivm_create_if_not_exists checks the TABLE_TYPE of a plain table. None reads ENGINE.
  • Fix: map MATERIALIZED_VIEW to MaterializedView in toEngineName(). The fix sits in the type mapping because every place that shows a table's engine reads Table.getEngine(), which returns it.
  • Other paths and branches: SHOW VIEWS selects ENGINE = 'View' and still leaves MTMVs out. Synchronous materialized views are indexes of their base table, not tables: not affected. Release branches: branch-3.1, branch-4.0, branch-4.1, and branch-4.2 have the same gap; since the fix changes output that clients of those releases may already handle, it is proposed for master only.
  • Behavior change: besides information_schema.tables and SHOW TABLE STATUS, Table.getEngine() feeds the tableType field of the REST v2 meta API (/rest/v2/api/meta/.../tables/{table}/schema) and the Type of the table in the plan JSON of an OLAP scan (Table.toSimpleJson); both show MaterializedView for an MTMV instead of null.

Testing

  • New regression suite mtmv_p0/test_mtmv_engine_name: a base table, an MTMV, and a view. information_schema.tables shows them as BASE TABLE/Doris, BASE TABLE/MaterializedView, and VIEW/View, and SHOW TABLE STATUS reports MaterializedView for the MTMV. On the unfixed FE the suite fails (Check tag 'information_schema_tables' failed, line 2 ... Expect cell is: MaterializedView But real is: \N) and SHOW TABLE STATUS shows Engine NULL for the MTMV; on the fixed FE it passes.
  • FE UT MTMVTest#testEngineAndMysqlType checks that an MTMV reports MaterializedView and BASE TABLE. run-fe-ut.sh --run org.apache.doris.mtmv.MTMVTest: 52 tests, 0 failures; with TableIf.java reverted to master, testEngineAndMysqlType fails with expected: <MaterializedView> but was: <null>.
  • Both ran locally. The regression suite ran 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 the same jar with the TableIf classes compiled from master.

Release note

information_schema.tables and SHOW TABLE STATUS report MaterializedView as the ENGINE of async materialized views instead of NULL.

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: As part of the OpenMetadata integration work, asked to give async materialized views a non-null ENGINE on master only, chose the value MaterializedView, and asked for full local verification (an FE build, the regression suite and the FE unit test, each before and after the fix).

@morningman

Copy link
Copy Markdown
Contributor Author

run buildall

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>
…ed views

### Background

`information_schema.tables` reports each table's `TABLE_TYPE` and `ENGINE`, and `SHOW TABLE STATUS` reads the same columns. The FE takes `ENGINE` from `TableIf.TableType.toEngineName()`: `Doris` for OLAP tables, `View` for views, and `Hive`, `jdbc`, `Stream` and so on for the other kinds. An async materialized view (MTMV) is an OLAP table whose type is `MATERIALIZED_VIEW`; since apache#38797 its `TABLE_TYPE` is `BASE TABLE`.

### What problem does this PR solve?

Issue Number: None
Related PR: apache#38797 (made the TABLE_TYPE of an MTMV BASE TABLE), apache#14930 (gave MATERIALIZED_VIEW its first MySQL table type)
PR Type: Bugfix

Problem Summary:

`ENGINE` is NULL for every async materialized view in `information_schema.tables` and `SHOW TABLE STATUS`, while every other table, and every view, names its engine. Clients that classify tables by `ENGINE` have no value to go on for them; the OpenMetadata Doris connector, for example, ingests them as regular tables. This PR reports `MaterializedView`, spelled like `InlineView` and `ElasticSearch`; the REST meta API's `tableType` changes with it (see Behavior change).

### Details

- **Frequency:** Always. `CREATE MATERIALIZED VIEW mv BUILD DEFERRED REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 1 PROPERTIES ("replication_num" = "1") AS SELECT k, v FROM t; SELECT TABLE_TYPE, ENGINE FROM information_schema.tables WHERE TABLE_NAME = 'mv';` returns `BASE TABLE` and NULL.
- **Root cause:** `TableIf.TableType.toEngineName()` has no case for `MATERIALIZED_VIEW` and returns null from its default branch. The type got a MySQL table type in apache#14930 (`VIEW`) and apache#38797 (`BASE TABLE`), but never an engine name.
- **Why existing tests missed it:** Unit tests: no test read the engine of an MTMV; `MTMVTest` covers its info string, refresh state, and persistence. Regression: `mtmv_p0/test_build_mtmv` only checks that the MTMV's name appears in `SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'` and in `information_schema.tables`; `mtmv_p0/ivm/test_ivm_create_if_not_exists` checks the `TABLE_TYPE` of a plain table. None reads `ENGINE`.
- **Fix:** map `MATERIALIZED_VIEW` to `MaterializedView` in `toEngineName()`. The fix sits in the type mapping because every place that shows a table's engine reads `Table.getEngine()`, which returns it.
- **Other paths and branches:** `SHOW VIEWS` selects `ENGINE = 'View'` and still leaves MTMVs out. Synchronous materialized views are indexes of their base table, not tables: not affected. Release branches: branch-3.1, branch-4.0, branch-4.1, and branch-4.2 have the same gap; since the fix changes output that clients of those releases may already handle, it is proposed for master only.
- **Behavior change:** besides `information_schema.tables` and `SHOW TABLE STATUS`, `Table.getEngine()` feeds the `tableType` field of the REST v2 meta API (`/rest/v2/api/meta/.../tables/{table}/schema`) and the `Type` of the table in the plan JSON of an OLAP scan (`Table.toSimpleJson`); both show `MaterializedView` for an MTMV instead of null.

### Testing

- New regression suite `mtmv_p0/test_mtmv_engine_name`: a base table, an MTMV, and a view. `information_schema.tables` shows them as `BASE TABLE`/`Doris`, `BASE TABLE`/`MaterializedView`, and `VIEW`/`View`, and `SHOW TABLE STATUS` reports `MaterializedView` for the MTMV. On the unfixed FE the suite fails (`Check tag 'information_schema_tables' failed, line 2 ... Expect cell is: MaterializedView But real is: \N`) and `SHOW TABLE STATUS` shows Engine NULL for the MTMV; on the fixed FE it passes.
- FE UT `MTMVTest#testEngineAndMysqlType` checks that an MTMV reports `MaterializedView` and `BASE TABLE`. `run-fe-ut.sh --run org.apache.doris.mtmv.MTMVTest`: 52 tests, 0 failures; with `TableIf.java` reverted to master, `testEngineAndMysqlType` fails with `expected: <MaterializedView> but was: <null>`.
- Both ran locally. The regression suite ran 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 the same jar with the `TableIf` classes compiled from master.

### Release note

`information_schema.tables` and `SHOW TABLE STATUS` report `MaterializedView` as the ENGINE of async materialized views instead of NULL.

### 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: As part of the OpenMetadata integration work, asked to give async materialized views a non-null ENGINE on master only, chose the value MaterializedView, and asked for full local verification (an FE build, the regression suite and the FE unit test, each before and after the fix).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@morningman

Copy link
Copy Markdown
Contributor Author

run buildall

@morningman

Copy link
Copy Markdown
Contributor Author

Local pipeline review — ✅ PASS

schema: doris-repo-review/v1
status: PASS
pr: apache/doris#70523
commit: 6e329402e43bab19b79d390acf681ef239edfb13
base: c298259d425b0418568bc8f25bbb397dd34b1e16
reviewed_at: 2026-11-17T15:11+08:00
reviewer: morningman
model: gpt-6.1-sol
effort: xhigh
findings: {blocker: 0, major: 0, minor: 0, nit: 2}
rounds: 1
converged: true

Notes for maintainers

  • F-01 (wording): fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java:342 changes SQL ENGINE and plan JSON as intended. Correct the PR description's REST tableType claim: the live schema endpoint still derives engineType from the unchanged enum; the engine-based helper has no callers.
  • F-02 (maintainability): regression-test/suites/mtmv_p0/test_mtmv_engine_name.groovy:57 correctly checks SHOW output, but deterministic Name/Engine fields should use quickRunTest row conversion and a generated .out baseline under the repository convention.
  • Static review only; no builds or tests were run during this review. No undeclared runtime regression was substantiated.

Reviewed locally with the doris-repo-review pipeline. Repository policy may accept this receipt for the matching commit; it is not a human Apache approval.

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>
morningman added a commit to morningman/doris that referenced this pull request Nov 18, 2026
### Background

Since apache#61382, a table stream (`CREATE STREAM s ON TABLE t`) is listed with the tables and views of its database in `SHOW FULL TABLES` and `information_schema.tables`, with `ENGINE` `Stream`. Incremental refresh (apache#62606) creates one for each base table of an incrementally refreshed materialized view, named `__doris_ivm_stream_<mv id>_<hash>`. `TableIf.TableType.toMysqlType` gives a stream the table type `VIEW`.

### What problem does this PR solve?

Issue Number: None

Related PR: apache#61382, apache#62606

PR Type: Enhancement

Problem Summary: Metadata clients take a `VIEW` row for a view: they read its definition and parse it for lineage. A stream has no view definition; `SHOW CREATE TABLE` prints `CREATE STREAM ... ON TABLE ...`. OpenMetadata, for one, ingests every stream as a view whose definition is that statement, and the streams incremental refresh creates appear as views nobody created. This PR lists a stream as `BASE TABLE`: it is read with SELECT like a table, and MySQL defines no other table type that fits. `ENGINE` stays `Stream`, so clients can still tell streams apart. Table streams and incremental refresh are only on master, so no released version changes its output.

### Details

- **Before and after:**

  | | Before | After |
  |---|---|---|
  | `Table_type` of a stream in `SHOW FULL TABLES` | `VIEW` | `BASE TABLE` |
  | `TABLE_TYPE`, `ENGINE` of a stream in `information_schema.tables` | `VIEW`, `Stream` | `BASE TABLE`, `Stream` |
  | the `__doris_ivm_stream_*` streams of an incrementally refreshed MV | listed, `VIEW` | listed, `BASE TABLE` |

  Views keep `VIEW` and system tables `SYSTEM VIEW`. `information_schema.views`, `SHOW STREAMS`, `SHOW CREATE TABLE` and `information_schema.table_streams` are unchanged: they select streams and views by `TableType`, not by this string.
- **Configs and defaults:** None.
- **Impact on existing users:** None on released versions: table streams and incremental refresh are on neither branch-4.1 nor branch-4.2. On master, `SHOW FULL TABLES ... WHERE Table_type = 'VIEW'` and JDBC `getTables` with the type `VIEW` no longer return streams, and the type `TABLE` now does. Nothing is persisted: the type is computed whenever a listing is served.

### Testing

- Regression test (new): `query_p0/schema_table/test_stream_table_type` creates a table, a stream on it and a view, and checks the stream and the view in `SHOW FULL TABLES`, all three in `information_schema.tables`, and that `information_schema.views` lists only the view. The `.out` is generated. On the code before this PR it fails at its first check: `Expect cell is: BASE TABLE`, `But real is: VIEW`.
- FE unit test (new): `TableTypeTest` checks that a stream maps to `BASE TABLE` with the engine `Stream`, and that `VIEW`, `INLINE_VIEW`, `SCHEMA`, `OLAP` and `MATERIALIZED_VIEW` keep their types. `./run-fe-ut.sh --run org.apache.doris.catalog.TableTypeTest`: 2 tests, 0 failures.
- Manual: an incrementally refreshed materialized view over a merge-on-write table with changelog; its `__doris_ivm_stream_*` stream is listed as `BASE TABLE` / `Stream` in both listings, and as `VIEW` / `Stream` before this PR.
- Environment: a local cluster whose FE ran this branch's fe-core jar (and, for the before runs, a jar of the same base without this change), with a BE from an earlier master build (`6991e766329`); the change is FE-only.

### Notes for Reviewers

- Why `BASE TABLE` and not a new value such as `STREAM`: MySQL defines `BASE TABLE`, `VIEW` and `SYSTEM VIEW`, and clients map and filter by them (MySQL Connector/J returns `BASE TABLE` rows as `TABLE` from `getTables`), so a new value would drop streams from client listings or break their type mapping.
- Why the streams incremental refresh creates stay listed: they are real objects that `SHOW STREAMS` and `information_schema.table_streams` show and that can be queried; hiding them by their name prefix in some listings would make the listings disagree.
- The incremental-refresh case is checked by hand rather than in the suite: it needs a merge-on-write base table with changelog, and a materialized view's `ENGINE` in `information_schema.tables` is about to change (apache#70523), which the `.out` would then depend on.

### Release note

None

### Check List (For Author)

- Behavior changed: Yes. Table streams are listed as `BASE TABLE` instead of `VIEW`; table streams are not released yet.
- Does this need documentation: No. doris-website has no page on table streams yet.
- Pre-submission status: Ready

### AI Disclosure

- Tool: Claude Code (Claude Opus 5.5)
- Generated: the code change, both tests and this description
- Human review: not stated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@yujun777 yujun777 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.

LGTM

@morningman
morningman merged commit 3c559f7 into apache:master Nov 18, 2026
34 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Nov 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

morningman added a commit that referenced this pull request Nov 19, 2026
)

### Background

Since #61382, a table stream (`CREATE STREAM s ON TABLE t`) is listed
with the tables and views of its database in `SHOW FULL TABLES` and
`information_schema.tables`, with `ENGINE` `Stream`. Incremental refresh
(#62606) creates one for each base table of an incrementally refreshed
materialized view, named `__doris_ivm_stream_<mv id>_<hash>`.
`TableIf.TableType.toMysqlType` gives a stream the table type `VIEW`.

### What problem does this PR solve?

Issue Number: None

Related PR: #61382 (introduced table streams), #62606 (introduced
incremental refresh)

PR Type: Enhancement

Problem Summary: Metadata clients interpret streams listed as `VIEW` as
views and try to parse their `CREATE STREAM ... ON TABLE ...`
definitions; OpenMetadata exposes IVM streams as user views. List
streams as `BASE TABLE`, keeping `ENGINE = 'Stream'` so clients can
distinguish them. Adapt the global hash-bucket checker to select the
`Doris` engine, since streams have no physical buckets. Streams and
incremental refresh exist only on master, so released versions are
unaffected.

### Details

- **Before and after:**

  | | Before | After |
  |---|---|---|
| `Table_type` of a stream in `SHOW FULL TABLES` | `VIEW` | `BASE TABLE`
|
| `TABLE_TYPE`, `ENGINE` of a stream in `information_schema.tables` |
`VIEW`, `Stream` | `BASE TABLE`, `Stream` |
| the `__doris_ivm_stream_*` streams of an incrementally refreshed MV |
listed, `VIEW` | listed, `BASE TABLE` |

Views keep `VIEW` and system tables `SYSTEM VIEW`.
`information_schema.views`, `SHOW STREAMS`, `SHOW CREATE TABLE` and
`information_schema.table_streams` are unchanged: they select streams
and views by `TableType`, not by this string.
- **Configs and defaults:** None.
- **Impact on existing users:** None on released versions: table streams
and incremental refresh are on neither branch-4.1 nor branch-4.2. On
master, `SHOW FULL TABLES ... WHERE Table_type = 'VIEW'` and JDBC
`getTables` with the type `VIEW` no longer return streams, and the type
`TABLE` now does. Nothing is persisted: the type is computed whenever a
listing is served.

### Testing

- CloudP0 on `6f6109a339b8`: `test_stream_table_type` passed;
`check_hash_bucket_table` failed when `SHOW PARTITIONS` reached an
internal IVM stream. The engine selector added in this follow-up has not
been rerun against a cluster; this worktree has no deployed FE/BE.
- Regression test (new): `query_p0/schema_table/test_stream_table_type`
creates a table, a stream on it and a view, and checks the stream and
the view in `SHOW FULL TABLES`, all three in
`information_schema.tables`, and that `information_schema.views` lists
only the view. The `.out` is generated. On the code before this PR it
fails at its first check: `Expect cell is: BASE TABLE`, `But real is:
VIEW`.
- FE unit test (new): `TableTypeTest` checks that a stream maps to `BASE
TABLE` with the engine `Stream`, and that `VIEW`, `INLINE_VIEW`,
`SCHEMA`, `OLAP` and `MATERIALIZED_VIEW` keep their types.
`./run-fe-ut.sh --run org.apache.doris.catalog.TableTypeTest`: 2 tests,
0 failures.
- Manual: an incrementally refreshed materialized view over a
merge-on-write table with changelog; its `__doris_ivm_stream_*` stream
is listed as `BASE TABLE` / `Stream` in both listings, and as `VIEW` /
`Stream` before this PR.
- Original local checks used this branch's FE jar, or the same base
without the metadata change, with BE `6991e766329` from an earlier
master build.

### Notes for Reviewers

- `check_hash_bucket_table` selects the current database's `Doris`
engine tables from `information_schema.tables`. `BASE TABLE` includes
streams, for which `SHOW PARTITIONS` is invalid. Filtering by engine
covers user and IVM streams; async-MV exclusion stays in place.
- Why `BASE TABLE`: Connector/J maps it to `TABLE` and clients filter by
standard MySQL types; an unfamiliar value such as `STREAM` could drop
streams from listings or break type mapping.
- Why the streams incremental refresh creates stay listed: they are real
objects that `SHOW STREAMS` and `information_schema.table_streams` show
and that can be queried; hiding them by their name prefix in some
listings would make the listings disagree.
- The incremental-refresh case is checked by hand rather than in the
suite: it needs a merge-on-write base table with changelog, and a
materialized view's `ENGINE` in `information_schema.tables` is about to
change (#70523), which the `.out` would then depend on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.2.x dev/4.2.x-conflict reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants