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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to