apache/druid · error · IAE

Expected [1] child, got

Error message

Expected [1] child, got [%d]

What it means

A FilteredDataSource wraps exactly one child data source plus a filter. DataSource.withChildren(children) replaces the child list, and this implementation requires exactly one child; any other count is rejected with this IllegalArgumentException to keep the data source tree structurally valid during query planning/rewriting.

Solutions

  1. Ensure the children list passed to withChildren contains exactly the single child of the FilteredDataSource.
  2. When rewriting, preserve the original child count by calling withChildren on the correct DataSource node type rather than a sibling node.
  3. Inspect the rewriting code that produced the list; it likely aggregated children of a parent (e.g. a join) and applied them to a filtered child.

Example fix

// before
ds.withChildren(allChildren); // allChildren.size() == 3
// after
ds.withChildren(allChildren.subList(0, 1)); // filtered datasource takes only its own child
Defensive patterns

Strategy: validation

Validate before calling

if (children.size() != 1) {
  throw new IllegalArgumentException("FilteredDataSource expects exactly 1 child, got " + children.size());
}

Prevention

When it happens

Trigger: Calling filteredDataSource.withChildren(list) with an empty list or a list of 2+ data sources, typically from a planner/rewriter pass that miscounts children when rebuilding a datasource tree.

Common situations: Custom query tooling or extension code that recursively rebuilds data sources; bugs in datasource-rewriting utilities (e.g. analysis/replacement passes) that collect children from multiple sources into one list.

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/b1b26904bf798e56. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/FilteredDataSource.java:96

  }

  @Override
  public Set<String> getTableNames()
  {
    return base.getTableNames();
  }

  @Override
  public List<DataSource> getChildren()
  {
    return ImmutableList.of(base);
  }

  @Override
  public DataSource withChildren(List<DataSource> children)
  {
    if (children.size() != 1) {
      throw new IAE("Expected [1] child, got [%d]", children.size());
    }

    return new FilteredDataSource(children.get(0), filter);
  }

  @Override
  public boolean isCacheable(boolean isBroker)
  {
    return false;
  }

  @Override
  public boolean isGlobal()
  {
    return base.isGlobal();
  }

  @Override

View on GitHub (pinned to 9b90983fd2)