siddharthteotia commented on a change in pull request #4535: Implement DISTINCT 
clause
URL: https://github.com/apache/incubator-pinot/pull/4535#discussion_r315381929
 
 

 ##########
 File path: 
pinot-core/src/main/java/org/apache/pinot/core/plan/TransformPlanNode.java
 ##########
 @@ -76,7 +83,19 @@ private void extractColumnsAndTransforms(@Nonnull 
BrokerRequest brokerRequest,
       IndexSegment indexSegment) {
     if (brokerRequest.isSetAggregationsInfo()) {
       for (AggregationInfo aggregationInfo : 
brokerRequest.getAggregationsInfo()) {
-        if 
(!aggregationInfo.getAggregationType().equalsIgnoreCase(AggregationFunctionType.COUNT.getName()))
 {
+        if 
(aggregationInfo.getAggregationType().equalsIgnoreCase(AggregationFunctionType.DISTINCT.getName()))
 {
+          // handle DISTINCT (col1, col2 ...) as an aggregate function
+          final String multiColumnExpression = 
AggregationFunctionUtils.getColumn(aggregationInfo);
+          final String[] distinctColumnExpressions = 
multiColumnExpression.split(FunctionCallAstNode.DISTINCT_MULTI_COLUMN_SEPARATOR);
+          int col = 0;
+          for (String distinctColumnExpr : distinctColumnExpressions) {
+            TransformExpressionTree transformExpressionTree = 
TransformExpressionTree.compileToExpressionTree(distinctColumnExpr);
+            transformExpressionTree.getColumns(_projectionColumns);
+            _expressionTrees.add(transformExpressionTree);
+            _projectionColumnIndices.put(distinctColumnExpr, col++);
 
 Review comment:
   This is being used in the ProjectionOperator to correctly store info on each 
projected column type and the type info is used later when we build DataTable 
in InstanceResponeBlock to correctly set the type in DataSchema for each 
projected column in distinct query

----------------------------------------------------------------
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

Reply via email to