gargvishesh commented on code in PR #16778:
URL: https://github.com/apache/druid/pull/16778#discussion_r1692947447
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java:
##########
@@ -1624,33 +1629,49 @@ private static Function<Set<DataSegment>,
Set<DataSegment>> addCompactionStateTo
MSQSpec querySpec,
ObjectMapper jsonMapper,
DataSchema dataSchema,
- ShardSpec shardSpec,
+ @Nullable ShardSpec shardSpec,
+ @Nullable ClusterBy clusterBy,
String queryId
)
{
final MSQTuningConfig tuningConfig = querySpec.getTuningConfig();
PartitionsSpec partitionSpec;
- if (Objects.equals(shardSpec.getType(), ShardSpec.Type.RANGE)) {
- List<String> partitionDimensions = ((DimensionRangeShardSpec)
shardSpec).getDimensions();
+ // shardSpec is absent in the absence of segments, which happens when only
tombstones are generated by an
+ // MSQControllerTask.
+ if (shardSpec != null) {
+ if (Objects.equals(shardSpec.getType(), ShardSpec.Type.RANGE)) {
+ List<String> partitionDimensions = ((DimensionRangeShardSpec)
shardSpec).getDimensions();
+ partitionSpec = new DimensionRangePartitionsSpec(
+ tuningConfig.getRowsPerSegment(),
+ null,
+ partitionDimensions,
+ false
+ );
+ } else if (Objects.equals(shardSpec.getType(), ShardSpec.Type.NUMBERED))
{
+ // MSQ tasks don't use maxTotalRows. Hence using LONG.MAX_VALUE.
+ partitionSpec = new
DynamicPartitionsSpec(tuningConfig.getRowsPerSegment(), Long.MAX_VALUE);
+ } else {
+ // SingleDimenionShardSpec and other shard specs are never created in
MSQ.
+ throw new MSQException(
+ UnknownFault.forMessage(
+ StringUtils.format(
+ "Query[%s] cannot store compaction state in segments as
shard spec of unsupported type[%s].",
+ queryId,
+ shardSpec.getType()
+ )));
+ }
+ } else if (clusterBy != null && !clusterBy.getColumns().isEmpty()) {
Review Comment:
There is a `checkNotNull` in the `ClusterBy` constructor.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]