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 2021/07/08 08:15:54 UTC

[GitHub] [incubator-pinot] atris opened a new pull request #7141: Support Dictionary Based Plans For DISTINCT

atris opened a new pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141


   ## Description
   This PR introduces the ability to execute DISTINCT using a dictionary based plan when the DISTINCT query has a single column, no filters and the column is dictionary encoded.
   
   ## Upgrade Notes
   Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
   * [ ] Yes (Please label as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
   
   Does this PR fix a zero-downtime upgrade introduced earlier?
   * [ ] Yes (Please label this as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
   
   Does this PR otherwise need attention when creating release notes? Things to consider:
   - New configuration options
   - Deprecation of configurations
   - Signature changes to public methods/interfaces
   - New plugins added or old plugins removed
   * [ ] Yes (Please label this PR as **<code>release-notes</code>** and complete the section on Release Notes)
   ## Release Notes
   <!-- If you have tagged this as either backward-incompat or release-notes,
   you MUST add text here that you would like to see appear in release notes of the
   next release. -->
   
   <!-- If you have a series of commits adding or enabling a feature, then
   add this section only in final commit that marks the feature completed.
   Refer to earlier release notes to see examples of text.
   -->
   ## Documentation
   <!-- If you have introduced a new feature or configuration, please add it to the documentation as well.
   See https://docs.pinot.apache.org/developers/developers-and-contributors/update-document
   -->
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r667264444



##########
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 getDistinctPlanNode(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) {
+          return new DictionaryBasedDistinctPlanNode(indexSegment, queryContext, dictionary);

Review comment:
       (nit) get the data type here and pass it in instead of passing in the segment

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,153 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.BaseOperator;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends BaseOperator<IntermediateResultsBlock> {
+  private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+
+  private final DistinctAggregationFunction _distinctAggregationFunction;
+  private final Dictionary _dictionary;
+  private final int _numTotalDocs;
+  private IndexSegment _indexSegment;
+
+  private boolean _hasOrderBy;
+  private boolean _isAscending;
+
+  private int _dictLength;

Review comment:
       This can be final, or move to local variable (preferable)

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,153 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.BaseOperator;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends BaseOperator<IntermediateResultsBlock> {
+  private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+
+  private final DistinctAggregationFunction _distinctAggregationFunction;
+  private final Dictionary _dictionary;
+  private final int _numTotalDocs;
+  private IndexSegment _indexSegment;

Review comment:
       This can be 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.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
atris commented on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876728697


   @Jackie-Jiang Updated, please see and let me know your thoughts


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r667211807



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/plan/DictionaryBasedDistinctPlanNode.java
##########
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.plan;
+
+import org.apache.pinot.core.operator.query.DictionaryBasedDistinctOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+
+/**
+ * Execute a DISTINCT operation using dictionary based plan
+ */
+public class DictionaryBasedDistinctPlanNode implements PlanNode {
+  private final IndexSegment _indexSegment;
+  private final DistinctAggregationFunction _distinctAggregationFunction;
+  private final Dictionary _dictionary;
+  private final TransformPlanNode _transformPlanNode;
+
+  /**
+   * Constructor for the class.
+   *
+   * @param indexSegment Segment to process
+   * @param queryContext Query context
+   */
+  public DictionaryBasedDistinctPlanNode(IndexSegment indexSegment, QueryContext queryContext, Dictionary dictionary) {
+    _indexSegment = indexSegment;
+    AggregationFunction[] aggregationFunctions = queryContext.getAggregationFunctions();
+
+    assert aggregationFunctions != null && aggregationFunctions.length == 1
+        && aggregationFunctions[0] instanceof DistinctAggregationFunction;
+
+    _distinctAggregationFunction = (DistinctAggregationFunction) aggregationFunctions[0];
+
+    _dictionary = dictionary;
+
+    _transformPlanNode =

Review comment:
       No need to create the transform plan

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,146 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {

Review comment:
       We should extends `BaseOperator<IntermediateResultsBlock>` instead of `DistinctOperator`

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,146 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+  private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+
+  private final DistinctAggregationFunction _distinctAggregationFunction;
+  private final Dictionary _dictionary;
+  private final int _numTotalDocs;
+
+  private boolean _hasOrderBy;
+  private boolean _isAscending;
+
+  private int _dictLength;
+
+  public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+      Dictionary dictionary, int numTotalDocs,
+      TransformOperator transformOperator) {
+    super(indexSegment, distinctAggregationFunction, transformOperator);
+
+    _distinctAggregationFunction = distinctAggregationFunction;
+    _dictionary = dictionary;
+    _numTotalDocs = numTotalDocs;
+
+    List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+    if (orderByExpressionContexts != null) {
+      OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+
+      _isAscending = orderByExpressionContext.isAsc();
+      _hasOrderBy = true;
+    }
+
+    _dictLength = _dictionary.length();
+  }
+
+  @Override
+  protected IntermediateResultsBlock getNextBlock() {
+    DistinctTable distinctTable = buildResult();
+
+    return new IntermediateResultsBlock(new AggregationFunction[]{_distinctAggregationFunction},
+        Collections.singletonList(distinctTable), false);
+  }
+
+  /**
+   * Build the final result for this operation
+   */
+  private DistinctTable buildResult() {
+
+    assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+    List<ExpressionContext> expressions = _distinctAggregationFunction.getInputExpressions();
+    ExpressionContext expression = expressions.get(0);
+    FieldSpec.DataType dataType = _dictionary.getValueType();
+
+    DataSchema dataSchema = new DataSchema(new String[]{expression.toString()},
+        new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.fromDataTypeSV(dataType)});
+    List<Record> records;
+
+    int limit = _distinctAggregationFunction.getLimit();
+    int actualLimit = Math.min(limit, _dictLength);
+
+    // If ORDER BY is not present, we read the first limit values from the dictionary and return.
+    // If ORDER BY is present and the dictionary is sorted, then we read the first/last limit values
+    // from the dictionary. If not sorted, then we read the entire dictionary and return it.
+    if (!_hasOrderBy) {
+      records = new ArrayList<>(actualLimit);
+
+      for (int i = 0; i < actualLimit; i++) {
+        records.add(new Record(new Object[]{_dictionary.getInternal(i)}));
+      }
+    } else {
+      DistinctTable distinctTable = new DistinctTable(dataSchema, _distinctAggregationFunction.getOrderByExpressions(), limit);
+
+      if (_dictionary.isSorted()) {
+        if (_isAscending) {
+          for (int i = 0; i < actualLimit; i++) {
+            distinctTable.addWithOrderBy(new Record(new Object[]{_dictionary.getInternal(i)}));
+          }
+        } else {
+          for (int i = _dictLength - 1; i >= (_dictLength - actualLimit); i--) {
+            distinctTable.addWithOrderBy(new Record(new Object[]{_dictionary.getInternal(i)}));
+          }
+        }
+      } else {
+        for (int i = 0; i < _dictLength; i++) {
+          distinctTable.addWithOrderBy(new Record(new Object[]{_dictionary.getInternal(i)}));
+        }
+      }
+
+      return distinctTable;
+    }
+
+    return new DistinctTable(dataSchema, records);
+  }
+
+  @Override
+  public String getOperatorName() {
+    return OPERATOR_NAME;
+  }
+
+  @Override
+  public ExecutionStatistics getExecutionStatistics() {
+    // NOTE: Set numDocsScanned to numTotalDocs for backward compatibility.
+    return new ExecutionStatistics(_numTotalDocs, 0, 0, _numTotalDocs);

Review comment:
       Let's count the actual values read from the dictionary, and put it as `numDocsScanned` and `numEntriesScannedPostFilter`

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,146 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+  private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+
+  private final DistinctAggregationFunction _distinctAggregationFunction;
+  private final Dictionary _dictionary;
+  private final int _numTotalDocs;
+
+  private boolean _hasOrderBy;
+  private boolean _isAscending;
+
+  private int _dictLength;
+
+  public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+      Dictionary dictionary, int numTotalDocs,
+      TransformOperator transformOperator) {
+    super(indexSegment, distinctAggregationFunction, transformOperator);
+
+    _distinctAggregationFunction = distinctAggregationFunction;
+    _dictionary = dictionary;
+    _numTotalDocs = numTotalDocs;
+
+    List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+    if (orderByExpressionContexts != null) {
+      OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+
+      _isAscending = orderByExpressionContext.isAsc();
+      _hasOrderBy = true;
+    }
+
+    _dictLength = _dictionary.length();
+  }
+
+  @Override
+  protected IntermediateResultsBlock getNextBlock() {
+    DistinctTable distinctTable = buildResult();
+
+    return new IntermediateResultsBlock(new AggregationFunction[]{_distinctAggregationFunction},
+        Collections.singletonList(distinctTable), false);
+  }
+
+  /**
+   * Build the final result for this operation
+   */
+  private DistinctTable buildResult() {
+
+    assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+    List<ExpressionContext> expressions = _distinctAggregationFunction.getInputExpressions();
+    ExpressionContext expression = expressions.get(0);
+    FieldSpec.DataType dataType = _dictionary.getValueType();
+
+    DataSchema dataSchema = new DataSchema(new String[]{expression.toString()},
+        new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.fromDataTypeSV(dataType)});
+    List<Record> records;
+
+    int limit = _distinctAggregationFunction.getLimit();
+    int actualLimit = Math.min(limit, _dictLength);
+
+    // If ORDER BY is not present, we read the first limit values from the dictionary and return.
+    // If ORDER BY is present and the dictionary is sorted, then we read the first/last limit values
+    // from the dictionary. If not sorted, then we read the entire dictionary and return it.
+    if (!_hasOrderBy) {
+      records = new ArrayList<>(actualLimit);
+
+      for (int i = 0; i < actualLimit; i++) {
+        records.add(new Record(new Object[]{_dictionary.getInternal(i)}));
+      }
+    } else {
+      DistinctTable distinctTable = new DistinctTable(dataSchema, _distinctAggregationFunction.getOrderByExpressions(), limit);
+
+      if (_dictionary.isSorted()) {
+        if (_isAscending) {
+          for (int i = 0; i < actualLimit; i++) {
+            distinctTable.addWithOrderBy(new Record(new Object[]{_dictionary.getInternal(i)}));
+          }
+        } else {
+          for (int i = _dictLength - 1; i >= (_dictLength - actualLimit); i--) {
+            distinctTable.addWithOrderBy(new Record(new Object[]{_dictionary.getInternal(i)}));
+          }
+        }
+      } else {
+        for (int i = 0; i < _dictLength; i++) {

Review comment:
       You only need to create main distinct table when dictionary is not sorted. When dictionary is sorted, creating a wrapper distinct table is good enough




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
atris commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666492908



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+    int MAX_INITIAL_CAPACITY = 10000;
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Map<String, Dictionary> _dictionaryMap;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private final IntOpenHashSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Map<String, Dictionary> dictionaryMap, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionaryMap = dictionaryMap;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        String column = _distinctAggregationFunction.getInputExpressions().get(0).getIdentifier();
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        Dictionary dictionary = _dictionaryMap.get(column);
+        int dictionarySize = dictionary.length();
+
+        for (int dictId = 0; dictId < dictionarySize; dictId++) {
+            if (!_hasOrderBy) {
+                _dictIdSet.add(dictId);
+
+                if (_dictIdSet.size() >= limit) {
+                    break;
+                }
+            } else {
+                // We already ascertained that the dictionary is sorted, hence we can use IDs instead of actual values

Review comment:
       That would not work,  since dictionary does not allow us to get dictIds from it directly. We would have to get it from TransformBlock, which does not guarantee order of returned dictIds.




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
atris commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666729330



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";

Review comment:
       I applied the style sheet and it seems to be passing -- what is the formatting change needed here, please?




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
atris commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666472342



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+    int MAX_INITIAL_CAPACITY = 10000;
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Map<String, Dictionary> _dictionaryMap;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private final IntOpenHashSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Map<String, Dictionary> dictionaryMap, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionaryMap = dictionaryMap;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        String column = _distinctAggregationFunction.getInputExpressions().get(0).getIdentifier();
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        Dictionary dictionary = _dictionaryMap.get(column);
+        int dictionarySize = dictionary.length();
+
+        for (int dictId = 0; dictId < dictionarySize; dictId++) {
+            if (!_hasOrderBy) {

Review comment:
       Isnt that what we are doing here?




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f39adfa) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **increase** coverage by `8.07%`.
   > The diff coverage is `84.05%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7141      +/-   ##
   ============================================
   + Coverage     65.43%   73.50%   +8.07%     
     Complexity       92       92              
   ============================================
     Files          1495     1499       +4     
     Lines         73441    73576     +135     
     Branches      10587    10612      +25     
   ============================================
   + Hits          48055    54085    +6030     
   + Misses        21991    15974    -6017     
   - Partials       3395     3517     +122     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | integration | `41.69% <63.76%> (?)` | |
   | unittests | `65.38% <82.60%> (-0.06%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...perator/query/DictionaryBasedDistinctOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9xdWVyeS9EaWN0aW9uYXJ5QmFzZWREaXN0aW5jdE9wZXJhdG9yLmphdmE=) | `80.00% <80.00%> (ø)` | |
   | [...not/core/plan/DictionaryBasedDistinctPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL0RpY3Rpb25hcnlCYXNlZERpc3RpbmN0UGxhbk5vZGUuamF2YQ==) | `83.33% <83.33%> (ø)` | |
   | [...pinot/core/plan/maker/InstancePlanMakerImplV2.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL21ha2VyL0luc3RhbmNlUGxhbk1ha2VySW1wbFYyLmphdmE=) | `90.09% <100.00%> (+12.09%)` | :arrow_up: |
   | [...ctionaryBasedSingleColumnDistinctOnlyExecutor.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9kaWN0aW9uYXJ5L0RpY3Rpb25hcnlCYXNlZFNpbmdsZUNvbHVtbkRpc3RpbmN0T25seUV4ZWN1dG9yLmphdmE=) | `80.00% <0.00%> (-20.00%)` | :arrow_down: |
   | [.../java/org/apache/pinot/spi/filesystem/PinotFS.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZmlsZXN5c3RlbS9QaW5vdEZTLmphdmE=) | `72.22% <0.00%> (-3.97%)` | :arrow_down: |
   | [...transform/function/DateTruncTransformFunction.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vRGF0ZVRydW5jVHJhbnNmb3JtRnVuY3Rpb24uamF2YQ==) | `83.87% <0.00%> (-2.80%)` | :arrow_down: |
   | [...inot/common/function/scalar/DateTimeFunctions.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0RhdGVUaW1lRnVuY3Rpb25zLmphdmE=) | `98.61% <0.00%> (-1.39%)` | :arrow_down: |
   | [...lugin/stream/kinesis/KinesisConnectionHandler.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LWtpbmVzaXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3BsdWdpbi9zdHJlYW0va2luZXNpcy9LaW5lc2lzQ29ubmVjdGlvbkhhbmRsZXIuamF2YQ==) | `20.51% <0.00%> (-0.54%)` | :arrow_down: |
   | [...ava/org/apache/pinot/core/transport/TlsConfig.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS90cmFuc3BvcnQvVGxzQ29uZmlnLmphdmE=) | `94.11% <0.00%> (ø)` | |
   | [...va/org/apache/pinot/spi/utils/CommonConstants.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvdXRpbHMvQ29tbW9uQ29uc3RhbnRzLmphdmE=) | `35.00% <0.00%> (ø)` | |
   | ... and [369 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...f39adfa](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
atris commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666685531



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/plan/DictionaryBasedDistinctPlanNode.java
##########
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.plan;
+
+import org.apache.pinot.core.operator.query.DictionaryBasedDistinctOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+
+/**
+ * Execute a DISTINCT operation using dictionary based plan
+ */
+public class DictionaryBasedDistinctPlanNode implements PlanNode {
+    private final IndexSegment _indexSegment;
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Dictionary _dictionary;
+    private final TransformPlanNode _transformPlanNode;
+
+    /**
+     * Constructor for the class.
+     *
+     * @param indexSegment Segment to process
+     * @param queryContext Query context
+     */
+    public DictionaryBasedDistinctPlanNode(IndexSegment indexSegment, QueryContext queryContext, Dictionary dictionary) {
+        _indexSegment = indexSegment;
+        AggregationFunction[] aggregationFunctions = queryContext.getAggregationFunctions();
+
+        assert aggregationFunctions != null && aggregationFunctions.length == 1
+                && aggregationFunctions[0] instanceof DistinctAggregationFunction;
+
+        _distinctAggregationFunction = (DistinctAggregationFunction) aggregationFunctions[0];
+
+        _dictionary = dictionary;
+
+        _transformPlanNode =

Review comment:
       We need the transform plan node to get the data type during result construction




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (76fd4ed) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **decrease** coverage by `0.03%`.
   > The diff coverage is `84.37%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7141      +/-   ##
   ============================================
   - Coverage     65.43%   65.40%   -0.04%     
     Complexity       92       92              
   ============================================
     Files          1495     1499       +4     
     Lines         73441    73570     +129     
     Branches      10587    10612      +25     
   ============================================
   + Hits          48055    48117      +62     
   - Misses        21991    22052      +61     
   - Partials       3395     3401       +6     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `65.40% <84.37%> (-0.04%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...perator/query/DictionaryBasedDistinctOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9xdWVyeS9EaWN0aW9uYXJ5QmFzZWREaXN0aW5jdE9wZXJhdG9yLmphdmE=) | `82.50% <82.50%> (ø)` | |
   | [...not/core/plan/DictionaryBasedDistinctPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL0RpY3Rpb25hcnlCYXNlZERpc3RpbmN0UGxhbk5vZGUuamF2YQ==) | `83.33% <83.33%> (ø)` | |
   | [...pinot/core/plan/maker/InstancePlanMakerImplV2.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL21ha2VyL0luc3RhbmNlUGxhbk1ha2VySW1wbFYyLmphdmE=) | `79.27% <91.66%> (+1.27%)` | :arrow_up: |
   | [...ctionaryBasedSingleColumnDistinctOnlyExecutor.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9kaWN0aW9uYXJ5L0RpY3Rpb25hcnlCYXNlZFNpbmdsZUNvbHVtbkRpc3RpbmN0T25seUV4ZWN1dG9yLmphdmE=) | `20.00% <0.00%> (-80.00%)` | :arrow_down: |
   | [.../java/org/apache/pinot/spi/filesystem/PinotFS.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZmlsZXN5c3RlbS9QaW5vdEZTLmphdmE=) | `72.22% <0.00%> (-3.97%)` | :arrow_down: |
   | [...transform/function/DateTruncTransformFunction.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vRGF0ZVRydW5jVHJhbnNmb3JtRnVuY3Rpb24uamF2YQ==) | `83.87% <0.00%> (-2.80%)` | :arrow_down: |
   | [.../pinot/core/query/scheduler/PriorityScheduler.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9zY2hlZHVsZXIvUHJpb3JpdHlTY2hlZHVsZXIuamF2YQ==) | `80.82% <0.00%> (-2.74%)` | :arrow_down: |
   | [.../java/org/apache/pinot/spi/data/TimeFieldSpec.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9UaW1lRmllbGRTcGVjLmphdmE=) | `88.63% <0.00%> (-2.28%)` | :arrow_down: |
   | [...inot/common/function/scalar/DateTimeFunctions.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0RhdGVUaW1lRnVuY3Rpb25zLmphdmE=) | `98.61% <0.00%> (-1.39%)` | :arrow_down: |
   | [...oller/api/resources/PinotTableRestletResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1Bpbm90VGFibGVSZXN0bGV0UmVzb3VyY2UuamF2YQ==) | `53.55% <0.00%> (-1.15%)` | :arrow_down: |
   | ... and [25 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...76fd4ed](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on pull request #7141: Support Dictionary Based Plans For DISTINCT

Posted by GitBox <gi...@apache.org>.
atris commented on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876233535


   @mayankshriv @Jackie-Jiang Please review


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666498797



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+    int MAX_INITIAL_CAPACITY = 10000;
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Map<String, Dictionary> _dictionaryMap;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private final IntOpenHashSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Map<String, Dictionary> dictionaryMap, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionaryMap = dictionaryMap;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        String column = _distinctAggregationFunction.getInputExpressions().get(0).getIdentifier();
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        Dictionary dictionary = _dictionaryMap.get(column);
+        int dictionarySize = dictionary.length();
+
+        for (int dictId = 0; dictId < dictionarySize; dictId++) {
+            if (!_hasOrderBy) {
+                _dictIdSet.add(dictId);
+
+                if (_dictIdSet.size() >= limit) {
+                    break;
+                }
+            } else {
+                // We already ascertained that the dictionary is sorted, hence we can use IDs instead of actual values

Review comment:
       I don't follow. dictId is simply the index within dictionary. E.g. for ascending order of limit 10, just read dictId 0-9 from the dictionary and construct the DistinctTable. No need to scan the whole dictionary




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666499698



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+    int MAX_INITIAL_CAPACITY = 10000;
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Map<String, Dictionary> _dictionaryMap;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private final IntOpenHashSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Map<String, Dictionary> dictionaryMap, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionaryMap = dictionaryMap;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        String column = _distinctAggregationFunction.getInputExpressions().get(0).getIdentifier();
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        Dictionary dictionary = _dictionaryMap.get(column);
+        int dictionarySize = dictionary.length();
+
+        for (int dictId = 0; dictId < dictionarySize; dictId++) {
+            if (!_hasOrderBy) {

Review comment:
       No, currently we scan the whole dictionary. Instead, we only need to scan `limit` number of entries in the dictionary




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
atris commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666685741



##########
File path: pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
##########
@@ -245,12 +245,14 @@ public void testSingleColumnDistinctOnlyInnerSegment()
       // String columns
       //@formatter:off
       List<String> queries = Arrays
-          .asList("SELECT DISTINCT(stringColumn) FROM testTable", "SELECT DISTINCT(rawStringColumn) FROM testTable");
+          .asList("SELECT DISTINCT(stringColumn) FROM testTable");

Review comment:
       We need the changes since the order of results in absence of ORDER BY is not consistent between segment reads and dictionary reads.




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r667214214



##########
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 getDistinctPlanNode(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) {

Review comment:
       Per the test failure, we need to read the data type from the data source by calling `DataSource.getDataSourceMetadata().getDataType()`. The value type from dictionary is the internal stored type




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
atris commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666729703



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+    int MAX_INITIAL_CAPACITY = 10000;
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Map<String, Dictionary> _dictionaryMap;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private final IntOpenHashSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Map<String, Dictionary> dictionaryMap, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionaryMap = dictionaryMap;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        String column = _distinctAggregationFunction.getInputExpressions().get(0).getIdentifier();
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        Dictionary dictionary = _dictionaryMap.get(column);
+        int dictionarySize = dictionary.length();
+
+        for (int dictId = 0; dictId < dictionarySize; dictId++) {
+            if (!_hasOrderBy) {
+                _dictIdSet.add(dictId);
+
+                if (_dictIdSet.size() >= limit) {
+                    break;
+                }
+            } else {
+                // We already ascertained that the dictionary is sorted, hence we can use IDs instead of actual values

Review comment:
       Yeah, as discussed, I was not aware that dictIDs are strictly in the order of 0 - dictionary limit. Changed now, thanks




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang merged pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang merged pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141


   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e5562bc) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **decrease** coverage by `0.03%`.
   > The diff coverage is `81.57%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7141      +/-   ##
   ============================================
   - Coverage     65.43%   65.39%   -0.04%     
     Complexity       92       92              
   ============================================
     Files          1495     1499       +4     
     Lines         73441    73582     +141     
     Branches      10587    10619      +32     
   ============================================
   + Hits          48055    48122      +67     
   - Misses        21991    22059      +68     
   - Partials       3395     3401       +6     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `65.39% <81.57%> (-0.04%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...perator/query/DictionaryBasedDistinctOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9xdWVyeS9EaWN0aW9uYXJ5QmFzZWREaXN0aW5jdE9wZXJhdG9yLmphdmE=) | `78.84% <78.84%> (ø)` | |
   | [...not/core/plan/DictionaryBasedDistinctPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL0RpY3Rpb25hcnlCYXNlZERpc3RpbmN0UGxhbk5vZGUuamF2YQ==) | `83.33% <83.33%> (ø)` | |
   | [...pinot/core/plan/maker/InstancePlanMakerImplV2.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL21ha2VyL0luc3RhbmNlUGxhbk1ha2VySW1wbFYyLmphdmE=) | `79.27% <91.66%> (+1.27%)` | :arrow_up: |
   | [...ctionaryBasedSingleColumnDistinctOnlyExecutor.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9kaWN0aW9uYXJ5L0RpY3Rpb25hcnlCYXNlZFNpbmdsZUNvbHVtbkRpc3RpbmN0T25seUV4ZWN1dG9yLmphdmE=) | `20.00% <0.00%> (-80.00%)` | :arrow_down: |
   | [.../startree/v2/builder/OffHeapSingleTreeBuilder.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9zdGFydHJlZS92Mi9idWlsZGVyL09mZkhlYXBTaW5nbGVUcmVlQnVpbGRlci5qYXZh) | `87.42% <0.00%> (-4.20%)` | :arrow_down: |
   | [.../java/org/apache/pinot/spi/filesystem/PinotFS.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZmlsZXN5c3RlbS9QaW5vdEZTLmphdmE=) | `72.22% <0.00%> (-3.97%)` | :arrow_down: |
   | [...transform/function/DateTruncTransformFunction.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vRGF0ZVRydW5jVHJhbnNmb3JtRnVuY3Rpb24uamF2YQ==) | `83.87% <0.00%> (-2.80%)` | :arrow_down: |
   | [...inot/common/function/scalar/DateTimeFunctions.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0RhdGVUaW1lRnVuY3Rpb25zLmphdmE=) | `98.61% <0.00%> (-1.39%)` | :arrow_down: |
   | [...oller/api/resources/PinotTableRestletResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1Bpbm90VGFibGVSZXN0bGV0UmVzb3VyY2UuamF2YQ==) | `53.55% <0.00%> (-1.15%)` | :arrow_down: |
   | [...main/java/org/apache/pinot/spi/data/FieldSpec.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9GaWVsZFNwZWMuamF2YQ==) | `82.44% <0.00%> (-0.54%)` | :arrow_down: |
   | ... and [26 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...e5562bc](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r667126687



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Dictionary _dictionary;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+
+    private boolean _hasOrderBy;
+    private boolean _isAscending;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Dictionary dictionary, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionary = dictionary;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+
+            _isAscending = orderByExpressionContext.isAsc();
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        DistinctTable distinctTable = buildResult();
+
+        return new IntermediateResultsBlock(new AggregationFunction[]{_distinctAggregationFunction},
+                Collections.singletonList(distinctTable), false);
+    }
+
+    /**
+     * Build the final result for this operation
+     */
+    private DistinctTable buildResult() {
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        List<ExpressionContext> expressions = _distinctAggregationFunction.getInputExpressions();
+        ExpressionContext expression = expressions.get(0);
+        FieldSpec.DataType dataType = _transformOperator.getResultMetadata(expression).getDataType();
+
+        DataSchema dataSchema = new DataSchema(new String[]{expression.toString()},
+                new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.fromDataTypeSV(dataType)});
+        List<Record> records;
+
+        int limit = _distinctAggregationFunction.getLimit();
+        int actualLimit = Math.min(limit, _dictionary.length());
+
+        // If ORDER BY is not present, we read the first limit values from the dictionary and return.
+        // If ORDER BY is present and the dictionary is sorted, then we read the first/last limit values
+        // from the dictionary. If not sorted, then we read the entire dictionary and return it.
+        if (!_hasOrderBy) {
+            records = new ArrayList<>(actualLimit);
+
+            for (int i = 0; i < actualLimit; i++) {
+                records.add(new Record(new Object[]{_dictionary.getInternal(i)}));
+            }
+        } else {
+            if (_dictionary.isSorted()) {
+                records = new ArrayList<>(actualLimit);
+                if (_isAscending) {
+                    for (int i = 0; i < actualLimit; i++) {
+                        records.add(new Record(new Object[]{_dictionary.getInternal(i)}));
+                    }
+                } else {
+                    for (int i = _dictionary.length() - 1; i >= (_dictionary.length() - actualLimit); i--) {
+                        records.add(new Record(new Object[]{_dictionary.getInternal(i)}));
+                    }
+                }
+            } else {
+                records = new ArrayList<>(_dictionary.length());

Review comment:
       We should insert records into the `DistinctTable`. `DistinctTable` will only keep the top records.
   ```suggestion
     DistinctTable distinctTable = new DistinctTable(dataSchema, _distinctAggregationFunction.getOrderByExpressions(), limit);
     for (int i = 0; i < dictionarySize; i++) {
       distinctTable.addWithOrderBy(new Record(new Object[]{_dictionary.getInternal(i)}));
     }
   ```

##########
File path: pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
##########
@@ -245,7 +245,34 @@ public void testSingleColumnDistinctOnlyInnerSegment()
       // String columns
       //@formatter:off
       List<String> queries = Arrays

Review comment:
       Since there is only one query, let's use a single value instead of a list. We can also remove the comment to turn off/on the formatter

##########
File path: pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
##########
@@ -245,7 +245,34 @@ public void testSingleColumnDistinctOnlyInnerSegment()
       // String columns
       //@formatter:off
       List<String> queries = Arrays
-          .asList("SELECT DISTINCT(stringColumn) FROM testTable", "SELECT DISTINCT(rawStringColumn) FROM testTable");
+          .asList("SELECT DISTINCT(stringColumn) FROM testTable");
+      //@formatter:on
+      Set<Integer> expectedValues =
+          new HashSet<>(Arrays.asList(0, 16, 17, 1, 10, 11, 12, 13, 14, 15));

Review comment:
       (nit) for clarity (alphabetical order)
   ```suggestion
             new HashSet<>(Arrays.asList(0, 1, 10, 11, 12, 13, 14, 15, 16, 17));
   ```

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";

Review comment:
       I don't think it takes effect. The indentation should be 2 spaces instead of 4

##########
File path: pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
##########
@@ -245,7 +245,34 @@ public void testSingleColumnDistinctOnlyInnerSegment()
       // String columns
       //@formatter:off
       List<String> queries = Arrays
-          .asList("SELECT DISTINCT(stringColumn) FROM testTable", "SELECT DISTINCT(rawStringColumn) FROM testTable");
+          .asList("SELECT DISTINCT(stringColumn) FROM testTable");
+      //@formatter:on
+      Set<Integer> expectedValues =
+          new HashSet<>(Arrays.asList(0, 16, 17, 1, 10, 11, 12, 13, 14, 15));
+      for (String query : queries) {
+        DistinctTable pqlDistinctTable = getDistinctTableInnerSegment(query, true);
+        DistinctTable pqlDistinctTable2 = DistinctTable.fromByteBuffer(ByteBuffer.wrap(pqlDistinctTable.toBytes()));
+        DistinctTable sqlDistinctTable = getDistinctTableInnerSegment(query, false);
+        DistinctTable sqlDistinctTable2 = DistinctTable.fromByteBuffer(ByteBuffer.wrap(sqlDistinctTable.toBytes()));
+        for (DistinctTable distinctTable : Arrays
+            .asList(pqlDistinctTable, pqlDistinctTable2, sqlDistinctTable, sqlDistinctTable2)) {
+          assertEquals(distinctTable.size(), 10);
+          Set<Integer> actualValues = new HashSet<>();
+          for (Record record : distinctTable.getRecords()) {
+            Object[] values = record.getValues();
+            assertEquals(values.length, 1);
+            assertTrue(values[0] instanceof String);
+            actualValues.add(Integer.parseInt((String) values[0]));
+          }
+          assertEquals(actualValues, expectedValues);
+        }
+      }
+    }
+    {
+      // String columns
+      //@formatter:off
+      List<String> queries = Arrays

Review comment:
       Same here, use single value

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Dictionary _dictionary;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+
+    private boolean _hasOrderBy;
+    private boolean _isAscending;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Dictionary dictionary, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionary = dictionary;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+
+            _isAscending = orderByExpressionContext.isAsc();
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        DistinctTable distinctTable = buildResult();
+
+        return new IntermediateResultsBlock(new AggregationFunction[]{_distinctAggregationFunction},
+                Collections.singletonList(distinctTable), false);
+    }
+
+    /**
+     * Build the final result for this operation
+     */
+    private DistinctTable buildResult() {
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        List<ExpressionContext> expressions = _distinctAggregationFunction.getInputExpressions();
+        ExpressionContext expression = expressions.get(0);
+        FieldSpec.DataType dataType = _transformOperator.getResultMetadata(expression).getDataType();
+
+        DataSchema dataSchema = new DataSchema(new String[]{expression.toString()},
+                new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.fromDataTypeSV(dataType)});
+        List<Record> records;
+
+        int limit = _distinctAggregationFunction.getLimit();
+        int actualLimit = Math.min(limit, _dictionary.length());

Review comment:
       Let's cache the value of `_dictionary.length()` into a local variable

##########
File path: pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
##########
@@ -245,12 +245,14 @@ public void testSingleColumnDistinctOnlyInnerSegment()
       // String columns
       //@formatter:off
       List<String> queries = Arrays
-          .asList("SELECT DISTINCT(stringColumn) FROM testTable", "SELECT DISTINCT(rawStringColumn) FROM testTable");
+          .asList("SELECT DISTINCT(stringColumn) FROM testTable");

Review comment:
       I see. This is caused by sorting in alphabetical order. Can you please add some comments explaining the reason?

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/plan/DictionaryBasedDistinctPlanNode.java
##########
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.plan;
+
+import org.apache.pinot.core.operator.query.DictionaryBasedDistinctOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+
+/**
+ * Execute a DISTINCT operation using dictionary based plan
+ */
+public class DictionaryBasedDistinctPlanNode implements PlanNode {
+    private final IndexSegment _indexSegment;
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Dictionary _dictionary;
+    private final TransformPlanNode _transformPlanNode;
+
+    /**
+     * Constructor for the class.
+     *
+     * @param indexSegment Segment to process
+     * @param queryContext Query context
+     */
+    public DictionaryBasedDistinctPlanNode(IndexSegment indexSegment, QueryContext queryContext, Dictionary dictionary) {
+        _indexSegment = indexSegment;
+        AggregationFunction[] aggregationFunctions = queryContext.getAggregationFunctions();
+
+        assert aggregationFunctions != null && aggregationFunctions.length == 1
+                && aggregationFunctions[0] instanceof DistinctAggregationFunction;
+
+        _distinctAggregationFunction = (DistinctAggregationFunction) aggregationFunctions[0];
+
+        _dictionary = dictionary;
+
+        _transformPlanNode =

Review comment:
       Data type is available in by `Dictionary.getValueType()`. We want to short-circuit all the lower level operators




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] atris commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
atris commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666684255



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,176 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntSet;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.blocks.TransformBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+import static org.apache.pinot.core.query.distinct.DistinctExecutor.MAX_INITIAL_CAPACITY;
+
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Dictionary _dictionary;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private IntSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Dictionary dictionary, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionary = dictionary;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        ExpressionContext expression = _distinctAggregationFunction.getInputExpressions().get(0);
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        TransformBlock transformBlock = _transformOperator.nextBlock();

Review comment:
       Yes, I was not aware that dictionary (when sorted) has IDs strictly in the ascending order of numbers (i.e. starting dictID will always be 0, next 1 ...). Thanks for highlighting that. Fixed per your suggestions.
   
   For the no order by case, we dont really have an order defined in which we read values from the underlying storage (so the order of values read from segment vs dictionary can be different). Hence, need to change DistinctQueriesTest to reflect the same.




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666499698



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+    int MAX_INITIAL_CAPACITY = 10000;
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Map<String, Dictionary> _dictionaryMap;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private final IntOpenHashSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Map<String, Dictionary> dictionaryMap, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionaryMap = dictionaryMap;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        String column = _distinctAggregationFunction.getInputExpressions().get(0).getIdentifier();
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        Dictionary dictionary = _dictionaryMap.get(column);
+        int dictionarySize = dictionary.length();
+
+        for (int dictId = 0; dictId < dictionarySize; dictId++) {
+            if (!_hasOrderBy) {

Review comment:
       We can avoid creating the separate set and directly read the first `min(dictionarySize, limit)` entries from the dictionary




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666601239



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";

Review comment:
       The format is still incorrect

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/plan/DictionaryBasedDistinctPlanNode.java
##########
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.plan;
+
+import org.apache.pinot.core.operator.query.DictionaryBasedDistinctOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+
+/**
+ * Execute a DISTINCT operation using dictionary based plan
+ */
+public class DictionaryBasedDistinctPlanNode implements PlanNode {
+    private final IndexSegment _indexSegment;
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Dictionary _dictionary;
+    private final TransformPlanNode _transformPlanNode;
+
+    /**
+     * Constructor for the class.
+     *
+     * @param indexSegment Segment to process
+     * @param queryContext Query context
+     */
+    public DictionaryBasedDistinctPlanNode(IndexSegment indexSegment, QueryContext queryContext, Dictionary dictionary) {
+        _indexSegment = indexSegment;
+        AggregationFunction[] aggregationFunctions = queryContext.getAggregationFunctions();
+
+        assert aggregationFunctions != null && aggregationFunctions.length == 1
+                && aggregationFunctions[0] instanceof DistinctAggregationFunction;
+
+        _distinctAggregationFunction = (DistinctAggregationFunction) aggregationFunctions[0];
+
+        _dictionary = dictionary;
+
+        _transformPlanNode =

Review comment:
       We don't need to construct the transform plan node. Dictionary itself is enough to solve the query

##########
File path: pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
##########
@@ -245,12 +245,14 @@ public void testSingleColumnDistinctOnlyInnerSegment()
       // String columns
       //@formatter:off
       List<String> queries = Arrays
-          .asList("SELECT DISTINCT(stringColumn) FROM testTable", "SELECT DISTINCT(rawStringColumn) FROM testTable");
+          .asList("SELECT DISTINCT(stringColumn) FROM testTable");

Review comment:
       Revert the change in this file

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,176 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntSet;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.blocks.TransformBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+import static org.apache.pinot.core.query.distinct.DistinctExecutor.MAX_INITIAL_CAPACITY;
+
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Dictionary _dictionary;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private IntSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Dictionary dictionary, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionary = dictionary;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        ExpressionContext expression = _distinctAggregationFunction.getInputExpressions().get(0);
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        TransformBlock transformBlock = _transformOperator.nextBlock();

Review comment:
       We don't need to read dictIds from the transform block.
   
   - If there is no order-by, read the first `min(limit, dictionarySize)` values from the dictionary
   - If there is order-by
     - If dictionary is sorted, read the first if asc, last if desc `min(limit, dictionarySize)` values from the dictionary
     - If dictionary is not sorted, dump all values in the dictionary into the `DistinctTable`




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (95a5302) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **decrease** coverage by `23.69%`.
   > The diff coverage is `67.18%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@              Coverage Diff              @@
   ##             master    #7141       +/-   ##
   =============================================
   - Coverage     65.43%   41.73%   -23.70%     
   + Complexity       92        7       -85     
   =============================================
     Files          1495     1499        +4     
     Lines         73441    73570      +129     
     Branches      10587    10612       +25     
   =============================================
   - Hits          48055    30704    -17351     
   - Misses        21991    40267    +18276     
   + Partials       3395     2599      -796     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | integration | `41.73% <67.18%> (?)` | |
   | unittests | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...perator/query/DictionaryBasedDistinctOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9xdWVyeS9EaWN0aW9uYXJ5QmFzZWREaXN0aW5jdE9wZXJhdG9yLmphdmE=) | `55.00% <55.00%> (ø)` | |
   | [...not/core/plan/DictionaryBasedDistinctPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL0RpY3Rpb25hcnlCYXNlZERpc3RpbmN0UGxhbk5vZGUuamF2YQ==) | `83.33% <83.33%> (ø)` | |
   | [...pinot/core/plan/maker/InstancePlanMakerImplV2.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL21ha2VyL0luc3RhbmNlUGxhbk1ha2VySW1wbFYyLmphdmE=) | `72.97% <91.66%> (-5.03%)` | :arrow_down: |
   | [...c/main/java/org/apache/pinot/common/tier/Tier.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdGllci9UaWVyLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...ava/org/apache/pinot/spi/data/MetricFieldSpec.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9NZXRyaWNGaWVsZFNwZWMuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...va/org/apache/pinot/spi/utils/BigDecimalUtils.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvdXRpbHMvQmlnRGVjaW1hbFV0aWxzLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...java/org/apache/pinot/common/tier/TierFactory.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdGllci9UaWVyRmFjdG9yeS5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...a/org/apache/pinot/spi/config/table/TableType.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvY29uZmlnL3RhYmxlL1RhYmxlVHlwZS5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...a/org/apache/pinot/spi/data/DateTimeFieldSpec.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9EYXRlVGltZUZpZWxkU3BlYy5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [.../org/apache/pinot/spi/data/DimensionFieldSpec.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9EaW1lbnNpb25GaWVsZFNwZWMuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | ... and [1138 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...95a5302](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter commented on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9db1b41) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **decrease** coverage by `0.03%`.
   > The diff coverage is `88.88%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7141      +/-   ##
   ============================================
   - Coverage     65.43%   65.39%   -0.04%     
     Complexity       92       92              
   ============================================
     Files          1495     1499       +4     
     Lines         73441    73590     +149     
     Branches      10587    10616      +29     
   ============================================
   + Hits          48055    48125      +70     
   - Misses        21991    22064      +73     
   - Partials       3395     3401       +6     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `65.39% <88.88%> (-0.04%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...pinot/core/plan/maker/InstancePlanMakerImplV2.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL21ha2VyL0luc3RhbmNlUGxhbk1ha2VySW1wbFYyLmphdmE=) | `78.37% <83.33%> (+0.37%)` | :arrow_up: |
   | [...not/core/plan/DictionaryBasedDistinctPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL0RpY3Rpb25hcnlCYXNlZERpc3RpbmN0UGxhbk5vZGUuamF2YQ==) | `85.71% <85.71%> (ø)` | |
   | [...perator/query/DictionaryBasedDistinctOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9xdWVyeS9EaWN0aW9uYXJ5QmFzZWREaXN0aW5jdE9wZXJhdG9yLmphdmE=) | `90.90% <90.90%> (ø)` | |
   | [...ctionaryBasedSingleColumnDistinctOnlyExecutor.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9kaWN0aW9uYXJ5L0RpY3Rpb25hcnlCYXNlZFNpbmdsZUNvbHVtbkRpc3RpbmN0T25seUV4ZWN1dG9yLmphdmE=) | `20.00% <0.00%> (-80.00%)` | :arrow_down: |
   | [.../startree/v2/builder/OffHeapSingleTreeBuilder.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9zdGFydHJlZS92Mi9idWlsZGVyL09mZkhlYXBTaW5nbGVUcmVlQnVpbGRlci5qYXZh) | `87.42% <0.00%> (-4.20%)` | :arrow_down: |
   | [...lix/core/realtime/PinotRealtimeSegmentManager.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL3JlYWx0aW1lL1Bpbm90UmVhbHRpbWVTZWdtZW50TWFuYWdlci5qYXZh) | `75.89% <0.00%> (-3.59%)` | :arrow_down: |
   | [...transform/function/DateTruncTransformFunction.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vRGF0ZVRydW5jVHJhbnNmb3JtRnVuY3Rpb24uamF2YQ==) | `83.87% <0.00%> (-2.80%)` | :arrow_down: |
   | [...inot/common/function/scalar/DateTimeFunctions.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0RhdGVUaW1lRnVuY3Rpb25zLmphdmE=) | `98.61% <0.00%> (-1.39%)` | :arrow_down: |
   | [...oller/api/resources/PinotTableRestletResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1Bpbm90VGFibGVSZXN0bGV0UmVzb3VyY2UuamF2YQ==) | `53.55% <0.00%> (-1.15%)` | :arrow_down: |
   | [...lix/core/minion/PinotHelixTaskResourceManager.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL21pbmlvbi9QaW5vdEhlbGl4VGFza1Jlc291cmNlTWFuYWdlci5qYXZh) | `2.66% <0.00%> (-0.28%)` | :arrow_down: |
   | ... and [13 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...9db1b41](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9528930) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **decrease** coverage by `0.04%`.
   > The diff coverage is `82.35%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7141      +/-   ##
   ============================================
   - Coverage     65.43%   65.38%   -0.05%     
     Complexity       92       92              
   ============================================
     Files          1495     1499       +4     
     Lines         73441    73574     +133     
     Branches      10587    10612      +25     
   ============================================
   + Hits          48055    48110      +55     
   - Misses        21991    22065      +74     
   - Partials       3395     3399       +4     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `65.38% <82.35%> (-0.05%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...not/core/plan/DictionaryBasedDistinctPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL0RpY3Rpb25hcnlCYXNlZERpc3RpbmN0UGxhbk5vZGUuamF2YQ==) | `80.00% <80.00%> (ø)` | |
   | [...perator/query/DictionaryBasedDistinctOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9xdWVyeS9EaWN0aW9uYXJ5QmFzZWREaXN0aW5jdE9wZXJhdG9yLmphdmE=) | `80.43% <80.43%> (ø)` | |
   | [...pinot/core/plan/maker/InstancePlanMakerImplV2.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL21ha2VyL0luc3RhbmNlUGxhbk1ha2VySW1wbFYyLmphdmE=) | `79.27% <91.66%> (+1.27%)` | :arrow_up: |
   | [...ctionaryBasedSingleColumnDistinctOnlyExecutor.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9kaWN0aW9uYXJ5L0RpY3Rpb25hcnlCYXNlZFNpbmdsZUNvbHVtbkRpc3RpbmN0T25seUV4ZWN1dG9yLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [.../startree/v2/builder/OffHeapSingleTreeBuilder.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9zdGFydHJlZS92Mi9idWlsZGVyL09mZkhlYXBTaW5nbGVUcmVlQnVpbGRlci5qYXZh) | `87.42% <0.00%> (-4.20%)` | :arrow_down: |
   | [.../java/org/apache/pinot/spi/filesystem/PinotFS.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZmlsZXN5c3RlbS9QaW5vdEZTLmphdmE=) | `72.22% <0.00%> (-3.97%)` | :arrow_down: |
   | [...transform/function/DateTruncTransformFunction.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vRGF0ZVRydW5jVHJhbnNmb3JtRnVuY3Rpb24uamF2YQ==) | `83.87% <0.00%> (-2.80%)` | :arrow_down: |
   | [...t/core/query/distinct/DistinctExecutorFactory.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9EaXN0aW5jdEV4ZWN1dG9yRmFjdG9yeS5qYXZh) | `79.16% <0.00%> (-2.78%)` | :arrow_down: |
   | [.../java/org/apache/pinot/spi/data/TimeFieldSpec.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9UaW1lRmllbGRTcGVjLmphdmE=) | `88.63% <0.00%> (-2.28%)` | :arrow_down: |
   | [...inot/common/function/scalar/DateTimeFunctions.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0RhdGVUaW1lRnVuY3Rpb25zLmphdmE=) | `98.61% <0.00%> (-1.39%)` | :arrow_down: |
   | ... and [26 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...9528930](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (1f8a1fb) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **decrease** coverage by `23.80%`.
   > The diff coverage is `31.85%`.
   
   > :exclamation: Current head 1f8a1fb differs from pull request most recent head 9528930. Consider uploading reports for the commit 9528930 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@              Coverage Diff              @@
   ##             master    #7141       +/-   ##
   =============================================
   - Coverage     65.43%   41.62%   -23.81%     
   + Complexity       92        7       -85     
   =============================================
     Files          1495     1499        +4     
     Lines         73441    73574      +133     
     Branches      10587    10612       +25     
   =============================================
   - Hits          48055    30628    -17427     
   - Misses        21991    40350    +18359     
   + Partials       3395     2596      -799     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | integration | `41.62% <31.85%> (?)` | |
   | unittests | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...n/java/org/apache/pinot/client/ExecutionStats.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY2xpZW50cy9waW5vdC1qYXZhLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY2xpZW50L0V4ZWN1dGlvblN0YXRzLmphdmE=) | `8.88% <ø> (-60.00%)` | :arrow_down: |
   | [...inot/common/function/scalar/DateTimeFunctions.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0RhdGVUaW1lRnVuY3Rpb25zLmphdmE=) | `6.94% <0.00%> (-93.06%)` | :arrow_down: |
   | [...a/org/apache/pinot/common/metrics/MinionGauge.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25HYXVnZS5qYXZh) | `90.00% <ø> (ø)` | |
   | [...a/org/apache/pinot/common/metrics/MinionMeter.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25NZXRlci5qYXZh) | `100.00% <ø> (ø)` | |
   | [...org/apache/pinot/common/metrics/MinionMetrics.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25NZXRyaWNzLmphdmE=) | `57.14% <ø> (ø)` | |
   | [.../apache/pinot/common/metrics/MinionQueryPhase.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25RdWVyeVBoYXNlLmphdmE=) | `100.00% <ø> (ø)` | |
   | [...a/org/apache/pinot/common/metrics/MinionTimer.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25UaW1lci5qYXZh) | `0.00% <ø> (ø)` | |
   | [...che/pinot/controller/api/debug/TableDebugInfo.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvZGVidWcvVGFibGVEZWJ1Z0luZm8uamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...oller/api/resources/PinotTableRestletResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1Bpbm90VGFibGVSZXN0bGV0UmVzb3VyY2UuamF2YQ==) | `27.19% <0.00%> (-27.51%)` | :arrow_down: |
   | [...roller/api/resources/PinotTaskRestletResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1Bpbm90VGFza1Jlc3RsZXRSZXNvdXJjZS5qYXZh) | `0.00% <0.00%> (ø)` | |
   | ... and [1151 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...9528930](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e5562bc) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **increase** coverage by `8.04%`.
   > The diff coverage is `82.89%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7141      +/-   ##
   ============================================
   + Coverage     65.43%   73.47%   +8.04%     
     Complexity       92       92              
   ============================================
     Files          1495     1499       +4     
     Lines         73441    73582     +141     
     Branches      10587    10619      +32     
   ============================================
   + Hits          48055    54068    +6013     
   + Misses        21991    15987    -6004     
   - Partials       3395     3527     +132     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | integration | `41.59% <64.47%> (?)` | |
   | unittests | `65.39% <81.57%> (-0.04%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...perator/query/DictionaryBasedDistinctOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9xdWVyeS9EaWN0aW9uYXJ5QmFzZWREaXN0aW5jdE9wZXJhdG9yLmphdmE=) | `78.84% <78.84%> (ø)` | |
   | [...not/core/plan/DictionaryBasedDistinctPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL0RpY3Rpb25hcnlCYXNlZERpc3RpbmN0UGxhbk5vZGUuamF2YQ==) | `83.33% <83.33%> (ø)` | |
   | [...pinot/core/plan/maker/InstancePlanMakerImplV2.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL21ha2VyL0luc3RhbmNlUGxhbk1ha2VySW1wbFYyLmphdmE=) | `90.09% <100.00%> (+12.09%)` | :arrow_up: |
   | [...ctionaryBasedSingleColumnDistinctOnlyExecutor.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9kaWN0aW9uYXJ5L0RpY3Rpb25hcnlCYXNlZFNpbmdsZUNvbHVtbkRpc3RpbmN0T25seUV4ZWN1dG9yLmphdmE=) | `80.00% <0.00%> (-20.00%)` | :arrow_down: |
   | [.../java/org/apache/pinot/spi/filesystem/PinotFS.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZmlsZXN5c3RlbS9QaW5vdEZTLmphdmE=) | `72.22% <0.00%> (-3.97%)` | :arrow_down: |
   | [...transform/function/DateTruncTransformFunction.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vRGF0ZVRydW5jVHJhbnNmb3JtRnVuY3Rpb24uamF2YQ==) | `83.87% <0.00%> (-2.80%)` | :arrow_down: |
   | [...inot/common/function/scalar/DateTimeFunctions.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0RhdGVUaW1lRnVuY3Rpb25zLmphdmE=) | `98.61% <0.00%> (-1.39%)` | :arrow_down: |
   | [...main/java/org/apache/pinot/spi/data/FieldSpec.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9GaWVsZFNwZWMuamF2YQ==) | `82.44% <0.00%> (-0.54%)` | :arrow_down: |
   | [...ava/org/apache/pinot/core/transport/TlsConfig.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS90cmFuc3BvcnQvVGxzQ29uZmlnLmphdmE=) | `94.11% <0.00%> (ø)` | |
   | [...va/org/apache/pinot/spi/utils/CommonConstants.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvdXRpbHMvQ29tbW9uQ29uc3RhbnRzLmphdmE=) | `35.00% <0.00%> (ø)` | |
   | ... and [370 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...e5562bc](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f39adfa) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **decrease** coverage by `0.05%`.
   > The diff coverage is `82.60%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7141      +/-   ##
   ============================================
   - Coverage     65.43%   65.38%   -0.06%     
     Complexity       92       92              
   ============================================
     Files          1495     1499       +4     
     Lines         73441    73576     +135     
     Branches      10587    10612      +25     
   ============================================
   + Hits          48055    48106      +51     
   - Misses        21991    22068      +77     
   - Partials       3395     3402       +7     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `65.38% <82.60%> (-0.06%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...perator/query/DictionaryBasedDistinctOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9xdWVyeS9EaWN0aW9uYXJ5QmFzZWREaXN0aW5jdE9wZXJhdG9yLmphdmE=) | `80.00% <80.00%> (ø)` | |
   | [...not/core/plan/DictionaryBasedDistinctPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL0RpY3Rpb25hcnlCYXNlZERpc3RpbmN0UGxhbk5vZGUuamF2YQ==) | `83.33% <83.33%> (ø)` | |
   | [...pinot/core/plan/maker/InstancePlanMakerImplV2.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL21ha2VyL0luc3RhbmNlUGxhbk1ha2VySW1wbFYyLmphdmE=) | `79.27% <91.66%> (+1.27%)` | :arrow_up: |
   | [...ctionaryBasedSingleColumnDistinctOnlyExecutor.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9kaWN0aW9uYXJ5L0RpY3Rpb25hcnlCYXNlZFNpbmdsZUNvbHVtbkRpc3RpbmN0T25seUV4ZWN1dG9yLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...lix/core/realtime/PinotRealtimeSegmentManager.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL3JlYWx0aW1lL1Bpbm90UmVhbHRpbWVTZWdtZW50TWFuYWdlci5qYXZh) | `74.87% <0.00%> (-4.62%)` | :arrow_down: |
   | [.../java/org/apache/pinot/spi/filesystem/PinotFS.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZmlsZXN5c3RlbS9QaW5vdEZTLmphdmE=) | `72.22% <0.00%> (-3.97%)` | :arrow_down: |
   | [...transform/function/DateTruncTransformFunction.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vRGF0ZVRydW5jVHJhbnNmb3JtRnVuY3Rpb24uamF2YQ==) | `83.87% <0.00%> (-2.80%)` | :arrow_down: |
   | [...t/core/query/distinct/DistinctExecutorFactory.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9EaXN0aW5jdEV4ZWN1dG9yRmFjdG9yeS5qYXZh) | `79.16% <0.00%> (-2.78%)` | :arrow_down: |
   | [...inot/common/function/scalar/DateTimeFunctions.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0RhdGVUaW1lRnVuY3Rpb25zLmphdmE=) | `98.61% <0.00%> (-1.39%)` | :arrow_down: |
   | [...oller/api/resources/PinotTableRestletResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1Bpbm90VGFibGVSZXN0bGV0UmVzb3VyY2UuamF2YQ==) | `53.55% <0.00%> (-1.15%)` | :arrow_down: |
   | ... and [24 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...f39adfa](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#issuecomment-876284165


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7141](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9db1b41) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/b99e804ff1e4458cb73e4766cb0b20fb9b716494?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e804) will **increase** coverage by `8.08%`.
   > The diff coverage is `90.12%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/7141/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7141      +/-   ##
   ============================================
   + Coverage     65.43%   73.51%   +8.08%     
     Complexity       92       92              
   ============================================
     Files          1495     1499       +4     
     Lines         73441    73590     +149     
     Branches      10587    10616      +29     
   ============================================
   + Hits          48055    54103    +6048     
   + Misses        21991    15958    -6033     
   - Partials       3395     3529     +134     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | integration | `41.70% <69.13%> (?)` | |
   | unittests | `65.39% <88.88%> (-0.04%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...not/core/plan/DictionaryBasedDistinctPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL0RpY3Rpb25hcnlCYXNlZERpc3RpbmN0UGxhbk5vZGUuamF2YQ==) | `85.71% <85.71%> (ø)` | |
   | [...perator/query/DictionaryBasedDistinctOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9xdWVyeS9EaWN0aW9uYXJ5QmFzZWREaXN0aW5jdE9wZXJhdG9yLmphdmE=) | `90.90% <90.90%> (ø)` | |
   | [...pinot/core/plan/maker/InstancePlanMakerImplV2.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL21ha2VyL0luc3RhbmNlUGxhbk1ha2VySW1wbFYyLmphdmE=) | `89.18% <91.66%> (+11.18%)` | :arrow_up: |
   | [...ctionaryBasedSingleColumnDistinctOnlyExecutor.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9kaXN0aW5jdC9kaWN0aW9uYXJ5L0RpY3Rpb25hcnlCYXNlZFNpbmdsZUNvbHVtbkRpc3RpbmN0T25seUV4ZWN1dG9yLmphdmE=) | `80.00% <0.00%> (-20.00%)` | :arrow_down: |
   | [...transform/function/DateTruncTransformFunction.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vRGF0ZVRydW5jVHJhbnNmb3JtRnVuY3Rpb24uamF2YQ==) | `83.87% <0.00%> (-2.80%)` | :arrow_down: |
   | [...inot/common/function/scalar/DateTimeFunctions.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0RhdGVUaW1lRnVuY3Rpb25zLmphdmE=) | `98.61% <0.00%> (-1.39%)` | :arrow_down: |
   | [...ava/org/apache/pinot/core/transport/TlsConfig.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS90cmFuc3BvcnQvVGxzQ29uZmlnLmphdmE=) | `94.11% <0.00%> (ø)` | |
   | [...va/org/apache/pinot/spi/utils/CommonConstants.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvdXRpbHMvQ29tbW9uQ29uc3RhbnRzLmphdmE=) | `35.00% <0.00%> (ø)` | |
   | [...org/apache/pinot/spi/config/table/TableStatus.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvY29uZmlnL3RhYmxlL1RhYmxlU3RhdHVzLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...org/apache/pinot/core/auth/BasicAuthPrincipal.java](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9hdXRoL0Jhc2ljQXV0aFByaW5jaXBhbC5qYXZh) | `80.00% <0.00%> (ø)` | |
   | ... and [361 more](https://codecov.io/gh/apache/incubator-pinot/pull/7141/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b99e804...9db1b41](https://codecov.io/gh/apache/incubator-pinot/pull/7141?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7141: Support Dictionary Based Plan For DISTINCT

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7141:
URL: https://github.com/apache/incubator-pinot/pull/7141#discussion_r666387959



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";

Review comment:
       Please follow the code style: https://docs.pinot.apache.org/developers/developers-and-contributors/code-setup

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+    int MAX_INITIAL_CAPACITY = 10000;

Review comment:
       Use `DistinctExecutor.MAX_INITIAL_CAPACITY`

##########
File path: pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
##########
@@ -245,19 +245,60 @@ public void testSingleColumnDistinctOnlyInnerSegment()
       // String columns
       //@formatter:off
       List<String> queries = Arrays
-          .asList("SELECT DISTINCT(stringColumn) FROM testTable", "SELECT DISTINCT(rawStringColumn) FROM testTable");
+          .asList("SELECT DISTINCT(stringColumn) FROM testTable ORDER BY stringColumn");

Review comment:
       This test is already covered in `testSingleColumnDistinctOrderByInnerSegment()`. We don't need to add extra correctness test for the change, but you may want to add test to ensure the dictionary-based operator is used

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+    int MAX_INITIAL_CAPACITY = 10000;
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Map<String, Dictionary> _dictionaryMap;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private final IntOpenHashSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Map<String, Dictionary> dictionaryMap, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionaryMap = dictionaryMap;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        String column = _distinctAggregationFunction.getInputExpressions().get(0).getIdentifier();
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        Dictionary dictionary = _dictionaryMap.get(column);
+        int dictionarySize = dictionary.length();
+
+        for (int dictId = 0; dictId < dictionarySize; dictId++) {
+            if (!_hasOrderBy) {

Review comment:
       Without ordering, pick the first `limit` dictIds and put them into the `DistinctTable`

##########
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:
       We should still be able to use dictionary based operator when dictionary is not sorted: create a `DistinctTable` and add all dictionary values into the table

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/plan/DictionaryBasedDistinctPlanNode.java
##########
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.plan;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.pinot.core.operator.query.DictionaryBasedDistinctOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+
+/**
+ * Execute a DISTINCT operation using dictionary based plan
+ */
+public class DictionaryBasedDistinctPlanNode implements PlanNode {
+    private final IndexSegment _indexSegment;
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Map<String, Dictionary> _dictionaryMap;
+    private final TransformPlanNode _transformPlanNode;
+
+    /**
+     * Constructor for the class.
+     *
+     * @param indexSegment Segment to process
+     * @param queryContext Query context
+     */
+    public DictionaryBasedDistinctPlanNode(IndexSegment indexSegment, QueryContext queryContext) {
+        _indexSegment = indexSegment;
+        AggregationFunction[] aggregationFunctions = queryContext.getAggregationFunctions();
+
+        assert aggregationFunctions != null && aggregationFunctions.length == 1
+                && aggregationFunctions[0] instanceof DistinctAggregationFunction;
+
+        _distinctAggregationFunction = (DistinctAggregationFunction) aggregationFunctions[0];
+
+        _dictionaryMap = new HashMap<>();

Review comment:
       We don't really need a map. There should be only one dictionary. You can directly pass in the dictionary when constructing the plan node

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/DictionaryBasedDistinctOperator.java
##########
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.query;
+
+import it.unimi.dsi.fastutil.ints.IntHeapPriorityQueue;
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.OrderByExpressionContext;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.data.table.Record;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
+import org.apache.pinot.core.query.distinct.DistinctTable;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec;
+
+/**
+ * Operator which executes DISTINCT operation based on dictionary
+ */
+public class DictionaryBasedDistinctOperator extends DistinctOperator {
+    private static final String OPERATOR_NAME = "DictionaryBasedDistinctOperator";
+    int MAX_INITIAL_CAPACITY = 10000;
+
+    private final DistinctAggregationFunction _distinctAggregationFunction;
+    private final Map<String, Dictionary> _dictionaryMap;
+    private final int _numTotalDocs;
+    private final TransformOperator _transformOperator;
+    private final IntOpenHashSet _dictIdSet;
+
+    private IntPriorityQueue _priorityQueue;
+
+    private boolean _hasOrderBy;
+
+    public DictionaryBasedDistinctOperator(IndexSegment indexSegment, DistinctAggregationFunction distinctAggregationFunction,
+                                           Map<String, Dictionary> dictionaryMap, int numTotalDocs,
+                                           TransformOperator transformOperator) {
+        super(indexSegment, distinctAggregationFunction, transformOperator);
+
+        _distinctAggregationFunction = distinctAggregationFunction;
+        _dictionaryMap = dictionaryMap;
+        _numTotalDocs = numTotalDocs;
+        _transformOperator = transformOperator;
+        _dictIdSet = new IntOpenHashSet();
+
+        List<OrderByExpressionContext> orderByExpressionContexts = _distinctAggregationFunction.getOrderByExpressions();
+
+        if (orderByExpressionContexts != null) {
+            OrderByExpressionContext orderByExpressionContext = orderByExpressionContexts.get(0);
+            int limit = _distinctAggregationFunction.getLimit();
+            int comparisonFactor = orderByExpressionContext.isAsc() ? -1 : 1;
+            _priorityQueue =
+                    new IntHeapPriorityQueue(Math.min(limit, MAX_INITIAL_CAPACITY), (i1, i2) -> (i1 - i2) * comparisonFactor);
+            _hasOrderBy = true;
+        }
+    }
+
+    @Override
+    protected IntermediateResultsBlock getNextBlock() {
+        int limit = _distinctAggregationFunction.getLimit();
+        String column = _distinctAggregationFunction.getInputExpressions().get(0).getIdentifier();
+
+        assert _distinctAggregationFunction.getType() == AggregationFunctionType.DISTINCT;
+
+        Dictionary dictionary = _dictionaryMap.get(column);
+        int dictionarySize = dictionary.length();
+
+        for (int dictId = 0; dictId < dictionarySize; dictId++) {
+            if (!_hasOrderBy) {
+                _dictIdSet.add(dictId);
+
+                if (_dictIdSet.size() >= limit) {
+                    break;
+                }
+            } else {
+                // We already ascertained that the dictionary is sorted, hence we can use IDs instead of actual values

Review comment:
       Since we already know the dictionary is sorted, simply pick the first (asc) or last (desc) `limit` dictIds and put them into the `DistinctTable`, no need to scan the dictionary.

##########
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) {

Review comment:
       (nit) `getDistinctPlanNode`




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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