From 310d8a1bcddf534d62395c2a4d92bdc0b725d971 Mon Sep 17 00:00:00 2001 From: Kevin Cai Date: Tue, 19 May 2026 17:25:44 +0800 Subject: [PATCH 1/3] [BugFix] Restore SHOW CREATE MATERIALIZED VIEW for sync MVs (#73396) Signed-off-by: Kevin Cai (cherry picked from commit 4e35d9dc26a33704b489c0496ad7942a900ac67e) # Conflicts: # fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java --- .../java/com/starrocks/qe/ShowExecutor.java | 95 +++++++++++++++++++ .../catalog/MaterializedViewTest.java | 77 +++++++++++++++ .../R/test_show_create_sync_materialized_view | 39 ++++++++ .../T/test_show_create_sync_materialized_view | 34 +++++++ 4 files changed, 245 insertions(+) create mode 100644 test/sql/test_materialized_view/R/test_show_create_sync_materialized_view create mode 100644 test/sql/test_materialized_view/T/test_show_create_sync_materialized_view diff --git a/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java b/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java index e902912fdad1c2..2fdc3b717976fd 100644 --- a/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java +++ b/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java @@ -743,6 +743,7 @@ private ShowResultSet showCreateInternalCatalogTable(ShowCreateTableStmt showStm Database db = GlobalStateMgr.getCurrentState().getLocalMetastore().getDb(showStmt.getDb()); MetaUtils.checkDbNullAndReport(db, showStmt.getDb()); List> rows = Lists.newArrayList(); +<<<<<<< HEAD TableName tableName = showStmt.getTbl(); Table table = MetaUtils.getSessionAwareTable(connectContext, db, tableName); if (table == null) { @@ -785,7 +786,22 @@ private ShowResultSet showCreateInternalCatalogTable(ShowCreateTableStmt showStm dbLocker.unLockDatabase(db.getId(), LockType.READ); } ErrorReport.reportSemanticException(ErrorCode.ERR_BAD_TABLE_ERROR, showStmt.getTable()); +======= + TableName tableName = new TableName(showStmt.getCatalogName(), showStmt.getDb(), showStmt.getTable()); + // Lookup is ConcurrentHashMap-backed (Database.nameToTable) for internal catalog and + // throws SemanticException if the name does not match a registered Table. + Table table; + try { + table = MetaUtils.getSessionAwareTable(connectContext, db, tableName); + } catch (SemanticException e) { + // Sync MVs are mv indexes inside an OLAP table and are not registered as Tables, + // so the lookup misses. Fall through to a DB-wide scan for the MV-typed query; + // for any other type, the miss is a real "table not found". + if (showStmt.getType() != ShowCreateTableStmt.CreateTableType.MATERIALIZED_VIEW) { + throw e; +>>>>>>> 4e35d9dc26 ([BugFix] Restore SHOW CREATE MATERIALIZED VIEW for sync MVs (#73396)) } + return findSyncMaterializedViewCreateStmt(connectContext, db, showStmt); } Locker locker = new Locker(); locker.lockTableWithIntensiveDbLock(db.getId(), table.getId(), LockType.READ); @@ -829,12 +845,16 @@ private ShowResultSet showCreateInternalCatalogTable(ShowCreateTableStmt showStm .build(); return new ShowResultSet(showViewResultSetMeta, rows); } else { +<<<<<<< HEAD rows.add(Lists.newArrayList(table.getName(), createTableStmt.get(0))); ShowResultSetMetaData showResultSetMetaData = ShowResultSetMetaData.builder() .addColumn(new Column("Materialized View", ScalarType.createVarchar(20))) .addColumn(new Column("Create Materialized View", ScalarType.createVarchar(30))) .build(); return new ShowResultSet(showResultSetMetaData, rows); +======= + return buildShowCreateMaterializedViewResult(table.getName(), createTableStmt.get(0)); +>>>>>>> 4e35d9dc26 ([BugFix] Restore SHOW CREATE MATERIALIZED VIEW for sync MVs (#73396)) } } else { if (showStmt.getType() != ShowCreateTableStmt.CreateTableType.TABLE) { @@ -849,6 +869,81 @@ private ShowResultSet showCreateInternalCatalogTable(ShowCreateTableStmt showStm } } + // Shared SHOW CREATE MATERIALIZED VIEW schema for the async and sync MV paths. + private static ShowResultSet buildShowCreateMaterializedViewResult(String mvName, String createSql) { + List> rows = Lists.newArrayList(); + rows.add(Lists.newArrayList(mvName, createSql)); + ShowResultSetMetaData meta = ShowResultSetMetaData.builder() + .addColumn(new Column("Materialized View", TypeFactory.createVarcharType(20))) + .addColumn(new Column("Create Materialized View", TypeFactory.createVarcharType(30))) + .build(); + return new ShowResultSet(meta, rows); + } + + // Sync MVs live as MaterializedIndexMetas inside an OLAP table, not as + // separate Tables, so a name lookup misses and we scan. The visitor's + // pre-execution auth check resolves the sync MV name to a null BasicTable + // and silently no-ops, so we re-check privileges on the owning OLAP table + // once a match is found; the deny error names the sync MV (not the base + // table) to avoid revealing which table hosts the index. + private ShowResultSet findSyncMaterializedViewCreateStmt(ConnectContext connectContext, + Database db, + ShowCreateTableStmt showStmt) { + // ConcurrentHashMap-backed snapshot: weakly consistent, not a point-in-time + // atomic snapshot. Acceptable here - this is a best-effort fallback. + List tablesSnapshot = GlobalStateMgr.getCurrentState().getLocalMetastore().getTables(db.getId()); + Locker locker = new Locker(); + for (Table tbl : tablesSnapshot) { + // Include CLOUD_NATIVE (shared-data) base tables - sync MVs exist + // there too, see LakeSyncMaterializedViewTest. + if (!tbl.isOlapOrCloudNativeTable()) { + continue; + } + OlapTable olapTable = (OlapTable) tbl; + locker.lockTableWithIntensiveDbLock(db.getId(), olapTable.getId(), LockType.READ); + try { + Long metaId = olapTable.getIndexMetaIdByName(showStmt.getTable()); + // Skip the base index (its name equals the table's current name) - only + // reachable here if a concurrent RENAME slipped between the failed name + // lookup that routed us into this fallback and the snapshot below. + if (metaId == null || metaId == olapTable.getBaseIndexMetaId()) { + continue; + } + // Skip shadow / mid-schema-change indexes. + boolean visible = olapTable.getVisibleIndexMetas().stream() + .anyMatch(m -> m.getIndexMetaId() == metaId); + if (!visible) { + continue; + } + MaterializedIndexMeta mvMeta = olapTable.getIndexMetaByMetaId(metaId); + if (mvMeta == null) { + continue; + } + TableName baseTableName = new TableName(InternalCatalog.DEFAULT_INTERNAL_CATALOG_NAME, + db.getFullName(), olapTable.getName()); + try { + Authorizer.checkAnyActionOnTable(connectContext, baseTableName); + } catch (AccessDeniedException denied) { + AccessDeniedException.reportAccessDenied( + InternalCatalog.DEFAULT_INTERNAL_CATALOG_NAME, + connectContext.getCurrentUserIdentity(), + connectContext.getCurrentRoleIds(), + PrivilegeType.ANY.name(), + ObjectType.TABLE.name(), + showStmt.getTable()); + } + String createSql = mvMeta.getOriginStmt() == null + ? ShowMaterializedViewStatus.buildCreateMVSql(olapTable, showStmt.getTable(), mvMeta) + : mvMeta.getOriginStmt(); + return buildShowCreateMaterializedViewResult(showStmt.getTable(), createSql); + } finally { + locker.unLockTableWithIntensiveDbLock(db.getId(), olapTable.getId(), LockType.READ); + } + } + ErrorReport.reportSemanticException(ErrorCode.ERR_BAD_TABLE_ERROR, showStmt.getTable()); + return null; // unreachable; reportSemanticException always throws + } + private ShowResultSet showCreateExternalCatalogTable(ConnectContext context, ShowCreateTableStmt showStmt, TableName tbl, String catalogName) { String dbName = tbl.getDb(); diff --git a/fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java b/fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java index 75d7164413e8b2..92070f47e876b0 100644 --- a/fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java @@ -629,6 +629,83 @@ public void testShowSyncMV() throws Exception { Assertions.assertEquals(connectContext.getState().getStateType(), QueryState.MysqlStateType.EOF); } + // Regression test: sync MVs are mv indexes inside an OLAP table, not registered as Tables. + // SHOW CREATE MATERIALIZED VIEW must locate the index by name and return its + // CREATE statement instead of failing with "Table not found". + @Test + public void testShowCreateRollupSyncMV() throws Exception { + starRocksAssert.withDatabase("test").useDatabase("test") + .withTable("CREATE TABLE test.tbl_rollup_sync_mv\n" + + "(\n" + + " k1 date,\n" + + " k2 int,\n" + + " v1 int sum\n" + + ")\n" + + "DISTRIBUTED BY HASH(k2) BUCKETS 3\n" + + "PROPERTIES('replication_num' = '1');") + .withMaterializedView( + "create materialized view rollup_sync_mv_to_check as " + + "select k2, sum(v1) as total from tbl_rollup_sync_mv group by k2;"); + String showSql = "show create materialized view rollup_sync_mv_to_check;"; + StatementBase statement = SqlParser.parseSingleStatement(showSql, connectContext.getSessionVariable().getSqlMode()); + StmtExecutor stmtExecutor = new StmtExecutor(connectContext, statement); + stmtExecutor.execute(); + Assertions.assertEquals(QueryState.MysqlStateType.EOF, connectContext.getState().getStateType()); + } + + // Fallback scan exhaustion: a sync-MV-shaped lookup with a name that matches + // nothing in any base table runs through the full snapshot and falls through + // to ErrorReport.reportSemanticException(ERR_BAD_TABLE_ERROR, ...). + @Test + public void testShowCreateSyncMVNotFound() throws Exception { + starRocksAssert.withDatabase("test").useDatabase("test") + .withTable("CREATE TABLE test.tbl_sync_mv_not_found\n" + + "(\n" + + " k1 date,\n" + + " k2 int,\n" + + " v1 int sum\n" + + ")\n" + + "DISTRIBUTED BY HASH(k2) BUCKETS 3\n" + + "PROPERTIES('replication_num' = '1');"); + String showSql = "show create materialized view does_not_exist_anywhere;"; + StatementBase statement = SqlParser.parseSingleStatement(showSql, connectContext.getSessionVariable().getSqlMode()); + StmtExecutor stmtExecutor = new StmtExecutor(connectContext, statement); + stmtExecutor.execute(); + Assertions.assertEquals(QueryState.MysqlStateType.ERR, connectContext.getState().getStateType()); + } + + // Authorization deny path: once the fallback locates the owning base table and + // calls Authorizer.checkAnyActionOnTable, mock the check to throw and verify + // the deny error fires (reportAccessDenied -> ERR state). + @Test + public void testShowCreateSyncMVAccessDenied() throws Exception { + starRocksAssert.withDatabase("test").useDatabase("test") + .withTable("CREATE TABLE test.tbl_sync_mv_auth\n" + + "(\n" + + " k1 date,\n" + + " k2 int,\n" + + " v1 int sum\n" + + ")\n" + + "DISTRIBUTED BY HASH(k2) BUCKETS 3\n" + + "PROPERTIES('replication_num' = '1');") + .withMaterializedView( + "create materialized view sync_mv_auth_deny as " + + "select k2, sum(v1) as total from tbl_sync_mv_auth group by k2;"); + new mockit.MockUp() { + @mockit.Mock + public void checkAnyActionOnTable(ConnectContext context, + com.starrocks.catalog.TableName tableName) + throws com.starrocks.authorization.AccessDeniedException { + throw new com.starrocks.authorization.AccessDeniedException(); + } + }; + String showSql = "show create materialized view sync_mv_auth_deny;"; + StatementBase statement = SqlParser.parseSingleStatement(showSql, connectContext.getSessionVariable().getSqlMode()); + StmtExecutor stmtExecutor = new StmtExecutor(connectContext, statement); + stmtExecutor.execute(); + Assertions.assertEquals(QueryState.MysqlStateType.ERR, connectContext.getState().getStateType()); + } + @Test public void testAlterMVWithIndex() throws Exception { starRocksAssert.withDatabase("test").useDatabase("test") diff --git a/test/sql/test_materialized_view/R/test_show_create_sync_materialized_view b/test/sql/test_materialized_view/R/test_show_create_sync_materialized_view new file mode 100644 index 00000000000000..92373b3965e4bf --- /dev/null +++ b/test/sql/test_materialized_view/R/test_show_create_sync_materialized_view @@ -0,0 +1,39 @@ +-- name: test_show_create_sync_materialized_view @native +create database test_show_create_sync_mv_${uuid0}; +-- result: +-- !result +use test_show_create_sync_mv_${uuid0}; +-- result: +-- !result +create table sync_mv_base +( + k1 date, + k2 int, + v1 int sum +) +distributed by hash(k2) buckets 3 +properties('replication_num' = '1'); +-- result: +-- !result +create materialized view sync_mv_rollup as select k2, sum(v1) from sync_mv_base group by k2; +-- result: +-- !result +function: wait_materialized_view_finish() +-- result: +None +-- !result +show create materialized view sync_mv_rollup; +-- result: +[REGEX]sync_mv_rollup\tcreate materialized view sync_mv_rollup as select.*from sync_mv_base group by.* +-- !result +show create table sync_mv_rollup; +-- result: +[REGEX].*Table.*sync_mv_rollup.*is not found.* +-- !result +show create view sync_mv_rollup; +-- result: +[REGEX].*Table.*sync_mv_rollup.*is not found.* +-- !result +drop database test_show_create_sync_mv_${uuid0}; +-- result: +-- !result diff --git a/test/sql/test_materialized_view/T/test_show_create_sync_materialized_view b/test/sql/test_materialized_view/T/test_show_create_sync_materialized_view new file mode 100644 index 00000000000000..7ca896ba9a437d --- /dev/null +++ b/test/sql/test_materialized_view/T/test_show_create_sync_materialized_view @@ -0,0 +1,34 @@ +-- name: test_show_create_sync_materialized_view @native + +create database test_show_create_sync_mv_${uuid0}; +use test_show_create_sync_mv_${uuid0}; + +create table sync_mv_base +( + k1 date, + k2 int, + v1 int sum +) +distributed by hash(k2) buckets 3 +properties('replication_num' = '1'); + +-- Sync materialized view (legacy rollup style: no DISTRIBUTED BY, no REFRESH +-- clause). Stored as a MaterializedIndexMeta inside the base OLAP table, not +-- as a separately-registered Table. +create materialized view sync_mv_rollup as select k2, sum(v1) from sync_mv_base group by k2; +function: wait_materialized_view_finish() + +-- Regression: SHOW CREATE MATERIALIZED VIEW on a sync MV must locate the +-- MaterializedIndexMeta via the dedicated scan path inside +-- showCreateInternalCatalogTable. Without the fix this returned +-- "Table sync_mv_rollup is not found" because the regular name lookup misses +-- sync MV index names. +show create materialized view sync_mv_rollup; + +-- Negative cases: SHOW CREATE TABLE / VIEW on a sync MV name must still fail +-- with "Table not found" (the fallback scan is only entered for MV-typed +-- queries; see ShowExecutor.showCreateInternalCatalogTable). +show create table sync_mv_rollup; +show create view sync_mv_rollup; + +drop database test_show_create_sync_mv_${uuid0}; From 9db253ef14a884a942da36de6950f37b51dd40b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 May 2026 09:44:43 +0000 Subject: [PATCH 2/3] Resolve ShowExecutor backport conflict Agent-Logs-Url: https://github.com/StarRocks/starrocks/sessions/69524445-236d-4fa9-8751-e5687e623fb6 Co-authored-by: kevincai <771299+kevincai@users.noreply.github.com> --- .../java/com/starrocks/qe/ShowExecutor.java | 68 ++----------------- .../catalog/MaterializedViewTest.java | 2 +- 2 files changed, 7 insertions(+), 63 deletions(-) diff --git a/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java b/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java index 2fdc3b717976fd..07af5e10962cc5 100644 --- a/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java +++ b/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java @@ -743,53 +743,7 @@ private ShowResultSet showCreateInternalCatalogTable(ShowCreateTableStmt showStm Database db = GlobalStateMgr.getCurrentState().getLocalMetastore().getDb(showStmt.getDb()); MetaUtils.checkDbNullAndReport(db, showStmt.getDb()); List> rows = Lists.newArrayList(); -<<<<<<< HEAD TableName tableName = showStmt.getTbl(); - Table table = MetaUtils.getSessionAwareTable(connectContext, db, tableName); - if (table == null) { - if (showStmt.getType() != ShowCreateTableStmt.CreateTableType.MATERIALIZED_VIEW) { - ErrorReport.reportSemanticException(ErrorCode.ERR_BAD_TABLE_ERROR, showStmt.getTable()); - } else { - Locker dbLocker = new Locker(); - dbLocker.lockDatabase(db.getId(), LockType.READ); - try { - // For Sync Materialized View, it is a mv index inside OLAP table, - // so we can not get it from database. - for (Table tbl : GlobalStateMgr.getCurrentState().getLocalMetastore().getTables(db.getId())) { - if (tbl.getType() == Table.TableType.OLAP) { - OlapTable olapTable = (OlapTable) tbl; - List visibleMaterializedViews = - olapTable.getVisibleIndexMetas(); - for (MaterializedIndexMeta mvMeta : visibleMaterializedViews) { - if (olapTable.getIndexNameById(mvMeta.getIndexId()).equals(showStmt.getTable())) { - if (mvMeta.getOriginStmt() == null) { - String mvName = olapTable.getIndexNameById(mvMeta.getIndexId()); - rows.add(Lists.newArrayList(showStmt.getTable(), - ShowMaterializedViewStatus.buildCreateMVSql(olapTable, - mvName, mvMeta), "utf8", "utf8_general_ci")); - } else { - rows.add(Lists.newArrayList(showStmt.getTable(), mvMeta.getOriginStmt(), - "utf8", "utf8_general_ci")); - } - - ShowResultSetMetaData showResultSetMetaData = ShowResultSetMetaData.builder() - .addColumn(new Column("Materialized View", ScalarType.createVarchar(20))) - .addColumn(new Column("Create Materialized View", - ScalarType.createVarchar(30))) - .build(); - return new ShowResultSet(showResultSetMetaData, rows); - } - } - } - } - } finally { - dbLocker.unLockDatabase(db.getId(), LockType.READ); - } - ErrorReport.reportSemanticException(ErrorCode.ERR_BAD_TABLE_ERROR, showStmt.getTable()); -======= - TableName tableName = new TableName(showStmt.getCatalogName(), showStmt.getDb(), showStmt.getTable()); - // Lookup is ConcurrentHashMap-backed (Database.nameToTable) for internal catalog and - // throws SemanticException if the name does not match a registered Table. Table table; try { table = MetaUtils.getSessionAwareTable(connectContext, db, tableName); @@ -799,7 +753,6 @@ private ShowResultSet showCreateInternalCatalogTable(ShowCreateTableStmt showStm // for any other type, the miss is a real "table not found". if (showStmt.getType() != ShowCreateTableStmt.CreateTableType.MATERIALIZED_VIEW) { throw e; ->>>>>>> 4e35d9dc26 ([BugFix] Restore SHOW CREATE MATERIALIZED VIEW for sync MVs (#73396)) } return findSyncMaterializedViewCreateStmt(connectContext, db, showStmt); } @@ -845,16 +798,7 @@ private ShowResultSet showCreateInternalCatalogTable(ShowCreateTableStmt showStm .build(); return new ShowResultSet(showViewResultSetMeta, rows); } else { -<<<<<<< HEAD - rows.add(Lists.newArrayList(table.getName(), createTableStmt.get(0))); - ShowResultSetMetaData showResultSetMetaData = ShowResultSetMetaData.builder() - .addColumn(new Column("Materialized View", ScalarType.createVarchar(20))) - .addColumn(new Column("Create Materialized View", ScalarType.createVarchar(30))) - .build(); - return new ShowResultSet(showResultSetMetaData, rows); -======= return buildShowCreateMaterializedViewResult(table.getName(), createTableStmt.get(0)); ->>>>>>> 4e35d9dc26 ([BugFix] Restore SHOW CREATE MATERIALIZED VIEW for sync MVs (#73396)) } } else { if (showStmt.getType() != ShowCreateTableStmt.CreateTableType.TABLE) { @@ -874,8 +818,8 @@ private static ShowResultSet buildShowCreateMaterializedViewResult(String mvName List> rows = Lists.newArrayList(); rows.add(Lists.newArrayList(mvName, createSql)); ShowResultSetMetaData meta = ShowResultSetMetaData.builder() - .addColumn(new Column("Materialized View", TypeFactory.createVarcharType(20))) - .addColumn(new Column("Create Materialized View", TypeFactory.createVarcharType(30))) + .addColumn(new Column("Materialized View", ScalarType.createVarchar(20))) + .addColumn(new Column("Create Materialized View", ScalarType.createVarchar(30))) .build(); return new ShowResultSet(meta, rows); } @@ -902,20 +846,20 @@ private ShowResultSet findSyncMaterializedViewCreateStmt(ConnectContext connectC OlapTable olapTable = (OlapTable) tbl; locker.lockTableWithIntensiveDbLock(db.getId(), olapTable.getId(), LockType.READ); try { - Long metaId = olapTable.getIndexMetaIdByName(showStmt.getTable()); + Long metaId = olapTable.getIndexIdByName(showStmt.getTable()); // Skip the base index (its name equals the table's current name) - only // reachable here if a concurrent RENAME slipped between the failed name // lookup that routed us into this fallback and the snapshot below. - if (metaId == null || metaId == olapTable.getBaseIndexMetaId()) { + if (metaId == null || metaId == olapTable.getBaseIndexId()) { continue; } // Skip shadow / mid-schema-change indexes. boolean visible = olapTable.getVisibleIndexMetas().stream() - .anyMatch(m -> m.getIndexMetaId() == metaId); + .anyMatch(m -> m.getIndexId() == metaId); if (!visible) { continue; } - MaterializedIndexMeta mvMeta = olapTable.getIndexMetaByMetaId(metaId); + MaterializedIndexMeta mvMeta = olapTable.getIndexMetaByIndexId(metaId); if (mvMeta == null) { continue; } diff --git a/fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java b/fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java index 92070f47e876b0..6d6524e504d559 100644 --- a/fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java @@ -694,7 +694,7 @@ public void testShowCreateSyncMVAccessDenied() throws Exception { new mockit.MockUp() { @mockit.Mock public void checkAnyActionOnTable(ConnectContext context, - com.starrocks.catalog.TableName tableName) + com.starrocks.analysis.TableName tableName) throws com.starrocks.authorization.AccessDeniedException { throw new com.starrocks.authorization.AccessDeniedException(); } From 2a720f089f28237bcbd2641104e1b1267753c2d3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 May 2026 09:48:54 +0000 Subject: [PATCH 3/3] Rename sync MV index lookup variable Agent-Logs-Url: https://github.com/StarRocks/starrocks/sessions/69524445-236d-4fa9-8751-e5687e623fb6 Co-authored-by: kevincai <771299+kevincai@users.noreply.github.com> --- .../src/main/java/com/starrocks/qe/ShowExecutor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java b/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java index 07af5e10962cc5..bf4b0198b76874 100644 --- a/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java +++ b/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java @@ -846,20 +846,20 @@ private ShowResultSet findSyncMaterializedViewCreateStmt(ConnectContext connectC OlapTable olapTable = (OlapTable) tbl; locker.lockTableWithIntensiveDbLock(db.getId(), olapTable.getId(), LockType.READ); try { - Long metaId = olapTable.getIndexIdByName(showStmt.getTable()); + Long indexId = olapTable.getIndexIdByName(showStmt.getTable()); // Skip the base index (its name equals the table's current name) - only // reachable here if a concurrent RENAME slipped between the failed name // lookup that routed us into this fallback and the snapshot below. - if (metaId == null || metaId == olapTable.getBaseIndexId()) { + if (indexId == null || indexId == olapTable.getBaseIndexId()) { continue; } // Skip shadow / mid-schema-change indexes. boolean visible = olapTable.getVisibleIndexMetas().stream() - .anyMatch(m -> m.getIndexId() == metaId); + .anyMatch(m -> m.getIndexId() == indexId); if (!visible) { continue; } - MaterializedIndexMeta mvMeta = olapTable.getIndexMetaByIndexId(metaId); + MaterializedIndexMeta mvMeta = olapTable.getIndexMetaByIndexId(indexId); if (mvMeta == null) { continue; }