File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
java/net/sf/jsqlparser/expression
jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/statement/select Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ public class Function extends ASTNodeAccessImpl implements Expression {
39
39
private Limit limit = null ;
40
40
private KeepExpression keep = null ;
41
41
private String onOverflowTruncate = null ;
42
+ private String extraKeyword = null ;
42
43
43
44
public Function () {}
44
45
@@ -255,6 +256,15 @@ public void setKeep(KeepExpression keep) {
255
256
this .keep = keep ;
256
257
}
257
258
259
+ public String getExtraKeyword () {
260
+ return extraKeyword ;
261
+ }
262
+
263
+ public Function setExtraKeyword (String extraKeyword ) {
264
+ this .extraKeyword = extraKeyword ;
265
+ return this ;
266
+ }
267
+
258
268
@ Override
259
269
@ SuppressWarnings ({"PMD.CyclomaticComplexity" , "PMD.NPathComplexity" })
260
270
public String toString () {
@@ -272,6 +282,11 @@ public String toString() {
272
282
if (isAllColumns ()) {
273
283
b .append ("ALL " );
274
284
}
285
+
286
+ if (extraKeyword != null ) {
287
+ b .append (extraKeyword ).append (" " );
288
+ }
289
+
275
290
b .append (parameters );
276
291
277
292
if (havingClause != null ) {
Original file line number Diff line number Diff line change @@ -5903,6 +5903,7 @@ Function InternalFunction(boolean escaped):
5903
5903
String onOverflowTruncate = null;
5904
5904
Token overflowToken = null;
5905
5905
Limit limit;
5906
+ Token extraKeywordToken;
5906
5907
}
5907
5908
{
5908
5909
[ LOOKAHEAD(2) prefixToken = <K_APPROXIMATE> ]
@@ -5922,7 +5923,8 @@ Function InternalFunction(boolean escaped):
5922
5923
|
5923
5924
LOOKAHEAD( AllTableColumns() ) expr=AllTableColumns() { expressionList = new ExpressionList(expr); }
5924
5925
|
5925
- LOOKAHEAD(3) expressionList=ExpressionList()
5926
+ LOOKAHEAD(3) [ LOOKAHEAD(2) extraKeywordToken = <K_TABLE> { retval.setExtraKeyword(extraKeywordToken.image); } ]
5927
+ expressionList=ExpressionList()
5926
5928
[ orderByList = OrderByElements() { retval.setOrderByElements(orderByList); } ]
5927
5929
5928
5930
// https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/LISTAGG.html
Original file line number Diff line number Diff line change 11
11
12
12
import net .sf .jsqlparser .JSQLParserException ;
13
13
import net .sf .jsqlparser .test .TestUtils ;
14
+ import org .junit .jupiter .api .Assertions ;
14
15
import org .junit .jupiter .api .Disabled ;
15
16
import org .junit .jupiter .api .Test ;
16
17
@@ -92,4 +93,21 @@ void testAsValue() throws JSQLParserException {
92
93
String sqlStr = "SELECT AS VALUE STRUCT(1 AS a, 2 AS b) xyz" ;
93
94
TestUtils .assertSqlCanBeParsedAndDeparsed (sqlStr , true );
94
95
}
96
+
97
+ @ Test
98
+ void testTimeSeriesFunction () throws JSQLParserException {
99
+ String sqlStr = "with raw_data as (\n "
100
+ + " select timestamp('2024-12-01') zetime\n "
101
+ + " union all \n "
102
+ + " select timestamp('2024-12-04')\n "
103
+ + " )\n "
104
+ + "select zetime from GAP_FILL(\n "
105
+ + " TABLE raw_data,\n "
106
+ + " ts_column => 'zetime',\n "
107
+ + " bucket_width => INTERVAL 4 HOUR\n "
108
+ + ")" ;
109
+ PlainSelect select = (PlainSelect ) TestUtils .assertSqlCanBeParsedAndDeparsed (sqlStr , true );
110
+ TableFunction function = select .getFromItem (TableFunction .class );
111
+ Assertions .assertEquals ("TABLE" , function .getFunction ().getExtraKeyword ());
112
+ }
95
113
}
You can’t perform that action at this time.
0 commit comments