Skip to content

Commit

Permalink
fix group by items output format
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Dec 4, 2024
1 parent b4a1cff commit ae6382f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,7 @@ public boolean visit(SQLSelectGroupByClause x) {

if (i != 0) {
if (groupItemSingleLine) {
println(", ");
println(',');
} else {
if (item instanceof SQLGroupingSetExpr) {
println();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public void test_select() throws Exception {
"\t\tWHERE ds = 20170627\n" +
"\t\t\tAND hh = 0\n" +
"\t\t\tAND mm = 0\n" +
"\t\tGROUP BY item_id, \n" +
"\t\t\tstr_to_map(args, ',', '=')['sid'], \n" +
"\t\t\tpv_id, \n" +
"\t\tGROUP BY item_id,\n" +
"\t\t\tstr_to_map(args, ',', '=')['sid'],\n" +
"\t\t\tpv_id,\n" +
"\t\t\tsplit_part(str_to_map(args, ',', '=')['scm'], '.', 2)\n" +
"\t) UT\n" +
"\tLEFT OUTER JOIN (\n" +
Expand All @@ -83,7 +83,7 @@ public void test_select() throws Exception {
"\t\tWHERE ds = 20170627\n" +
"\t\t\tAND hh = 0\n" +
"\t\t\tAND mm = 0\n" +
"\t\tGROUP BY pv_id, \n" +
"\t\tGROUP BY pv_id,\n" +
"\t\t\titem_it\n" +
"\t) CLK\n" +
"\tON UT.ad_session = CLK.ad_session\n" +
Expand All @@ -110,9 +110,9 @@ public void test_select() throws Exception {
"\t\twhere ds = 20170627\n" +
"\t\t\tand hh = 0\n" +
"\t\t\tand mm = 0\n" +
"\t\tgroup by item_id, \n" +
"\t\t\tstr_to_map(args, ',', '=')['sid'], \n" +
"\t\t\tpv_id, \n" +
"\t\tgroup by item_id,\n" +
"\t\t\tstr_to_map(args, ',', '=')['sid'],\n" +
"\t\t\tpv_id,\n" +
"\t\t\tsplit_part(str_to_map(args, ',', '=')['scm'], '.', 2)\n" +
"\t) UT\n" +
"\tleft outer join (\n" +
Expand All @@ -122,7 +122,7 @@ public void test_select() throws Exception {
"\t\twhere ds = 20170627\n" +
"\t\t\tand hh = 0\n" +
"\t\t\tand mm = 0\n" +
"\t\tgroup by pv_id, \n" +
"\t\tgroup by pv_id,\n" +
"\t\t\titem_it\n" +
"\t) CLK\n" +
"\ton UT.ad_session = CLK.ad_session\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void test_select() throws Exception {
"ON t1.region_id = t3.region_id\n" +
"WHERE t1.add_date = '${date_minus_1}'\n" +
"\tOR t2.order_id IS NOT NULL\n" +
"GROUP BY t1.member_id, \n" +
"GROUP BY t1.member_id,\n" +
"\tt3.city_id", SQLUtils.formatOdps(sql));

assertEquals("select ta.member_id as member_id, ta.city_id\n" +
Expand Down Expand Up @@ -189,7 +189,7 @@ public void test_select() throws Exception {
"on t1.region_id = t3.region_id\n" +
"where t1.add_date = '${date_minus_1}'\n" +
"\tor t2.order_id is not null\n" +
"group by t1.member_id, \n" +
"group by t1.member_id,\n" +
"\tt3.city_id", SQLUtils.formatOdps(sql, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));

List<SQLStatement> statementList = SQLUtils.parseStatements(sql, JdbcConstants.ODPS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ public void test_select() throws Exception {
"\t) t1\n" +
"\t\tLATERAL VIEW EXPLODE(t1.os) t2 AS os\n" +
"\t\tLATERAL VIEW EXPLODE(t1.ver) t3 AS ver\n" +
"\tGROUP BY t1.uid, \n" +
"\t\tt2.os, \n" +
"\tGROUP BY t1.uid,\n" +
"\t\tt2.os,\n" +
"\t\tt3.ver\n" +
") tt\n" +
"WHERE NOT (tt.os = 'all'\n" +
"AND tt.ver <> 'all')\n" +
"GROUP BY tt.os, \n" +
"GROUP BY tt.os,\n" +
"\ttt.ver;", SQLUtils.formatOdps(sql));

assertEquals("insert overwrite table ids_openapp_dau_d partition (dt='${lastday}')\n" +
Expand All @@ -106,13 +106,13 @@ public void test_select() throws Exception {
"\t) t1\n" +
"\t\tlateral view explode(t1.os) t2 as os\n" +
"\t\tlateral view explode(t1.ver) t3 as ver\n" +
"\tgroup by t1.uid, \n" +
"\t\tt2.os, \n" +
"\tgroup by t1.uid,\n" +
"\t\tt2.os,\n" +
"\t\tt3.ver\n" +
") tt\n" +
"where not (tt.os = 'all'\n" +
"and tt.ver <> 'all')\n" +
"group by tt.os, \n" +
"group by tt.os,\n" +
"\ttt.ver;", SQLUtils.formatOdps(sql, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));

List<SQLStatement> statementList = SQLUtils.parseStatements(sql, JdbcConstants.ODPS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void test_select() throws Exception {
"\t\t'CheckMobileConflict', \n" +
"\t\t'VerifyEmail'\n" +
"\t)\n" +
"GROUP BY process, \n" +
"GROUP BY process,\n" +
"\tvalue5", SQLUtils.formatOdps(sql));

assertEquals("select count(DISTINCT (trackid)) as total, process, value5 as result\n" +
Expand All @@ -70,7 +70,7 @@ public void test_select() throws Exception {
"\t\t'CheckMobileConflict', \n" +
"\t\t'VerifyEmail'\n" +
"\t)\n" +
"group by process, \n" +
"group by process,\n" +
"\tvalue5", SQLUtils.formatOdps(sql, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));

List<SQLStatement> statementList = SQLUtils.parseStatements(sql, JdbcConstants.ODPS);
Expand Down
12 changes: 6 additions & 6 deletions core/src/test/resources/bvt/parser/odps-14.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ SELECT a -- 2 select注释
FROM tmp t1 -- 8 空白注释 ok
-- 9 空白注释 ok
GROUP BY -- 10 空白注释 ok
a,
b,
c,
a,
b,
c,
d -- 11 空白注释 ok
-- 12 空白注释 ok
,
e,
,
e,
f -- 13 空白注释 ok
,
,
GROUPING SETS ((a, b, c), (b, c, d), (d, e, f))

0 comments on commit ae6382f

Please sign in to comment.