This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 3c559f7a529 [fix](mtmv) Report MaterializedView as the ENGINE of async
materialized views (#70523)
3c559f7a529 is described below
commit 3c559f7a52919ee782099045ad85c3be31b684d9
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Wed Nov 18 11:53:34 2026 +0800
[fix](mtmv) Report MaterializedView as the ENGINE of async materialized
views (#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.
---
.../java/org/apache/doris/catalog/TableIf.java | 2 +
.../test/java/org/apache/doris/mtmv/MTMVTest.java | 8 +++
.../data/mtmv_p0/test_mtmv_engine_name.out | 6 +++
.../suites/mtmv_p0/test_mtmv_engine_name.groovy | 60 ++++++++++++++++++++++
4 files changed, 76 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java
index 3bcebc6e9bf..0baece474e1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java
@@ -339,6 +339,8 @@ public interface TableIf {
return "jdbc";
case TABLE_VALUED_FUNCTION:
return "Table_Valued_Function";
+ case MATERIALIZED_VIEW:
+ return "MaterializedView";
case DICTIONARY:
return "dictionary";
case DORIS_EXTERNAL_TABLE:
diff --git a/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVTest.java
b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVTest.java
index 3a99d13af1c..f3d4fd192ba 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVTest.java
@@ -79,6 +79,14 @@ import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class MTMVTest {
+ @Test
+ public void testEngineAndMysqlType() {
+ // information_schema.tables and SHOW TABLE STATUS show these as
ENGINE and TABLE_TYPE.
+ MTMV mtmv = new MTMV();
+ Assertions.assertEquals("MaterializedView", mtmv.getEngine());
+ Assertions.assertEquals("BASE TABLE", mtmv.getMysqlType());
+ }
+
@Test
public void testToInfoString() {
String expect
diff --git a/regression-test/data/mtmv_p0/test_mtmv_engine_name.out
b/regression-test/data/mtmv_p0/test_mtmv_engine_name.out
new file mode 100644
index 00000000000..7fc024d3da0
--- /dev/null
+++ b/regression-test/data/mtmv_p0/test_mtmv_engine_name.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !information_schema_tables --
+test_mtmv_engine_name_base BASE TABLE Doris
+test_mtmv_engine_name_mv BASE TABLE MaterializedView
+test_mtmv_engine_name_view VIEW View
+
diff --git a/regression-test/suites/mtmv_p0/test_mtmv_engine_name.groovy
b/regression-test/suites/mtmv_p0/test_mtmv_engine_name.groovy
new file mode 100644
index 00000000000..76f947251f2
--- /dev/null
+++ b/regression-test/suites/mtmv_p0/test_mtmv_engine_name.groovy
@@ -0,0 +1,60 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_mtmv_engine_name", "mtmv") {
+ sql """drop materialized view if exists test_mtmv_engine_name_mv"""
+ sql """drop view if exists test_mtmv_engine_name_view"""
+ sql """drop table if exists test_mtmv_engine_name_base"""
+
+ sql """
+ CREATE TABLE test_mtmv_engine_name_base
+ (
+ k INT,
+ v INT
+ )
+ DUPLICATE KEY(k)
+ DISTRIBUTED BY HASH(k) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1"
+ );
+ """
+ sql """
+ CREATE MATERIALIZED VIEW test_mtmv_engine_name_mv
+ BUILD DEFERRED REFRESH COMPLETE ON MANUAL
+ DISTRIBUTED BY RANDOM BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1"
+ )
+ AS
+ SELECT k, v FROM test_mtmv_engine_name_base;
+ """
+ sql """
+ CREATE VIEW test_mtmv_engine_name_view AS SELECT k FROM
test_mtmv_engine_name_base;
+ """
+
+ // An async materialized view is a BASE TABLE, and like every other table
it names its engine.
+ qt_information_schema_tables """
+ SELECT TABLE_NAME, TABLE_TYPE, ENGINE FROM information_schema.tables
+ WHERE TABLE_SCHEMA = '${context.dbName}' AND TABLE_NAME LIKE
'test_mtmv_engine_name%'
+ ORDER BY TABLE_NAME
+ """
+
+ // SHOW TABLE STATUS reads the same column. Its other columns, such as the
times, vary between runs.
+ def tableStatus = sql """SHOW TABLE STATUS LIKE
'test_mtmv_engine_name_mv'"""
+ assertEquals(1, tableStatus.size())
+ assertEquals("MaterializedView", tableStatus[0][1]) // Engine
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]