Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hubgeter committed Jan 3, 2025
1 parent d877397 commit 4e508e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ public ExternalDatabase<? extends ExternalTable> getDbNullable(String dbName) {
if (useMetaCache.get()) {
// must use full qualified name to generate id.
// otherwise, if 2 catalogs have the same db name, the id will be the same.
return metaCache.getMetaObj(realDbName, Util.genIdByName(getQualifiedName(realDbName))).orElse(null);
return metaCache.getMetaObj(realDbName, Util.genIdByName(name, realDbName)).orElse(null);
} else {
if (dbNameToId.containsKey(realDbName)) {
return idToDb.get(dbNameToId.get(realDbName));
Expand Down Expand Up @@ -1081,10 +1081,6 @@ public void truncateTable(TruncateTableStmt stmt) throws DdlException {
}
}

public String getQualifiedName(String dbName) {
return String.join(".", name, dbName);
}

public void setAutoAnalyzePolicy(String dbName, String tableName, String policy) {
Pair<String, String> key = Pair.of(dbName, tableName);
if (policy == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ public T getTableNullable(String tableName) {
if (extCatalog.getUseMetaCache().get()) {
// must use full qualified name to generate id.
// otherwise, if 2 databases have the same table name, the id will be the same.
return metaCache.getMetaObj(tableName, Util.genIdByName(getQualifiedName(tableName))).orElse(null);
return metaCache.getMetaObj(tableName,
Util.genIdByName(extCatalog.getName(), name, tableName)).orElse(null);
} else {
if (!tableNameToId.containsKey(tableName)) {
return null;
Expand Down Expand Up @@ -655,7 +656,7 @@ public void unregisterTable(String tableName) {

if (extCatalog.getUseMetaCache().get()) {
if (isInitialized()) {
metaCache.invalidate(tableName, Util.genIdByName(getQualifiedName(tableName)));
metaCache.invalidate(tableName, Util.genIdByName(extCatalog.getName(), name, tableName));
lowerCaseToTableName.remove(tableName.toLowerCase());
}
} else {
Expand Down Expand Up @@ -688,8 +689,9 @@ public boolean registerTable(TableIf tableIf) {
}
if (extCatalog.getUseMetaCache().get()) {
if (isInitialized()) {
metaCache.updateCache(tableName, extCatalog.fromRemoteTableName(this.remoteName, tableName),
(T) tableIf, Util.genIdByName(getQualifiedName(tableName)));
String localName = extCatalog.fromRemoteTableName(this.remoteName, tableName);
metaCache.updateCache(tableName, localName, (T) tableIf,
Util.genIdByName(extCatalog.getName(), name, localName));
lowerCaseToTableName.put(tableName.toLowerCase(), tableName);
}
} else {
Expand All @@ -705,10 +707,6 @@ public boolean registerTable(TableIf tableIf) {
return true;
}

public String getQualifiedName(String tblName) {
return String.join(".", extCatalog.getName(), name, tblName);
}

private boolean isStoredTableNamesLowerCase() {
// Because we have added a test configuration item,
// it needs to be judged together with Env.isStoredTableNamesLowerCase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void unregisterDatabase(String dbName) {
}
if (useMetaCache.get()) {
if (isInitialized()) {
metaCache.invalidate(dbName, Util.genIdByName(getQualifiedName(dbName)));
metaCache.invalidate(dbName, Util.genIdByName(name, dbName));
}
} else {
Long dbId = dbNameToId.remove(dbName);
Expand All @@ -266,7 +266,7 @@ public void registerDatabase(long dbId, String dbName) {
if (useMetaCache.get()) {
if (isInitialized()) {
metaCache.updateCache(db.getRemoteName(), db.getFullName(), db,
Util.genIdByName(getQualifiedName(dbName)));
Util.genIdByName(name, db.getFullName()));
}
} else {
dbNameToId.put(dbName, dbId);
Expand Down

0 comments on commit 4e508e1

Please sign in to comment.