Fix grouping sets leading comma issue. (#6383)
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (11, ubuntu-latest) (push) Has been cancelled Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (17, ubuntu-latest) (push) Has been cancelled Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (21, ubuntu-latest) (push) Has been cancelled Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (8, ubuntu-latest) (push) Has been cancelled Details

* Fix grouping sets leading comma issue.

* Fix grouping sets leading comma issue.

* Fix grouping sets leading comma issue.

* Fix grouping sets leading comma issue.
This commit is contained in:
lingo-xp 2025-03-20 15:49:29 +08:00 committed by GitHub
parent 3d111cebd4
commit f722a6ef10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 2 deletions

View File

@ -2571,7 +2571,13 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
if (i != 0) {
if (groupItemSingleLine) {
println(',');
if (item instanceof SQLGroupingSetExpr) {
if (!item.hasBeforeComment()) {
println();
}
} else {
println(',');
}
} else {
if (item instanceof SQLGroupingSetExpr) {
println();

View File

@ -40,5 +40,4 @@ GROUP BY -- 10 空白注释 ok
,
e,
f -- 13 空白注释 ok
,
GROUPING SETS ((a, b, c), (b, c, d), (d, e, f))

View File

@ -1,3 +1,20 @@
select
a,
b,
c,
d
from e
group by
a,
b
grouping sets ((a,b), (a))
--------------------
SELECT a, b, c, d
FROM e
GROUP BY a,
b
GROUPING SETS ((a, b), (a))
------------------------------------------------------------------------------------------------------------------------
select CASE
WHEN UPPER(a) = 'a'
AND (SELECT b FROM UNNEST() ORDER BY c DESC LIMIT 1) = 'b'