{"record":{"id":"2f112c71d6485b96","repo":"apache/druid","slug":"function-requires-a-schema-table-s-col","errorCode":null,"errorMessage":"Function requires a schema: TABLE(%s(...)) (<col> <type>...)","messagePattern":"Function requires a schema: TABLE\\((.+?)\\(\\.\\.\\.\\)\\) \\(<col> <type>\\.\\.\\.\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/catalog/model/table/BaseTableFunction.java","lineNumber":91,"sourceCode":"  }\n\n  private final List<ParameterDefn> parameters;\n\n  public BaseTableFunction(List<ParameterDefn> parameters)\n  {\n    this.parameters = parameters;\n  }\n\n  @Override\n  public List<ParameterDefn> parameters()\n  {\n    return parameters;\n  }\n\n  protected static void requireSchema(String fnName, List<ColumnSpec> columns)\n  {\n    if (columns == null) {\n      throw new IAE(\n          \"Function requires a schema: TABLE(%s(...)) (<col> <type>...)\",\n          fnName\n      );\n    }\n  }\n}\n","sourceCodeStart":73,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/catalog/model/table/BaseTableFunction.java#L73-L98","documentation":"BaseTableFunction.requireSchema throws this when a table function is invoked without a column schema. Druid's TABLE(...) functions need an explicit column list (<col> <type>...) because the underlying data source provides none.","triggerScenarios":"Calling a table function like TABLE(extern(...)(...)) omitting the parenthesized schema entirely (columns == null passed to requireSchema).","commonSituations":"Writing SQL like SELECT * FROM TABLE(extern('...')) without the '(col1 col2 ...)' schema suffix; generating table function SQL programmatically and dropping the schema clause.","solutions":["Append the schema: TABLE(fn(args) (colName TYPE, ...)).","Infer the schema first, then re-issue the query with explicit columns.","Check the function's javadoc for which functions require a schema.","For inline/local data, provide columns matching the parsed format fields."],"exampleFix":"// before\nSELECT * FROM TABLE(extern(\"data\"))\n// after\nSELECT * FROM TABLE(extern(\"data\") (col1 VARCHAR, col2 BIGINT))","handlingStrategy":"validation","validationCode":"// verify the TABLE(...) SQL includes a schema clause before execution\nif (!sql.matches(\".*TABLE\\\\s*\\\\([^)]*\\\\)\\\\s*\\\\(.*\\\\).*\")) {\n  throw new IllegalArgumentException(\"TABLE function requires (col TYPE, ...) schema\");\n}","typeGuard":null,"tryCatchPattern":"try { runQuery(sql); } catch (IAE e) { if (e.getMessage().contains(\"requires a schema\")) { sql = addSchemaClause(sql, inferredColumns); runQuery(sql); } }","preventionTips":["Always append (col TYPE, ...) to TABLE() function calls","Infer schema via sampling first, then write explicit schema","Use IDE/console SQL editors that surface table function signatures","Document required schemas for custom table functions"],"tags":["druid","sql","table-function","missing-schema"],"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"}