Skip to content

Commit

Permalink
[hotfix] Fix 'list tables' to view all tables in the sys database. ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuangchong authored Nov 6, 2023
1 parent 4a656d9 commit 1972d33
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.table.FileStoreTableFactory;
import org.apache.paimon.table.Table;
import org.apache.paimon.table.system.AllTableOptionsTable;
import org.apache.paimon.table.system.CatalogOptionsTable;
import org.apache.paimon.table.system.SystemTableLoader;
import org.apache.paimon.utils.StringUtils;

import javax.annotation.Nullable;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -51,9 +48,6 @@ public abstract class AbstractCatalog implements Catalog {

public static final String DB_SUFFIX = ".db";
protected static final String TABLE_DEFAULT_OPTION_PREFIX = "table-default.";
protected static final List<String> GLOBAL_TABLES =
Arrays.asList(
AllTableOptionsTable.ALL_TABLE_OPTIONS, CatalogOptionsTable.CATALOG_OPTIONS);

protected final FileIO fileIO;
protected final Map<String, String> tableDefaultOptions;
Expand Down Expand Up @@ -139,7 +133,7 @@ public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade
@Override
public List<String> listTables(String databaseName) throws DatabaseNotExistException {
if (isSystemDatabase(databaseName)) {
return GLOBAL_TABLES;
return SystemTableLoader.loadGlobalTableNames();
}
if (!databaseExists(databaseName)) {
throw new DatabaseNotExistException(databaseName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import javax.annotation.Nullable;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

Expand Down Expand Up @@ -109,4 +111,9 @@ public static Table loadGlobal(
return null;
}
}

public static List<String> loadGlobalTableNames() {
return Arrays.asList(
ALL_TABLE_OPTIONS, CATALOG_OPTIONS, SOURCE_TABLE_LINEAGE, SINK_TABLE_LINEAGE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.apache.paimon.schema.SchemaManager;
import org.apache.paimon.table.system.AllTableOptionsTable;
import org.apache.paimon.table.system.CatalogOptionsTable;
import org.apache.paimon.table.system.SinkTableLineageTable;
import org.apache.paimon.table.system.SourceTableLineageTable;
import org.apache.paimon.testutils.assertj.AssertionUtils;
import org.apache.paimon.types.IntType;
import org.apache.paimon.utils.BlockingIterator;
Expand Down Expand Up @@ -134,9 +136,11 @@ public void testChangeTableInSystemDatabase() {
public void testSystemDatabase() {
sql("USE " + Catalog.SYSTEM_DATABASE_NAME);
assertThat(sql("SHOW TABLES"))
.containsExactly(
.containsExactlyInAnyOrder(
Row.of(AllTableOptionsTable.ALL_TABLE_OPTIONS),
Row.of(CatalogOptionsTable.CATALOG_OPTIONS));
Row.of(CatalogOptionsTable.CATALOG_OPTIONS),
Row.of(SourceTableLineageTable.SOURCE_TABLE_LINEAGE),
Row.of(SinkTableLineageTable.SINK_TABLE_LINEAGE));
}

@Test
Expand Down

0 comments on commit 1972d33

Please sign in to comment.