You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/07/09 16:09:10 UTC

[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #5671: Rewrite non-aggregate group by query to distinct query

mayankshriv commented on a change in pull request #5671:
URL: https://github.com/apache/incubator-pinot/pull/5671#discussion_r452327225



##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -331,12 +345,59 @@ private static void queryRewrite(PinotQuery pinotQuery) {
       pinotQuery.setFilterExpression(updatedFilterExpression);
     }
 
+    // Rewrite GroupBy to Distinct
+    rewriteNonAggregationGroupByToDistinct(pinotQuery);
+
     // Update alias
     Map<Identifier, Expression> aliasMap = extractAlias(pinotQuery.getSelectList());
     applyAlias(aliasMap, pinotQuery);
     validate(aliasMap, pinotQuery);
   }
 
+  private static void rewriteNonAggregationGroupByToDistinct(PinotQuery pinotQuery) {

Review comment:
       Would be good to add doc with sample query translations (as already stated in the PR description).

##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -196,13 +198,25 @@ private static boolean isAggregateExpression(Expression expression) {
     return false;
   }
 
-  public static Set<String> extractIdentifiers(List<Expression> expressions) {
+  /**
+   * Extract all the identifiers from given expressions.
+   *
+   * @param expressions
+   * @param excludeAs if true, ignores the right side identifier for AS function.
+   * @return all the identifier names.
+   */
+  public static Set<String> extractIdentifiers(List<Expression> expressions, boolean excludeAs) {

Review comment:
       May be a non-issue here, but just wanted to point out that there are aggregation functions that take multiple args, some of which are expected to be literals (even though they look like expressions, eg distinctCountThetaSketch).




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

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



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