morningman opened a new pull request, #70523:
URL: https://github.com/apache/doris/pull/70523
### 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 #14930 (`VIEW`) and #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 6991e766329 (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).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]