gianm commented on code in PR #13506: URL: https://github.com/apache/druid/pull/13506#discussion_r1127458820
########## extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/kernel/HashShuffleSpec.java: ########## @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.msq.kernel; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.druid.frame.key.ClusterBy; +import org.apache.druid.frame.key.ClusterByPartitions; +import org.apache.druid.java.util.common.Either; +import org.apache.druid.java.util.common.IAE; +import org.apache.druid.msq.statistics.ClusterByStatisticsCollector; + +import javax.annotation.Nullable; + +public class HashShuffleSpec implements ShuffleSpec +{ + public static final String TYPE = "hash"; + + private final ClusterBy clusterBy; + private final int numPartitions; + + @JsonCreator + public HashShuffleSpec( + @JsonProperty("clusterBy") final ClusterBy clusterBy, + @JsonProperty("partitions") final int numPartitions + ) + { + this.clusterBy = clusterBy; + this.numPartitions = numPartitions; + + if (clusterBy.getBucketByCount() > 0) { + // Only GlobalSortTargetSizeShuffleSpec supports bucket-by. + throw new IAE("Cannot bucket with %s partitioning", TYPE); + } Review Comment: > Is there no way to make it so that the only thing that supports it is the only thing that takes it? It could be done. It makes this code cleaner but then makes other code elsewhere dirtier. On balance I think it's better this way. > Additionally, if you were to interpolate the clusterBy into the error message, would it generate something that tells the user which part of their query is doing weird things? If the planner is non-buggy then there would be no way a user sees this. (Unless they write their own MSQ spec, without going through SQL.) That being said, I think we might as well include `clusterBy` here to help debug any potential planner bugs. I added it. -- 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]
