atris commented on a change in pull request #7141: URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666455606
########## File path: pinot-core/src/main/java/org/apache/pinot/core/plan/maker/InstancePlanMakerImplV2.java ########## @@ -264,4 +267,31 @@ static boolean isFitForDictionaryBasedPlan(QueryContext queryContext, IndexSegme } return true; } + + /** + * Returns dictionary based distinct plan node iff supported, else distinct plan node + */ + private PlanNode getDistinctExecutionNode(IndexSegment indexSegment, QueryContext queryContext) { + AggregationFunction[] aggregationFunctions = queryContext.getAggregationFunctions(); + + // If we have gotten here, it must have been verified that there is only on aggregation function in the context + // and it is a DistinctAggregationFunction + + DistinctAggregationFunction distinctAggregationFunction = (DistinctAggregationFunction) aggregationFunctions[0]; + List<ExpressionContext> expressions = distinctAggregationFunction.getInputExpressions(); + + if (expressions.size() == 1 && queryContext.getFilter() == null) { + ExpressionContext expression = expressions.get(0); + + if (expression.getType() == ExpressionContext.Type.IDENTIFIER) { + String column = expression.getIdentifier(); + Dictionary dictionary = indexSegment.getDataSource(column).getDictionary(); + if (dictionary != null && dictionary.isSorted()) { Review comment: How would we apply limits on it? -- 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