Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public Pair<Boolean, Boolean> createTableWithLock(
registerTable(table);
if (!isReplay) {
// Write edit log
CreateTableInfo info = new CreateTableInfo(fullQualifiedName, table);
CreateTableInfo info = new CreateTableInfo(fullQualifiedName, id, table);
Env.getCurrentEnv().getEditLog().logCreateTable(info);
}
if (table.getType() == TableType.ELASTICSEARCH) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4330,7 +4330,8 @@ public void replayCreateTable(CreateTableInfo info) throws MetaNotFoundException
if (Strings.isNullOrEmpty(info.getCtlName()) || info.getCtlName()
.equals(InternalCatalog.INTERNAL_CATALOG_NAME)) {
Table table = info.getTable();
getInternalCatalog().replayCreateTable(info.getDbName(), table);
long dbId = info.getDbId();
getInternalCatalog().replayCreateTable(info.getDbName(), dbId, table);
if (table instanceof MTMV) {
((MTMV) table).compatible(Env.getCurrentEnv().getCatalogMgr());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1487,8 +1487,18 @@ public void createTableAsSelect(CreateTableAsSelectStmt stmt) throws DdlExceptio
}
}

public void replayCreateTable(String dbName, Table table) throws MetaNotFoundException {
Database db = this.fullNameToDb.get(dbName);
public void replayCreateTable(String dbName, long dbId, Table table) throws MetaNotFoundException {
if (dbId != -1L) {
Database db = getDbOrMetaException(dbId);
replayCreateTableInternal(db, table);
} else {
// Compatible with old logic
Database db = getDbOrMetaException(dbName);
replayCreateTableInternal(db, table);
}
}

private void replayCreateTableInternal(Database db, Table table) throws MetaNotFoundException {
try {
db.createTableWithLock(table, true, false);
} catch (DdlException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class CreateTableInfo implements Writable, GsonPostProcessable {

@SerializedName(value = "ctl")
private String ctlName;
@SerializedName(value = "dbId")
private long dbId = -1L;
@SerializedName(value = "dbName")
private String dbName;
@SerializedName(value = "tbl")
Expand All @@ -54,8 +56,9 @@ public CreateTableInfo() {
}

// for internal table
public CreateTableInfo(String dbName, Table table) {
public CreateTableInfo(String dbName, long dbId, Table table) {
this.ctlName = InternalCatalog.INTERNAL_CATALOG_NAME;
this.dbId = dbId;
this.dbName = dbName;
this.tblName = table.getName();
this.table = table;
Expand All @@ -76,6 +79,10 @@ public String getDbName() {
return dbName;
}

public long getDbId() {
return dbId;
}

public String getTblName() {
return tblName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testSerialization() throws Exception {
TStorageType.COLUMN, KeysType.AGG_KEYS);
Deencapsulation.setField(table, "baseIndexId", 1000);
table.addPartition(partition);
CreateTableInfo info = new CreateTableInfo("db1", table);
CreateTableInfo info = new CreateTableInfo("db1", -1L, table);
info.write(dos);

dos.flush();
Expand Down