github-actions[bot] commented on code in PR #63352:
URL: https://github.com/apache/doris/pull/63352#discussion_r3257704525


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java:
##########
@@ -202,6 +202,13 @@ public void validate(ConnectContext ctx) throws Exception {
         mvKeysType = planValidator.context.keysType;
         dbName = planValidator.context.dbName;
         baseIndexName = planValidator.context.baseIndexName;
+        // The MV's effective database (explicitly specified or current 
session db) must match the base table's db,
+        // because a sync materialized view is stored as an index on the base 
table.
+        String mvDb = name.getDb();
+        if (mvDb == null || mvDb.isEmpty()) {

Review Comment:
   This still ignores the MV catalog. `TableNameInfo` can contain three parts, 
and downstream `Alter.processCreateMaterializedView()` uses 
`command.getDBName()` from the base table while `getMVName()` returns only 
`name.getTbl()`. So a statement such as `CREATE MATERIALIZED VIEW 
other_ctl.same_db.mv AS SELECT ... FROM internal.same_db.t` (or using `USE 
other_ctl.same_db` and an unqualified MV name) has `mvDb == baseTableDb` and 
passes this check, but the catalog qualifier is silently ignored and the MV is 
created as an index on the internal base table. Since the invariant is that the 
sync MV belongs to the same base table namespace, please also validate the 
effective MV catalog (explicit `name.getCtl()` or current catalog) is the 
internal/base-table catalog, and add a regression case for a 
same-db/different-catalog name.



-- 
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]

Reply via email to