{"record":{"id":"31d9dcb209b8ec72","repo":"apache/beam","slug":"listing-dbs-is-not-supported-in-metastore","errorCode":null,"errorMessage":"Listing DBs is not supported in metastore","messagePattern":"Listing DBs is not supported in metastore","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/hcatalog/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/hcatalog/HCatalogTableProvider.java","lineNumber":101,"sourceCode":"  @Override\n  public Table getTable(String name) {\n    // Tables should have been looked up from sub-providers.\n    // If we reached this then getSubProvider(name) returned null\n    // meaning there's no such DB. Try to look up the table in the default DB instead.\n    return defaultDBProvider.getTable(name);\n  }\n\n  @Override\n  public BeamSqlTable buildBeamSqlTable(Table table) {\n    // This is the same `default` DB use case similar to how `getTable()` behaves.\n    // This path should only be hit if none of the sub-providers for the DBs\n    // was able to find the table.\n    return defaultDBProvider.buildBeamSqlTable(table);\n  }\n\n  @Override\n  public Set<String> getSubProviders() {\n    throw new UnsupportedOperationException(\"Listing DBs is not supported in metastore\");\n  }\n\n  @Override\n  public TableProvider getSubProvider(String name) {\n    return metastoreSchema.hasDatabase(name)\n        ? new DatabaseProvider(name, metastoreSchema, configuration)\n        : null;\n  }\n}\n","sourceCodeStart":83,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/hcatalog/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/hcatalog/HCatalogTableProvider.java#L83-L111","documentation":"HCatalogTableProvider implements hierarchical sub-providers (one per metastore database), but the metastore-backed implementation cannot list which databases exist. getSubProviders() unconditionally throws UnsupportedOperationException.","triggerScenarios":"Calling getSubProviders() to enumerate the databases of an hcatalog catalog, e.g. wildcard database resolution in the table provider framework.","commonSituations":"Catalog-wide discovery tools; frameworks iterating all sub-providers to build a schema tree over hcatalog.","solutions":["Enumerate databases via the Hive metastore client (getAllDatabases) instead.","Address a specific database with getSubProvider(name), which works for existing DBs.","Refactor discovery logic to require an explicitly named database."],"exampleFix":"// before\nSet<String> dbs = provider.getSubProviders();\n// after\nTableProvider dbProvider = provider.getSubProvider(\"mydb\");\n// listing: IMetaStoreClient m = ...; m.getAllDatabases();","handlingStrategy":"validation","validationCode":"if (provider instanceof HCatalogTableProvider && enumeratingDbs) {\n  // use metastore client getAllDatabases() instead of getSubProviders()\n}","typeGuard":null,"tryCatchPattern":"try {\n  dbs = provider.getSubProviders();\n} catch (UnsupportedOperationException e) {\n  dbs = metastore.getAllDatabases(); // Hive metastore client\n}","preventionTips":["Always name the database explicitly; use getSubProvider(name).","Enumerate databases via Hive metastore clients.","Avoid wildcard database discovery for hcatalog-backed catalogs."],"tags":["java","beam-sql","hcatalog","metadata"],"backgroundTag":"operation-not-supported","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}