apache/druid · error · UnsupportedOperationException

Cannot handle dataSource [%s]

Error message

Cannot handle dataSource [%s]

What it means

Thrown by DataSourcePlan.forDataSource when no registered DataSourcePlanner can handle the given DataSource class. Each query kit declares which data source types it can plan (table, query, inline, lookup, etc.); an unregistered type means the kit cannot process this source.

Source

Thrown at multi-stage-query/src/main/java/org/apache/druid/msq/querykit/DataSourcePlan.java:99

   * @param dataSource       datasource to plan
   * @param querySegmentSpec intervals for mandatory pruning. Must be {@link MultipleIntervalSegmentSpec}. The returned
   *                         plan is guaranteed to be filtered to this interval.
   * @param minStageNumber   starting stage number for subqueries
   * @param broadcast        whether the plan should broadcast data for this datasource
   */
  public static DataSourcePlan forDataSource(
      final QueryKitSpec queryKitSpec,
      final QueryContext queryContext,
      final DataSource dataSource,
      final QuerySegmentSpec querySegmentSpec,
      final int minStageNumber,
      final boolean broadcast
  )
  {
    //noinspection rawtypes
    final DataSourcePlanner planner = queryKitSpec.getDataSourcePlanners().getPlanner(dataSource.getClass());
    if (planner == null) {
      throw new UOE("Cannot handle dataSource [%s]", dataSource);
    }

    //noinspection unchecked
    return planner.planDataSource(
        queryKitSpec,
        queryContext,
        dataSource,
        querySegmentSpec,
        minStageNumber,
        broadcast
    );
  }

  /**
   * Possibly remapped datasource that should be used when processing. Will be either the original datasource, or the
   * original datasource with itself or some children replaced by {@link InputNumberDataSource}. Any added
   * {@link InputNumberDataSource} refer to {@link StageInputSpec} in {@link #getInputSpecs()}.
   */

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Rewrite the query to use a supported source, e.g. inline the data or use a table data source.
  2. For lookups, join against a table-based source or use the SQL lookup function supported by the engine.
  3. If a custom DataSource type is involved, register a DataSourcePlanner for it in the kit spec.

Example fix

// before
// MSQ query against a lookup datasource (unsupported)
SELECT * FROM lookup.myLookup;
// after
// rewrite as join against a druid table or use inline data:
SELECT t.*, l.v FROM druid.tbl t JOIN lookup.myLookup l ON t.k = l.k;
Defensive patterns

Strategy: validation

Validate before calling

// check the datasource kind is MSQ-supported before submitting
String dsClass = dataSource.getClass().getSimpleName();
if (!(dataSource instanceof TableDataSource || dataSource instanceof QueryDataSource || dataSource instanceof InlineDataSource)) {
  throw new IllegalArgumentException("MSQ cannot plan datasource: " + dsClass);
}

Try / catch

try {
  plan = DataSourcePlan.forDataSource(queryKitSpec, ctx, broadcast, dataSource);
} catch (UnsupportedOperationException e) {
  // rewrite query with supported table/inline source
}

Prevention

When it happens

Trigger: Passing a data source whose class has no planner in queryKitSpec.getDataSourcePlanners(), e.g. a lookup data source or nested query data source fed into a kit that only supports table/inline/query sources.

Common situations: Querying a lookup or metadata segment data source through the MSQ engine; extension data sources not registered with MSQ planners; composing SQL with constructs that produce unsupported data sources (e.g. certain joins/unions of lookups).

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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