morningman commented on code in PR #29767: URL: https://github.com/apache/doris/pull/29767#discussion_r1452915797
########## fe/fe-core/src/main/java/org/apache/doris/catalog/constraint/TableIdentifier.java: ########## @@ -20,30 +20,41 @@ import org.apache.doris.catalog.DatabaseIf; import org.apache.doris.catalog.Env; import org.apache.doris.catalog.TableIf; +import org.apache.doris.datasource.CatalogIf; import com.google.common.base.Preconditions; +import com.google.gson.annotations.SerializedName; import java.util.Objects; -class TableIdentifier { +public class TableIdentifier { + @SerializedName(value = "dbId") private final long databaseId; + @SerializedName(value = "tId") private final long tableId; + @SerializedName(value = "cId") + private final long catalogId; - TableIdentifier(TableIf tableIf) { + public TableIdentifier(TableIf tableIf) { Preconditions.checkArgument(tableIf != null, "Table can not be null in constraint"); - databaseId = tableIf.getDatabase().getId(); tableId = tableIf.getId(); + databaseId = tableIf.getDatabase().getId(); + catalogId = tableIf.getDatabase().getCatalog().getId(); } - TableIf toTableIf() { - DatabaseIf databaseIf = Env.getCurrentEnv().getCurrentCatalog().getDbNullable(databaseId); + public TableIf toTableIf() { + CatalogIf<?> catalogIf = Env.getCurrentEnv().getCatalogMgr().getCatalog(catalogId); + if (catalogIf == null) { + throw new NullPointerException(String.format("Can not find catalog %s in constraint", catalogId)); + } + DatabaseIf<?> databaseIf = catalogIf.getDbNullable(databaseId); if (databaseIf == null) { - throw new RuntimeException(String.format("Can not find database %s in constraint", databaseId)); + throw new NullPointerException(String.format("Can not find database %s in constraint", databaseId)); Review Comment: How about create a new exception? eg, MetaNotFoundException? ########## fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java: ########## @@ -973,6 +973,20 @@ public static void loadJournal(Env env, Long logId, JournalEntity journal) { case OperationType.OP_ALTER_MTMV_STMT: { break; } + case OperationType.OP_ADD_CONSTRAINT: { + final AlterConstraintLog log = (AlterConstraintLog) journal.getData(); + if (log != null) { + log.getTableIf().replayAddConstraint(log.getConstraint()); + } + break; + } + case OperationType.OP_DROP_CONSTRAINT: { + final AlterConstraintLog log = (AlterConstraintLog) journal.getData(); + if (log != null) { Review Comment: Why it can be null? -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org