apache/beam · error · UnsupportedOperationException

Listing DBs is not supported in metastore

Error message

Listing DBs is not supported in metastore

What it means

HCatalogTableProvider implements hierarchical sub-providers (one per metastore database), but the metastore-backed implementation cannot list which databases exist. getSubProviders() unconditionally throws UnsupportedOperationException.

Solutions

  1. Enumerate databases via the Hive metastore client (getAllDatabases) instead.
  2. Address a specific database with getSubProvider(name), which works for existing DBs.
  3. Refactor discovery logic to require an explicitly named database.

Example fix

// before
Set<String> dbs = provider.getSubProviders();
// after
TableProvider dbProvider = provider.getSubProvider("mydb");
// listing: IMetaStoreClient m = ...; m.getAllDatabases();
Defensive patterns

Strategy: validation

Validate before calling

if (provider instanceof HCatalogTableProvider && enumeratingDbs) {
  // use metastore client getAllDatabases() instead of getSubProviders()
}

Try / catch

try {
  dbs = provider.getSubProviders();
} catch (UnsupportedOperationException e) {
  dbs = metastore.getAllDatabases(); // Hive metastore client
}

Prevention

When it happens

Trigger: Calling getSubProviders() to enumerate the databases of an hcatalog catalog, e.g. wildcard database resolution in the table provider framework.

Common situations: Catalog-wide discovery tools; frameworks iterating all sub-providers to build a schema tree over hcatalog.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/31d9dcb209b8ec72. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/sql/hcatalog/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/hcatalog/HCatalogTableProvider.java:101

  @Override
  public Table getTable(String name) {
    // Tables should have been looked up from sub-providers.
    // If we reached this then getSubProvider(name) returned null
    // meaning there's no such DB. Try to look up the table in the default DB instead.
    return defaultDBProvider.getTable(name);
  }

  @Override
  public BeamSqlTable buildBeamSqlTable(Table table) {
    // This is the same `default` DB use case similar to how `getTable()` behaves.
    // This path should only be hit if none of the sub-providers for the DBs
    // was able to find the table.
    return defaultDBProvider.buildBeamSqlTable(table);
  }

  @Override
  public Set<String> getSubProviders() {
    throw new UnsupportedOperationException("Listing DBs is not supported in metastore");
  }

  @Override
  public TableProvider getSubProvider(String name) {
    return metastoreSchema.hasDatabase(name)
        ? new DatabaseProvider(name, metastoreSchema, configuration)
        : null;
  }
}

View on GitHub (pinned to 12126d8942)