Skip to content

Commit

Permalink
[apache#3403] bug(hive-catalog): add hive catalog property list-all-t…
Browse files Browse the repository at this point in the history
…abless (apache#3403)
  • Loading branch information
mygrsun2 committed Jun 1, 2024
1 parent e909181 commit f7ea0d3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ long getCacheEvictionInterval(Map<String, String> conf) {
.catalogPropertiesMetadata()
.getOrDefault(conf, CLIENT_POOL_CACHE_EVICTION_INTERVAL_MS);
}

boolean getListAllTables(Map<String, String> conf) {
return (boolean)
propertiesMetadata
.catalogPropertiesMetadata().getOrDefault(conf, LIST_ALL_TABLES);
propertiesMetadata.catalogPropertiesMetadata().getOrDefault(conf, LIST_ALL_TABLES);
}
/** Closes the Hive catalog and releases the associated client pool. */
@Override
Expand Down Expand Up @@ -531,22 +531,26 @@ public NameIdentifier[] listTables(Namespace namespace) throws NoSuchSchemaExcep
return clientPool.run(
c ->
c.getTableObjectsByName(schemaIdent.name(), allTables).stream()
.filter(tb -> {
boolean isSupportTable = SUPPORT_TABLE_TYPES.contains(tb.getTableType());
if (!isSupportTable) {
return false;
}
if (!listAllTables) {
Map<String, String> parameters = tb.getParameters();
if (parameters != null) {
boolean isIcebergTable = ICEBERG_TABLE_TYPE_VALUE.equalsIgnoreCase(parameters.get(TABLE_TYPE_PROP));
if (isIcebergTable) {
.filter(
tb -> {
boolean isSupportTable = SUPPORT_TABLE_TYPES.contains(tb.getTableType());
if (!isSupportTable) {
return false;
}
}
}
return true;
}).map(tb -> NameIdentifier.of(namespace, tb.getTableName()))
if (!listAllTables) {
Map<String, String> parameters = tb.getParameters();
if (parameters != null) {
boolean isIcebergTable =
ICEBERG_TABLE_TYPE_VALUE.equalsIgnoreCase(
parameters.get(TABLE_TYPE_PROP));
if (isIcebergTable) {
return false;
}
}
}
return true;
})
.map(tb -> NameIdentifier.of(namespace, tb.getTableName()))
.toArray(NameIdentifier[]::new));
} catch (UnknownDBException e) {
throw new NoSuchSchemaException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ public class HiveCatalogPropertiesMeta extends BaseCatalogPropertiesMetadata {
FETCH_TIMEOUT_SEC,
PropertyEntry.integerOptionalPropertyEntry(
FETCH_TIMEOUT_SEC, "The timeout to fetch key tab", true, 60, false))
.put(
LIST_ALL_TABLES,
PropertyEntry.booleanPropertyEntry(
LIST_ALL_TABLES,
"list all tables (including the iceberg tables)",
false,
false,
DEFAULT_LIST_ALL_TABLES,
false,
false))
.put(
LIST_ALL_TABLES,
PropertyEntry.booleanPropertyEntry(
LIST_ALL_TABLES,
"list all tables (including the iceberg tables)",
false,
false,
DEFAULT_LIST_ALL_TABLES,
false,
false))
.putAll(BASIC_CATALOG_PROPERTY_ENTRIES)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ void testPropertyMeta() {
Assertions.assertTrue(propertyEntryMap.containsKey(IMPERSONATION_ENABLE));
Assertions.assertTrue(propertyEntryMap.containsKey(LIST_ALL_TABLES));


Assertions.assertTrue(propertyEntryMap.get(METASTORE_URIS).isRequired());
Assertions.assertFalse(propertyEntryMap.get(Catalog.PROPERTY_PACKAGE).isRequired());
Assertions.assertFalse(propertyEntryMap.get(CLIENT_POOL_SIZE).isRequired());
Expand Down

0 comments on commit f7ea0d3

Please sign in to comment.