siddharthteotia commented on code in PR #10006: URL: https://github.com/apache/pinot/pull/10006#discussion_r1068861165
########## pinot-core/src/main/java/org/apache/pinot/core/operator/combine/merger/SelectionOnlyResultBlockMerger.java: ########## @@ -0,0 +1,65 @@ +/** + * 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.pinot.core.operator.combine.merger; + +import java.util.Collection; +import org.apache.pinot.common.exception.QueryException; +import org.apache.pinot.common.utils.DataSchema; +import org.apache.pinot.core.operator.blocks.results.SelectionResultsBlock; +import org.apache.pinot.core.query.request.context.QueryContext; +import org.apache.pinot.core.query.selection.SelectionOperatorUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class SelectionOnlyResultBlockMerger implements ResultBlockMerger<SelectionResultsBlock> { + private static final Logger LOGGER = LoggerFactory.getLogger(SelectionOnlyResultBlockMerger.class); + private final int _numRowsToKeep; + + public SelectionOnlyResultBlockMerger(QueryContext queryContext) { + _numRowsToKeep = queryContext.getLimit(); + } + + @Override + public boolean isQuerySatisfied(SelectionResultsBlock resultsBlock) { + return resultsBlock.getRows().size() == _numRowsToKeep; + } + + @Override + public void mergeResultsBlocks(SelectionResultsBlock mergedBlock, SelectionResultsBlock blockToMerge) { + DataSchema mergedDataSchema = mergedBlock.getDataSchema(); + DataSchema dataSchemaToMerge = blockToMerge.getDataSchema(); + assert mergedDataSchema != null && dataSchemaToMerge != null; + if (!mergedDataSchema.equals(dataSchemaToMerge)) { + String errorMessage = + String.format("Data schema mismatch between merged block: %s and block to merge: %s, drop block to merge", Review Comment: This should be thrown or handled better so that the caller of `mergeResultsBlocks` does not continue merging rest of the subsequent blocks since query has essentially failed or do we instead continue and return results with partial flag set to true ? -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org