{"record":{"id":"a1abf06a70940206","repo":"apache/druid","slug":"cannot-handle-datasource-s","errorCode":null,"errorMessage":"Cannot handle dataSource [%s]","messagePattern":"Cannot handle dataSource \\[(.+?)\\]","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"multi-stage-query/src/main/java/org/apache/druid/msq/querykit/DataSourcePlan.java","lineNumber":99,"sourceCode":"   * @param dataSource       datasource to plan\n   * @param querySegmentSpec intervals for mandatory pruning. Must be {@link MultipleIntervalSegmentSpec}. The returned\n   *                         plan is guaranteed to be filtered to this interval.\n   * @param minStageNumber   starting stage number for subqueries\n   * @param broadcast        whether the plan should broadcast data for this datasource\n   */\n  public static DataSourcePlan forDataSource(\n      final QueryKitSpec queryKitSpec,\n      final QueryContext queryContext,\n      final DataSource dataSource,\n      final QuerySegmentSpec querySegmentSpec,\n      final int minStageNumber,\n      final boolean broadcast\n  )\n  {\n    //noinspection rawtypes\n    final DataSourcePlanner planner = queryKitSpec.getDataSourcePlanners().getPlanner(dataSource.getClass());\n    if (planner == null) {\n      throw new UOE(\"Cannot handle dataSource [%s]\", dataSource);\n    }\n\n    //noinspection unchecked\n    return planner.planDataSource(\n        queryKitSpec,\n        queryContext,\n        dataSource,\n        querySegmentSpec,\n        minStageNumber,\n        broadcast\n    );\n  }\n\n  /**\n   * Possibly remapped datasource that should be used when processing. Will be either the original datasource, or the\n   * original datasource with itself or some children replaced by {@link InputNumberDataSource}. Any added\n   * {@link InputNumberDataSource} refer to {@link StageInputSpec} in {@link #getInputSpecs()}.\n   */","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/DataSourcePlan.java#L81-L117","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Rewrite the query to use a supported source, e.g. inline the data or use a table data source.","For lookups, join against a table-based source or use the SQL lookup function supported by the engine.","If a custom DataSource type is involved, register a DataSourcePlanner for it in the kit spec."],"exampleFix":"// before\n// MSQ query against a lookup datasource (unsupported)\nSELECT * FROM lookup.myLookup;\n// after\n// rewrite as join against a druid table or use inline data:\nSELECT t.*, l.v FROM druid.tbl t JOIN lookup.myLookup l ON t.k = l.k;","handlingStrategy":"validation","validationCode":"// check the datasource kind is MSQ-supported before submitting\nString dsClass = dataSource.getClass().getSimpleName();\nif (!(dataSource instanceof TableDataSource || dataSource instanceof QueryDataSource || dataSource instanceof InlineDataSource)) {\n  throw new IllegalArgumentException(\"MSQ cannot plan datasource: \" + dsClass);\n}","typeGuard":null,"tryCatchPattern":"try {\n  plan = DataSourcePlan.forDataSource(queryKitSpec, ctx, broadcast, dataSource);\n} catch (UnsupportedOperationException e) {\n  // rewrite query with supported table/inline source\n}","preventionTips":["Restrict MSQ queries to table/inline/query data sources.","Resolve lookups to joins against tables or inline data before using MSQ.","Register a DataSourcePlanner for any custom data source type."],"tags":["druid","msq","datasource","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}