apache/druid · error · IllegalArgumentException
The table type is required.
Error message
The table type is required.
What it means
TableDefnRegistry.resolve() looks up the table definition registered for a spec's type. The type field is mandatory: without it the registry cannot select a definition, so an empty/null type throws IAE before the lookup.
Source
Thrown at server/src/main/java/org/apache/druid/catalog/model/TableDefnRegistry.java:145
{
this(null, null, null, jsonMapper);
}
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);
}
/**View on GitHub (pinned to 9b90983fd2)
Solutions
- Populate the type field on the TableSpec (e.g. "datasource") before resolving
- Check the source JSON includes the "type" property and that deserialization binds it
- Validate the spec (e.g. via TableSpec.validate()) before calling resolve
Example fix
// before
TableSpec spec = new TableSpec(null, props, columns);
registry.resolve(spec);
// after
TableSpec spec = new TableSpec("datasource", props, columns);
registry.resolve(spec); Defensive patterns
Strategy: validation
Validate before calling
if (Strings.isNullOrEmpty(spec.type())) {
throw new IllegalArgumentException("set spec.type before resolve()");
} Type guard
boolean isResolvable(TableSpec spec) {
return spec != null && spec.type() != null && !spec.type().isEmpty();
} Try / catch
try { return registry.resolve(spec); } catch (IllegalArgumentException e) { if (e.getMessage().equals("The table type is required.")) { /* populate type or reject payload */ } else { throw e; } } Prevention
- Always construct TableSpec with a type
- Validate specs at ingestion/deserialization boundaries
- Make type a required constructor parameter in your wrappers
When it happens
Trigger: Calling resolve(TableSpec) — directly or via table(), unsealed(), resolved() helpers — with a TableSpec whose type is null or empty.
Common situations: Deserializing a partial/incomplete table spec from JSON where the "type" field was omitted; building a TableSpec programmatically with a null type; legacy spec formats predating the type field.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Column name is required
- Column %d must have a name
- Database schema is required
- Table name is required
- Table type is required
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/187fb805f56b475f.
Report an issue: GitHub.