Skip to content

Commit

Permalink
Add more test for NonAggregationGroupByToDistinctQueryRewriter (apach…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackie-Jiang authored Oct 18, 2022
1 parent 2875342 commit 63c6438
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
*
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 63c6438

Please sign in to comment.