Jackie-Jiang commented on a change in pull request #4535: Implement DISTINCT clause URL: https://github.com/apache/incubator-pinot/pull/4535#discussion_r324933169
########## File path: pinot-core/src/main/java/org/apache/pinot/core/query/reduce/BrokerReduceService.java ########## @@ -377,19 +386,50 @@ private void setAggregationResults(@Nonnull BrokerResponseNative brokerResponseN } } - // Extract final results and set them into the broker response. - List<AggregationResult> reducedAggregationResults = new ArrayList<>(numAggregationFunctions); - for (int i = 0; i < numAggregationFunctions; i++) { - Serializable resultValue = AggregationFunctionUtils - .getSerializableValue(aggregationFunctions[i].extractFinalResult(intermediateResults[i])); + // The DISTINCT query is just another SELECTION style query from the user's point of view + // and will return one or records in the result table for the column selected. + // Internally the execution is happening as an aggregation function (but that is an implementation + // detail) and so for that reason, response from broker should be a selection query result + // up until now, we have treated DISTINCT similar to another aggregation function even in terms + // of the result from function since it has been implemented as an aggregation function. + // However, the broker response will be a selection query response as that makes sense from SQL + // perspective + if (isDistinct(aggregationFunctions)) { + final Object merged = intermediateResults[0]; Review comment: (nit) final ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org