You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2022/10/18 03:13:26 UTC

[pinot] branch master updated: Add more test for NonAggregationGroupByToDistinctQueryRewriter (#9616)

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

jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 63c6438d3c Add more test for NonAggregationGroupByToDistinctQueryRewriter (#9616)
63c6438d3c is described below

commit 63c6438d3cd3f31983edc8324325a0e268332f37
Author: Xiaotian (Jackie) Jiang <17...@users.noreply.github.com>
AuthorDate: Mon Oct 17 20:13:20 2022 -0700

    Add more test for NonAggregationGroupByToDistinctQueryRewriter (#9616)
---
 .../parsers/rewriter/NonAggregationGroupByToDistinctQueryRewriter.java | 1 +
 .../rewriter/NonAggregationGroupByToDistinctQueryRewriterTest.java     | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/NonAggregationGroupByToDistinctQueryRewriter.java b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/NonAggregationGroupByToDistinctQueryRewriter.java
index 958387d051..8005dbd759 100644
--- a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/NonAggregationGroupByToDistinctQueryRewriter.java
+++ b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/NonAggregationGroupByToDistinctQueryRewriter.java
@@ -35,6 +35,7 @@ import org.apache.pinot.sql.parsers.SqlCompilationException;
  *
  * E.g.
  * SELECT col1, col2 FROM foo GROUP BY col1, col2 --> SELECT DISTINCT col1, col2 FROM foo
+ * SELECT col1, col2 FROM foo GROUP BY col2, col1 --> SELECT DISTINCT col1, col2 FROM foo
  * SELECT col1 + col2 FROM foo GROUP BY col1 + col2 --> SELECT DISTINCT col1 + col2 FROM foo
  * SELECT col1 AS c1 FROM foo GROUP BY col1 --> SELECT DISTINCT col1 AS c1 FROM foo
  * SELECT col1, col1 AS c1, col2 FROM foo GROUP BY col1, col2 --> SELECT DISTINCT col1, col1 AS ci, col2 FROM foo
diff --git a/pinot-common/src/test/java/org/apache/pinot/sql/parsers/rewriter/NonAggregationGroupByToDistinctQueryRewriterTest.java b/pinot-common/src/test/java/org/apache/pinot/sql/parsers/rewriter/NonAggregationGroupByToDistinctQueryRewriterTest.java
index b97df8dfc2..a005bc78de 100644
--- a/pinot-common/src/test/java/org/apache/pinot/sql/parsers/rewriter/NonAggregationGroupByToDistinctQueryRewriterTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/sql/parsers/rewriter/NonAggregationGroupByToDistinctQueryRewriterTest.java
@@ -33,11 +33,14 @@ public class NonAggregationGroupByToDistinctQueryRewriterTest {
   public void testQueryRewrite() {
     testQueryRewrite("SELECT A FROM myTable GROUP BY A", "SELECT DISTINCT A FROM myTable");
     testQueryRewrite("SELECT col1, col2 FROM foo GROUP BY col1, col2", "SELECT DISTINCT col1, col2 FROM foo");
+    testQueryRewrite("SELECT col1, col2 FROM foo GROUP BY col2, col1", "SELECT DISTINCT col1, col2 FROM foo");
     testQueryRewrite("SELECT col1+col2*5 FROM foo GROUP BY col1+col2*5", "SELECT DISTINCT col1+col2*5 FROM foo");
     testQueryRewrite("SELECT col1 as col2, col1 as col3 FROM foo GROUP BY col1",
         "SELECT DISTINCT col1 as col2, col1 as col3 FROM foo");
     testQueryRewrite("SELECT col1 as a, col2 as b, concat(col3, col4, '') as c FROM foo GROUP BY a,b,c",
         "SELECT DISTINCT col1 as a, col2 as b, concat(col3, col4, '') as c FROM foo");
+    testQueryRewrite("SELECT col1 as a, col2 as b, concat(col3, col4, '') as c FROM foo GROUP BY c, b, a",
+        "SELECT DISTINCT col1 as a, col2 as b, concat(col3, col4, '') as c FROM foo");
     testQueryRewrite(
         "SELECT col1 as a, col2 as b, concat(col3, col4, '') as c FROM foo GROUP BY col1, col2, CONCAT(col3,col4,'')",
         "SELECT DISTINCT col1 as a, col2 as b, concat(col3, col4, '') as c FROM foo");


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