apache/beam · error · IllegalStateException

Duplicate table: from provider

Error message

Duplicate table: ${tableName} from provider: ${provider}

What it means

initTablesFromProvider imports all tables exposed by a newly registered provider into the metastore and throws IllegalStateException if any of those table names already exist in the metastore. This prevents a provider registration from silently shadowing existing tables.

Solutions

  1. Rename the colliding table in one of the providers.
  2. Drop the existing table before registering the new provider.
  3. Register all providers on a fresh metastore before creating any tables manually.

Example fix

// before
metaStore.createTable(existingTable);
metaStore.registerProvider(providerWithSameTableName); // throws
// after
metaStore.registerProvider(providerWithSameTableName); // import first
metaStore.createTable(existingTable); // then add extra tables with unique names
Defensive patterns

Strategy: validation

Validate before calling

for (String name : provider.getTables().keySet()) {
  if (metaStore.getTable(name) != null) {
    throw new IllegalStateException("Collision on table: " + name);
  }
}
metaStore.registerProvider(provider);

Try / catch

try {
  metaStore.registerProvider(provider);
} catch (IllegalStateException e) {
  if (e.getMessage().startsWith("Duplicate table:")) { /* rename or drop first */ }
}

Prevention

When it happens

Trigger: registerProvider(provider) where provider.getTables() returns a table whose name collides with a table already in the metastore (created earlier or imported from another provider).

Common situations: Registering a second provider that pre-defines common table names like 'orders'; registering the same composite provider chain twice after tables were already imported.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/store/InMemoryMetaStore.java:116

    }
  }

  @Override
  public void registerProvider(TableProvider provider) {
    String type = provider.getTableType().toLowerCase();
    if (providers.containsKey(type)) {
      throw new IllegalArgumentException("Provider is already registered for table type: " + type);
    }

    initTablesFromProvider(provider);
    this.providers.put(type, provider);
  }

  private void initTablesFromProvider(TableProvider provider) {
    Map<String, Table> tables = provider.getTables();
    for (String tableName : tables.keySet()) {
      if (this.tables.containsKey(tableName)) {
        throw new IllegalStateException(
            "Duplicate table: " + tableName + " from provider: " + provider);
      }
    }
    this.tables.putAll(tables);
  }

  @Override
  public Map<String, TableProvider> tableProviders() {
    return providers;
  }

  @Override
  public boolean supportsPartitioning(Table table) {
    return getProvider(table.getType()).supportsPartitioning(table);
  }

  /**
   * Fetches a {@link TableProvider} for this type. This provider can exist in the current {@link

View on GitHub (pinned to 12126d8942)