apache/druid · error · IAE

Use a table function to set either

Error message

Use a table function to set either %s or %s

What it means

Druid's LocalInputSource rejects input sources that specify neither files nor filter — a bare baseDir alone cannot be converted to a valid input source (it needs a filter, which the catalog adds only for table-function paths). When converting a completed table whose stored input source has neither files nor filter, convertTable throws this IAE directing the user to the table function.

Solutions

  1. Run the table function once with files or filter to finalize the table definition
  2. Add a filter property (e.g. "*") to the table's input source
  3. Add an explicit files list to the table's input source

Example fix

// before
{"type":"local","baseDir":"/data"}
// after
{"type":"local","baseDir":"/data","filter":"*"}
Defensive patterns

Strategy: validation

Validate before calling

// Java
Map<String,Object> src = table.inputSourceMap;
if (!CollectionUtils.isNullOrEmpty((List<?>) src.getOrDefault("files", List.of())) == false
    && Strings.isNullOrEmpty((String) src.get("filter")))
  throw new IllegalArgumentException("finalize local table via table function or add filter");

Try / catch

try { table.convert(); } catch (IAE e) { if (e.getMessage().contains("Use a table function")) { /* invoke the table function with files/filter first */ } else throw e; }

Prevention

When it happens

Trigger: Querying an external table with type 'local' whose inputSourceMap contains only baseDir (no files, no filter) via a path that bypasses the table function; tables defined with baseDir but never finalized with a table function.

Common situations: Defining a table spec with just baseDir and trying to use it directly; programmatic table creation skipping the table-function resolution step; hand-authored catalog JSON.

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


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

Appendix: source

Thrown at server/src/main/java/org/apache/druid/catalog/model/table/LocalInputSourceDefn.java:272

    // we list. Take pity on the user and provide a filter in this case.
    String filter = CatalogUtils.getString(jsonMap, FILTER_FIELD);
    if (filter != null) {
      return;
    }
    String baseDir = CatalogUtils.getString(jsonMap, BASE_DIR_FIELD);
    if (baseDir != null) {
      jsonMap.put(FILTER_FIELD, "*");
    }
  }

  @Override
  public ExternalTableSpec convertTable(ResolvedExternalTable table)
  {
    final Map<String, Object> sourceMap = new HashMap<>(table.inputSourceMap);
    final boolean hasFiles = !CollectionUtils.isNullOrEmpty(CatalogUtils.safeGet(sourceMap, FILES_FIELD, List.class));
    final boolean hasFilter = !Strings.isNullOrEmpty(CatalogUtils.getString(sourceMap, FILTER_FIELD));
    if (!hasFiles && !hasFilter) {
      throw new IAE(
          "Use a table function to set either %s or %s",
          FILES_PARAMETER,
          FILTER_PARAMETER
      );
    }
    return super.convertTable(table);
  }
}

View on GitHub (pinned to 9b90983fd2)