apache/beam · error · IllegalArgumentException

Duplicate table name

Error message

Duplicate table name: ${table.getName()}

What it means

InMemoryMetaStore.createTable enforces that table names are unique within the in-memory metastore. If a table with the same name already exists, it throws IllegalArgumentException before delegating to the provider. This mirrors relational catalog semantics where names are primary keys.

Solutions

  1. Call dropTable(name) before createTable, or ignore if it already exists.
  2. Use getTable(name) to check existence first and skip creation.
  3. Use a fresh InMemoryMetaStore instance per run/test to guarantee a clean catalog.

Example fix

// before
metaStore.createTable(table);
// after
if (metaStore.getTable(table.getName()) == null) {
  metaStore.createTable(table);
}
Defensive patterns

Strategy: validation

Validate before calling

if (metaStore.getTable(table.getName()) != null) {
  metaStore.dropTable(table.getName()); // or skip creation
}
metaStore.createTable(table);

Try / catch

try {
  metaStore.createTable(table);
} catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("Duplicate table name")) { /* already created: ignore or drop+recreate */ }
}

Prevention

When it happens

Trigger: Calling metaStore.createTable(table) twice with the same table.getName(), or re-running setup code (e.g. in tests or notebooks) that registers the same DDL twice without dropping first.

Common situations: Re-executed JUnit @BeforeAll setup; interactive SQL sessions re-running CREATE TABLE; hot-reloading app code that rebuilds the metastore into a shared instance.

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/140a8e75a7452105. 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:54

@SuppressWarnings({
  "nullness" // TODO(https://github.com/apache/beam/issues/20497)
})
public class InMemoryMetaStore implements MetaStore {
  private Map<String, Table> tables = new HashMap<>();
  private Map<String, TableProvider> providers = new HashMap<>();

  @Override
  public String getTableType() {
    return "store";
  }

  @Override
  public void createTable(Table table) {
    validateTableType(table);

    // first assert the table name is unique
    if (tables.containsKey(table.getName())) {
      throw new IllegalArgumentException("Duplicate table name: " + table.getName());
    }

    // invoke the provider's create
    getProvider(table.getType()).createTable(table);

    // store to the global metastore
    tables.put(table.getName(), table);
  }

  @Override
  public void dropTable(String tableName) {
    if (!tables.containsKey(tableName)) {
      throw new IllegalArgumentException("No such table: " + tableName);
    }

    Table table = tables.get(tableName);
    getProvider(table.getType()).dropTable(tableName);
    tables.remove(tableName);

View on GitHub (pinned to 12126d8942)