File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
main/java/net/sf/jsqlparser/expression
test/java/net/sf/jsqlparser/expression Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 64
64
import net .sf .jsqlparser .statement .select .UnPivot ;
65
65
import net .sf .jsqlparser .statement .select .WithItem ;
66
66
67
+ import java .util .Optional ;
68
+
67
69
@ SuppressWarnings ({"PMD.CyclomaticComplexity" , "PMD.UncommentedEmptyMethodBody" })
68
70
public class ExpressionVisitorAdapter
69
71
implements ExpressionVisitor , PivotVisitor , SelectItemVisitor {
@@ -382,11 +384,13 @@ public void visit(AnalyticExpression expr) {
382
384
element .getExpression ().accept (this );
383
385
}
384
386
}
385
-
386
387
if (expr .getWindowElement () != null ) {
387
- expr .getWindowElement ().getRange ().getStart ().getExpression ().accept (this );
388
- expr .getWindowElement ().getRange ().getEnd ().getExpression ().accept (this );
389
- expr .getWindowElement ().getOffset ().getExpression ().accept (this );
388
+ Optional .ofNullable (expr .getWindowElement ().getRange ()).map (WindowRange ::getStart )
389
+ .map (WindowOffset ::getExpression ).ifPresent (e -> e .accept (this ));
390
+ Optional .ofNullable (expr .getWindowElement ().getRange ()).map (WindowRange ::getEnd )
391
+ .map (WindowOffset ::getExpression ).ifPresent (e -> e .accept (this ));
392
+ Optional .ofNullable (expr .getWindowElement ().getOffset ())
393
+ .map (WindowOffset ::getExpression ).ifPresent (e -> e .accept (this ));
390
394
}
391
395
}
392
396
Original file line number Diff line number Diff line change @@ -259,4 +259,13 @@ public void visit(AllTableColumns all) {
259
259
assertNotNull (holder [0 ]);
260
260
assertEquals ("a.*" , holder [0 ].toString ());
261
261
}
262
+
263
+ @ Test
264
+ public void testAnalyticExpressionWithNullOffsets () throws JSQLParserException {
265
+ ExpressionVisitorAdapter adapter = new ExpressionVisitorAdapter ();
266
+ Expression expression = CCJSqlParserUtil .parseExpression (
267
+ "SUM(\" Spent\" ) OVER (PARTITION BY \" ID\" ORDER BY \" Name\" ASC ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)" );
268
+
269
+ expression .accept (adapter );
270
+ }
262
271
}
You can’t perform that action at this time.
0 commit comments