Skip to content

Commit adca3ef

Browse files
committed
group_concat started
1 parent 3563c21 commit adca3ef

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
212212
| <K_RECURSIVE:"RECURSIVE">
213213
| <K_OF:"OF">
214214
| <K_KEEP:"KEEP">
215+
| <K_GROUP_CONCAT:"GROUP_CONCAT">
216+
| <K_SEPARATOR:"SEPARATOR">
215217
}
216218

217219
TOKEN : /* Numeric Constants */
@@ -1782,6 +1784,8 @@ Expression PrimaryExpression():
17821784

17831785
| LOOKAHEAD(ExtractExpression()) retval=ExtractExpression()
17841786

1787+
| MySQLGroupConcat()
1788+
17851789
| LOOKAHEAD([sign="+" | sign="-"] JsonExpression()) [sign="+" | sign="-"] retval=JsonExpression()
17861790

17871791
| LOOKAHEAD(["+" | "-"] Function()) [sign="+" | sign="-"] retval=Function()
@@ -2146,6 +2150,16 @@ Function Function():
21462150
}
21472151
}
21482152

2153+
void MySQLGroupConcat():{}
2154+
{
2155+
<K_GROUP_CONCAT> "("
2156+
[<K_DISTINCT>] SimpleExpressionList()
2157+
OrderByElements()
2158+
[ <K_SEPARATOR> <S_CHAR_LITERAL> ]
2159+
")"
2160+
}
2161+
2162+
21492163
SubSelect SubSelect():
21502164
{
21512165
SelectBody selectBody = null;

src/test/java/net/sf/jsqlparser/test/select/SelectTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,4 +1745,8 @@ public void testSelectKeep() throws JSQLParserException {
17451745
public void testSelectKeepOver() throws JSQLParserException {
17461746
assertSqlCanBeParsedAndDeparsed("SELECT MIN(salary) KEEP (DENSE_RANK FIRST ORDER BY commission_pct) OVER (PARTITION BY department_id ) \"Worst\" FROM employees ORDER BY department_id, salary");
17471747
}
1748+
1749+
public void testGroupConcat() throws JSQLParserException {
1750+
assertSqlCanBeParsedAndDeparsed("SELECT student_name, GROUP_CONCAT(DISTINCT test_score ORDER BY test_score DESC SEPARATOR ' ') FROM student GROUP BY student_name");
1751+
}
17481752
}

0 commit comments

Comments
 (0)