Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxiaojian committed May 17, 2024
1 parent ecbc3bc commit 719fb96
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public abstract class AbstractCatalog implements Catalog {
protected final FileIO fileIO;
protected final Map<String, String> tableDefaultOptions;
protected final Options catalogOptions;
protected final String branchName;

@Nullable protected final LineageMetaFactory lineageMetaFactory;

Expand All @@ -76,7 +75,6 @@ protected AbstractCatalog(FileIO fileIO) {
this.lineageMetaFactory = null;
this.tableDefaultOptions = new HashMap<>();
this.catalogOptions = new Options();
branchName = BranchManager.DEFAULT_MAIN_BRANCH;
}

protected AbstractCatalog(FileIO fileIO, Options options) {
Expand All @@ -86,7 +84,6 @@ protected AbstractCatalog(FileIO fileIO, Options options) {
this.tableDefaultOptions =
convertToPropertiesPrefixKey(options.toMap(), TABLE_DEFAULT_OPTION_PREFIX);
this.catalogOptions = options;
this.branchName = options.get(CoreOptions.BRANCH);
}

@Override
Expand Down Expand Up @@ -340,12 +337,6 @@ public Table getTable(Identifier identifier) throws TableNotExistException {
return table;
} else {
Table table = getDataTable(identifier);
// Override branch option
if (!branchName.equals(BranchManager.DEFAULT_MAIN_BRANCH)) {
Map<String, String> dynamicOptions = new HashMap<>(table.options());
dynamicOptions.put(CoreOptions.BRANCH.key(), branchName);
table = table.copy(dynamicOptions);
}
return table;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public boolean tableExists(Identifier identifier) {
}

private boolean tableExists(Path tablePath) {
return new SchemaManager(fileIO, tablePath, branchName).listAllIds().size() > 0;
return new SchemaManager(fileIO, tablePath).listAllIds().size() > 0;
}

@Override
Expand Down Expand Up @@ -153,7 +153,7 @@ private SchemaManager schemaManager(Identifier identifier) {
new RuntimeException(
"No lock context when lock is enabled."))))
.orElse(null);
return new SchemaManager(fileIO, path, branchName)
return new SchemaManager(fileIO, path)
.withLock(catalogLock == null ? null : Lock.fromCatalog(catalogLock, identifier));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ protected void renameTableImpl(Identifier fromTable, Identifier toTable) {
updateTable(connections, catalogKey, fromTable, toTable);

Path fromPath = getDataTableLocation(fromTable);
if (new SchemaManager(fileIO, fromPath, branchName).listAllIds().size() > 0) {
if (new SchemaManager(fileIO, fromPath).listAllIds().size() > 0) {
// Rename the file system's table directory. Maintain consistency between tables in
// the file system and tables in the Hive Metastore.
Path toPath = getDataTableLocation(toTable);
Expand Down Expand Up @@ -323,7 +323,7 @@ protected TableSchema getDataTableSchema(Identifier identifier) throws TableNotE
throw new TableNotExistException(identifier);
}
Path tableLocation = getDataTableLocation(identifier);
return new SchemaManager(fileIO, tableLocation, branchName)
return new SchemaManager(fileIO, tableLocation)
.latest()
.orElseThrow(
() -> new RuntimeException("There is no paimon table in " + tableLocation));
Expand Down Expand Up @@ -374,7 +374,7 @@ public void close() throws Exception {
}

private SchemaManager getSchemaManager(Identifier identifier) {
return new SchemaManager(fileIO, getDataTableLocation(identifier), branchName)
return new SchemaManager(fileIO, getDataTableLocation(identifier))
.withLock(lock(identifier));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public TableSchema getDataTableSchema(Identifier identifier) throws TableNotExis
throw new TableNotExistException(identifier);
}
Path tableLocation = getDataTableLocation(identifier);
return new SchemaManager(fileIO, tableLocation, branchName)
return new SchemaManager(fileIO, tableLocation)
.latest()
.orElseThrow(
() -> new RuntimeException("There is no paimon table in " + tableLocation));
Expand Down Expand Up @@ -422,7 +422,7 @@ protected void renameTableImpl(Identifier fromTable, Identifier toTable) {
client.alter_table(fromDB, fromTableName, table);

Path fromPath = getDataTableLocation(fromTable);
if (new SchemaManager(fileIO, fromPath, branchName).listAllIds().size() > 0) {
if (new SchemaManager(fileIO, fromPath).listAllIds().size() > 0) {
// Rename the file system's table directory. Maintain consistency between tables in
// the file system and tables in the Hive Metastore.
Path toPath = getDataTableLocation(toTable);
Expand Down Expand Up @@ -588,7 +588,7 @@ private FieldSchema convertToFieldSchema(DataField dataField) {
}

private SchemaManager schemaManager(Identifier identifier) {
return new SchemaManager(fileIO, getDataTableLocation(identifier), branchName)
return new SchemaManager(fileIO, getDataTableLocation(identifier))
.withLock(lock(identifier));
}

Expand Down

0 comments on commit 719fb96

Please sign in to comment.