apache/druid · error · IllegalArgumentException

Table type [ ] is not valid.

Error message

Table type [%s] is not valid.

What it means

TableDefnRegistry.resolve() found a non-empty type on the spec, but no TableDefn is registered under that name. Only registered table types (e.g. "datasource") can be resolved; unknown types cannot be given a definition.

Solutions

  1. Correct the type string to a registered type (e.g. "datasource")
  2. Check which table definitions the registry instance was built with and add the missing one if custom
  3. Upgrade Druid if the table type is newer than the running version

Example fix

// before
TableSpec spec = new TableSpec("data_source", props, columns); // typo
registry.resolve(spec);
// after
TableSpec spec = new TableSpec("datasource", props, columns);
registry.resolve(spec);
Defensive patterns

Strategy: validation

Validate before calling

Set<String> known = registry.tableDefns().keySet(); // via available definitions
if (!known.contains(spec.type())) {
  throw new IllegalArgumentException("unknown type: " + spec.type());
}

Type guard

boolean isKnownType(TableDefnRegistry registry, TableSpec spec) {
  return spec.type() != null && registry.resolveOrNull(spec) != null;
}

Try / catch

try { return registry.resolve(spec); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Table type [")) { /* fall back to default handling / report unknown type */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling resolve() (or table()/unsealed()/resolved()) with a TableSpec whose type string is not a key in the registry's tableDefns map (typo, unsupported type, or definition not registered in this registry instance).

Common situations: Typo in the type string (e.g. "datasource"); using a type introduced in a newer Druid version on an older cluster; constructing a registry that omitted the needed definition; reading specs produced by another system.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/728aa188c5e2b6fd. Report an issue: GitHub.

Appendix: source

Thrown at server/src/main/java/org/apache/druid/catalog/model/TableDefnRegistry.java:149

  public TableDefn tableDefnFor(String type)
  {
    return tableDefns.get(type);
  }

  public ObjectMapper jsonMapper()
  {
    return jsonMapper;
  }

  public ResolvedTable resolve(TableSpec spec)
  {
    String type = spec.type();
    if (Strings.isNullOrEmpty(type)) {
      throw new IAE("The table type is required.");
    }
    TableDefn defn = tableDefns.get(type);
    if (defn == null) {
      throw new IAE("Table type [%s] is not valid.", type);
    }
    return new ResolvedTable(defn, spec, jsonMapper);
  }

  /**
   * Return input source definition for the given input source type name, or
   * {@code null} if there is no such definition.
   */
  public InputSourceDefn inputSourceDefnFor(String type)
  {
    return inputSourceDefns.get(type);
  }

  /**
   * Return input format definition for the given input format type name, or
   * {@code null} if there is no such definition.
   */
  public InputFormatDefn inputFormatDefnFor(String type)

View on GitHub (pinned to 9b90983fd2)