{"record":{"id":"975026bc32bf8d20","repo":"apache/druid","slug":"unknown","errorCode":"Unknown","errorMessage":"Query[%s] cannot store compaction state in segments as shard spec of unsupported type[%s].","messagePattern":"Query\\[(.+?)\\] cannot store compaction state in segments as shard spec of unsupported type\\[(.+?)\\]\\.","errorType":"error_code","errorClass":"MSQException","httpStatus":null,"severity":"error","filePath":"multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java","lineNumber":1856,"sourceCode":"    final PartitionsSpec partitionSpec;\n    // shardSpec is absent in the absence of segments, which happens when only tombstones are generated by an\n    // MSQControllerTask.\n    if (shardSpec != null) {\n      if (Objects.equals(shardSpec.getType(), ShardSpec.Type.RANGE)) {\n        List<String> partitionDimensions = ((DimensionRangeShardSpec) shardSpec).getDimensions();\n        // Effective maxRowsPerSegment is propagated as rowsPerSegment in MSQ\n        partitionSpec = new DimensionRangePartitionsSpec(\n            null,\n            tuningConfig.getRowsPerSegment(),\n            partitionDimensions,\n            false\n        );\n      } else if (Objects.equals(shardSpec.getType(), ShardSpec.Type.NUMBERED)) {\n        // MSQ tasks don't use maxTotalRows. Hence using LONG.MAX_VALUE.\n        partitionSpec = new DynamicPartitionsSpec(tuningConfig.getRowsPerSegment(), Long.MAX_VALUE);\n      } else {\n        // SingleDimenionShardSpec and other shard specs are never created in MSQ.\n        throw new MSQException(\n            UnknownFault.forMessage(\n                StringUtils.format(\n                    \"Query[%s] cannot store compaction state in segments as shard spec of unsupported type[%s].\",\n                    queryDef.getQueryId(),\n                    shardSpec.getType()\n                )));\n      }\n    } else if (clusterBy != null && !clusterBy.getColumns().isEmpty()) {\n      // Effective maxRowsPerSegment is propagated as rowsPerSegment in MSQ\n      partitionSpec = new DimensionRangePartitionsSpec(\n          null,\n          tuningConfig.getRowsPerSegment(),\n          clusterBy.getColumns()\n                   .stream()\n                   .map(KeyColumn::columnName).collect(Collectors.toList()),\n          false\n      );\n    } else {","sourceCodeStart":1838,"sourceCodeEnd":1874,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java#L1838-L1874","documentation":"When an MSQ query must store compaction state into output segments, ControllerImpl derives a partition spec from each segment's shard spec. Only LinearShardSpec and NumberedShardSpec are supported; encountering any other shard spec type throws MSQException with an UnknownFault, since MSQ never creates such shard specs itself.","triggerScenarios":"Running an MSQ query (e.g. INSERT/REPLACE or compaction via MSQ) whose input/target segments carry a shard spec whose type is neither LINEAR nor NUMBERED (e.g. SingleDimensionShardSpec from native compaction) while storing compaction state in segments.","commonSituations":"Compacting with MSQ over segments previously produced by native compaction with hash/single-dimension sharding; mixing segment generations created by different engines.","solutions":["Re-generate or recompact the input segments so they use linear/numbered shard specs before running the MSQ job","Run native compaction instead of MSQ compaction for datasources containing unsupported shard specs","Avoid enabling 'store compaction state in segments' for these datasources","Upgrade Druid if a newer release adds support for the shard spec type"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for (DataSegment seg : inputSegments) { if (seg.getShardSpec().getType() != ShardSpec.Type.LINEAR && seg.getShardSpec().getType() != ShardSpec.Type.NUMBERED) throw new IllegalStateException(\"unsupported shard type: \" + seg.getShardSpec().getType()); }","typeGuard":null,"tryCatchPattern":"try { client.runMsq(compactionQuery); } catch (MSQException e) { if (e.getFault() instanceof UnknownFault && e.getMessage().contains(\"shard spec of unsupported type\")) { recompactNativelyFirst(); } else { throw e; } }","preventionTips":["Check datasource segment shard specs before MSQ compaction","Recompact with linear/numbered sharding first","Avoid mixing native-compacted single-dim segments into MSQ compaction"],"tags":["druid","msq","compaction","shardspec"],"backgroundTag":"unsupported-operation","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"}