kgyrtkirk commented on code in PR #17354: URL: https://github.com/apache/druid/pull/17354#discussion_r1822862906
########## processing/src/main/java/org/apache/druid/query/union/UnionQueryQueryToolChest.java: ########## @@ -0,0 +1,153 @@ +/* + * 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.query.union; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.common.base.Function; +import com.google.common.base.Functions; +import org.apache.druid.error.DruidException; +import org.apache.druid.frame.allocation.MemoryAllocatorFactory; +import org.apache.druid.java.util.common.guava.Sequence; +import org.apache.druid.java.util.common.guava.Sequences; +import org.apache.druid.query.DefaultQueryMetrics; +import org.apache.druid.query.FrameSignaturePair; +import org.apache.druid.query.Query; +import org.apache.druid.query.QueryExecutor; +import org.apache.druid.query.QueryMetrics; +import org.apache.druid.query.QueryRunner; +import org.apache.druid.query.QuerySegmentWalker; +import org.apache.druid.query.QueryToolChest; +import org.apache.druid.query.aggregation.MetricManipulationFn; +import org.apache.druid.segment.column.RowSignature; +import org.apache.druid.segment.column.RowSignature.Finalization; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class UnionQueryQueryToolChest extends QueryToolChest<UnionResult, UnionQuery> + implements QueryExecutor<UnionResult> +{ + @Override + public QueryRunner<UnionResult> makeQueryRunner(Query<UnionResult> query, + QuerySegmentWalker clientQuerySegmentWalker) + { + return new UnionQueryRunner((UnionQuery) query, clientQuerySegmentWalker); + } + + @Override + @SuppressWarnings("unchecked") + public QueryRunner<UnionResult> mergeResults(QueryRunner<UnionResult> runner) + { + throw new UnsupportedOperationException("Not supported"); + } + + @Override + public QueryMetrics<? super UnionQuery> makeMetrics(UnionQuery query) + { + return new DefaultQueryMetrics<>(); + } + + @Override + public Function<UnionResult, UnionResult> makePreComputeManipulatorFn( + UnionQuery query, + MetricManipulationFn fn) + { + return Functions.identity(); + } + + @Override + public TypeReference<UnionResult> getResultTypeReference() + { + return null; + } + + @Override + public RowSignature resultArraySignature(UnionQuery query) + { + for (Query<?> q : query.queries) { + RowSignature sig = q.getResultRowSignature(Finalization.UNKNOWN); + if (sig != null) { + return sig; + } + } + throw DruidException.defensive("None of the subqueries support row signature"); Review Comment: its not mandatory to implement `Query#getResultRowSignature` - this exception is only fires if none of the queries have done that...I'm not sure what the user could do in that case; but enhanced the exception message -- 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]
