You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by xi...@apache.org on 2020/10/21 21:29:38 UTC

[incubator-pinot] branch fixing_distinct_orderby_validation created (now 3af1c89)

This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a change to branch fixing_distinct_orderby_validation
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git.


      at 3af1c89  Fixing the issue of applying ordinals in order by for distinct queries

This branch includes the following new commits:

     new 3af1c89  Fixing the issue of applying ordinals in order by for distinct queries

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[incubator-pinot] 01/01: Fixing the issue of applying ordinals in order by for distinct queries

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a commit to branch fixing_distinct_orderby_validation
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git

commit 3af1c89ada9e07774fe907718d21ba1f7dc192f4
Author: Xiang Fu <fx...@gmail.com>
AuthorDate: Wed Oct 21 14:14:37 2020 -0700

    Fixing the issue of applying ordinals in order by for distinct queries
---
 .../main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java | 6 +++---
 .../org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java     | 9 +++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
index 7b41053..a3bd018 100644
--- a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
+++ b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
@@ -353,12 +353,12 @@ public class CalciteSqlParser {
       pinotQuery.setHavingExpression(updateComparisonPredicate(havingExpression));
     }
 
-    // Rewrite GroupBy to Distinct
-    rewriteNonAggregationGroupByToDistinct(pinotQuery);
-
     // Update Ordinals
     applyOrdinals(pinotQuery);
 
+    // Rewrite GroupBy to Distinct
+    rewriteNonAggregationGroupByToDistinct(pinotQuery);
+
     // Update alias
     Map<Identifier, Expression> aliasMap = extractAlias(pinotQuery.getSelectList());
     applyAlias(aliasMap, pinotQuery);
diff --git a/pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java b/pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java
index e9f37ce..7578b30 100644
--- a/pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java
@@ -1611,6 +1611,15 @@ public class CalciteSqlCompilerTest {
   }
 
   @Test
+  public void testOrdinalsQueryRewriteWithDistinctOrderby() {
+    String query = "SELECT baseballStats.playerName AS playerName FROM baseballStats GROUP BY baseballStats.playerName ORDER BY 1 ASC";
+    PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
+    Assert.assertEquals(pinotQuery.getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "baseballStats.playerName");
+    Assert.assertTrue(pinotQuery.getGroupByList().isEmpty());
+    Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "baseballStats.playerName");
+  }
+
+  @Test
   public void testNoArgFunction() {
     String query = "SELECT noArgFunc() FROM foo ";
     PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query);


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