{"record":{"id":"3fed23b8983d5453","repo":"apache/druid","slug":"database-schema-is-required","errorCode":null,"errorMessage":"Database schema is required","messagePattern":"Database schema is required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/catalog/model/TableMetadata.java","lineNumber":264,"sourceCode":"  public long updateTime()\n  {\n    return updateTime;\n  }\n\n  @JsonProperty(\"spec\")\n  public TableSpec spec()\n  {\n    return spec;\n  }\n\n  /**\n   * Syntactic validation of a table object. Validates only that which\n   * can be checked from this table object.\n   */\n  public void validate()\n  {\n    if (Strings.isNullOrEmpty(id.schema())) {\n      throw new IAE(\"Database schema is required\");\n    }\n    if (Strings.isNullOrEmpty(id.name())) {\n      throw new IAE(\"Table name is required\");\n    }\n    if (spec == null) {\n      throw new IAE(\"A table definition must include a table spec.\");\n    }\n  }\n\n  @Override\n  public String toString()\n  {\n    return CatalogUtils.toString(this);\n  }\n\n  @Override\n  public boolean equals(Object o)\n  {","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/catalog/model/TableMetadata.java#L246-L282","documentation":"TableMetadata.validate() performs syntactic checks on a table object. The table's TableId must include a database (Druid) schema segment; a null or empty schema means the table cannot be placed in any schema namespace, so validation fails immediately.","triggerScenarios":"Calling TableMetadata.validate() (directly or on resolution paths) where id.schema() returns null or empty — e.g. a TableId built from just a name, or parsed from a string without a schema qualifier.","commonSituations":"Parsing a bare table name like \"myTable\" instead of \"druid.myTable\"; constructing TableId programmatically without setting schema; JSON payloads omitting the schema field of the ID.","solutions":["Build the TableId with a non-empty schema (typically \"druid\") before validating","Include the schema segment when parsing qualified names","Check deserialization so the id.schema field is populated from the payload"],"exampleFix":"// before\nTableMetadata md = new TableMetadata(TableId.of(null, \"myTable\"), ...);\nmd.validate();\n// after\nTableMetadata md = new TableMetadata(TableId.of(\"druid\", \"myTable\"), ...);\nmd.validate();","handlingStrategy":"validation","validationCode":"if (Strings.isNullOrEmpty(id.schema())) {\n  throw new IllegalArgumentException(\"set schema before validate()\");\n}","typeGuard":"boolean hasSchema(TableMetadata md) {\n  return md.getId() != null && !Strings.isNullOrEmpty(md.getId().schema());\n}","tryCatchPattern":"try { md.validate(); } catch (IllegalArgumentException e) { if (e.getMessage().equals(\"Database schema is required\")) { /* rebuild TableId with schema */ } else { throw e; } }","preventionTips":["Use TableId.parse with fully qualified names (schema.table)","Default the schema to \"druid\" when absent in user input","Validate identifiers at API boundaries before constructing TableMetadata"],"tags":["validation","catalog","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}