You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/03/19 18:01:29 UTC

[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5154: Fix the NPE for DISTINCT aggregation function when no record is selected

Jackie-Jiang commented on a change in pull request #5154: Fix the NPE for DISTINCT aggregation function when no record is selected
URL: https://github.com/apache/incubator-pinot/pull/5154#discussion_r395219463
 
 

 ##########
 File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionFactory.java
 ##########
 @@ -112,8 +111,10 @@ public static AggregationFunction getAggregationFunction(AggregationInfo aggrega
           case DISTINCTCOUNTRAWHLLMV:
             return new DistinctCountRawHLLMVAggregationFunction();
           case DISTINCT:
+            Preconditions.checkState(brokerRequest != null,
+                "Broker request must be provided for 'DISTINCT' aggregation function");
             return new DistinctAggregationFunction(AggregationFunctionUtils.getColumn(aggregationInfo),
-                brokerRequest != null ? brokerRequest.getLimit() : SelectAstNode.DEFAULT_RECORD_LIMIT, brokerRequest.getOrderBy());
+                brokerRequest.getOrderBy(), brokerRequest.getLimit());
 
 Review comment:
   The existing code never works for `null` brokerRequest because `brokerRequest.getOrderBy()` will directly throw NPE. The broker aggregation reducer might call this without brokerRequest, but distinct is not using that code path to reduce the result.
   I added TODOs in `AggregationFunctionUtils` to always pass broker request for all code paths

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org