morrySnow commented on code in PR #61918: URL: https://github.com/apache/doris/pull/61918#discussion_r3031288440
########## fe/fe-core/src/main/java/org/apache/doris/info/TableNameInfoUtils.java: ########## @@ -0,0 +1,69 @@ +// 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. + +package org.apache.doris.info; + +import org.apache.doris.catalog.Database; +import org.apache.doris.catalog.DatabaseIf; +import org.apache.doris.catalog.NameSpaceContext; +import org.apache.doris.catalog.TableIf; +import org.apache.doris.datasource.CatalogIf; + +/** + * Utility methods for creating {@link TableNameInfo} from catalog objects. + * Kept separate from {@code TableNameInfo} to avoid coupling that class to + * {@code Database}/{@code TableIf}/{@code CatalogIf}. + */ +public class TableNameInfoUtils { Review Comment: Fixed — added TableNameInfoUtilsTest.java with 7 test cases covering all methods. ########## fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVService.java: ########## @@ -214,12 +218,29 @@ public void processEvent(Event event) throws EventException { private boolean shouldRefreshOnBaseTableDataChange(MTMV mtmv, TableIf table) { TableNameInfo tableName = null; try { - tableName = new TableNameInfo(table); - } catch (org.apache.doris.nereids.exceptions.AnalysisException e) { + if (table != null && !table.getName().isEmpty()) { + DatabaseIf<?> db = table.getDatabase(); + if (db != null) { + CatalogIf<?> catalog = db.getCatalog(); + if (catalog != null) { + String tblName = table.getName(); + if (GlobalVariable.isStoredTableNamesLowerCase()) { + tblName = tblName.toLowerCase(); + } Review Comment: Fixed — removed redundant lowercasing, now passes table.getName() directly. ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ForeignKeyContext.java: ########## @@ -102,10 +105,19 @@ public Void visitLogicalFilter(LogicalFilter<?> filter, ForeignKeyContext contex } void putAllForeignKeys(TableIf table) { - TableNameInfo tableNameInfo = TableNameInfo.createOrNull(table); - if (tableNameInfo == null) { + if (table == null || table.getName() == null || table.getName().isEmpty()) { return; } + DatabaseIf<?> db = table.getDatabase(); + if (db == null) { + return; + } + CatalogIf<?> catalog = db.getCatalog(); + if (catalog == null) { + return; + } + String tableName = table.getName(); Review Comment: Fixed — added fromCatalogDb(CatalogIf, DatabaseIf, TableIf) overload. Callers pass table object directly. ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ForeignKeyContext.java: ########## @@ -115,10 +127,19 @@ void putAllForeignKeys(TableIf table) { } void putAllPrimaryKeys(TableIf table) { - TableNameInfo tableNameInfo = TableNameInfo.createOrNull(table); - if (tableNameInfo == null) { + if (table == null || table.getName() == null || table.getName().isEmpty()) { + return; + } + DatabaseIf<?> db = table.getDatabase(); + if (db == null) { + return; + } + CatalogIf<?> catalog = db.getCatalog(); + if (catalog == null) { return; } + String tableName = table.getName(); Review Comment: Fixed — same change applied to both methods. ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AddConstraintCommand.java: ########## @@ -68,13 +70,25 @@ public AddConstraintCommand(String name, Constraint constraint) { public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { Pair<ImmutableList<String>, TableIf> columnsAndTable = extractColumnsAndTable(ctx, constraint.toProject()); TableIf table = columnsAndTable.second; - TableNameInfo tableNameInfo = new TableNameInfo(table); + String tableNameStr = table.getName(); + if (GlobalVariable.isStoredTableNamesLowerCase()) { + tableNameStr = tableNameStr.toLowerCase(); + } Review Comment: Fixed — both sites use fromCatalogDb(catalog, db, table). Removed redundant lowercasing. ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AddConstraintCommand.java: ########## @@ -68,13 +70,25 @@ public AddConstraintCommand(String name, Constraint constraint) { public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { Pair<ImmutableList<String>, TableIf> columnsAndTable = extractColumnsAndTable(ctx, constraint.toProject()); TableIf table = columnsAndTable.second; - TableNameInfo tableNameInfo = new TableNameInfo(table); + String tableNameStr = table.getName(); + if (GlobalVariable.isStoredTableNamesLowerCase()) { + tableNameStr = tableNameStr.toLowerCase(); + } + TableNameInfo tableNameInfo = TableNameInfoUtils.fromCatalogDb( + table.getDatabase().getCatalog(), table.getDatabase(), tableNameStr); ImmutableList<String> columns = columnsAndTable.first; if (constraint.isForeignKey()) { Pair<ImmutableList<String>, TableIf> refColumnsAndTable = extractColumnsAndTable(ctx, constraint.toReferenceProject()); - TableNameInfo refTableInfo = new TableNameInfo(refColumnsAndTable.second); + TableIf refTable = refColumnsAndTable.second; + String refTableNameStr = refTable.getName(); + if (GlobalVariable.isStoredTableNamesLowerCase()) { + refTableNameStr = refTableNameStr.toLowerCase(); + } Review Comment: Fixed — same as above. ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropConstraintCommand.java: ########## @@ -62,7 +64,12 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { TableNameInfo tableNameInfo; try { TableIf table = extractTable(ctx, plan); - tableNameInfo = new TableNameInfo(table); + String tblName = table.getName(); + if (GlobalVariable.isStoredTableNamesLowerCase()) { + tblName = tblName.toLowerCase(); + } Review Comment: Fixed — simplified to fromCatalogDb(catalog, db, table). ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCatalogRelation.java: ########## @@ -196,10 +198,22 @@ public String getTableAlias() { @Override public void computeUnique(DataTrait.Builder builder) { Set<Slot> outputSet = Utils.fastToImmutableSet(getOutputSet()); - TableNameInfo tableNameInfo = TableNameInfo.createOrNull(table); - if (tableNameInfo == null) { + if (table == null || table.getName() == null || table.getName().isEmpty()) { return; } + DatabaseIf<?> db = table.getDatabase(); + if (db == null) { + return; + } + CatalogIf<?> catalog = db.getCatalog(); + if (catalog == null) { + return; + } + String tableName = table.getName(); + if (GlobalVariable.isStoredTableNamesLowerCase()) { + tableName = tableName.toLowerCase(); + } Review Comment: Fixed — simplified to fromCatalogDb(catalog, db, table). ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalCatalogRelation.java: ########## @@ -211,10 +213,22 @@ public String shapeInfo() { @Override public void computeUnique(DataTrait.Builder builder) { Set<Slot> outputSet = Utils.fastToImmutableSet(getOutputSet()); - TableNameInfo tableNameInfo = TableNameInfo.createOrNull(table); - if (tableNameInfo == null) { + if (table == null || table.getName() == null || table.getName().isEmpty()) { return; } + DatabaseIf<?> db = table.getDatabase(); + if (db == null) { + return; + } + CatalogIf<?> catalog = db.getCatalog(); + if (catalog == null) { + return; + } + String tableName = table.getName(); + if (GlobalVariable.isStoredTableNamesLowerCase()) { + tableName = tableName.toLowerCase(); + } Review Comment: Fixed — simplified to fromCatalogDb(catalog, db, table). -- 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]
