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 6464import net .sf .jsqlparser .statement .select .UnPivot ;
6565import net .sf .jsqlparser .statement .select .WithItem ;
6666
67+ import java .util .Optional ;
68+
6769@ SuppressWarnings ({"PMD.CyclomaticComplexity" , "PMD.UncommentedEmptyMethodBody" })
6870public class ExpressionVisitorAdapter
6971 implements ExpressionVisitor , PivotVisitor , SelectItemVisitor {
@@ -382,11 +384,13 @@ public void visit(AnalyticExpression expr) {
382384 element .getExpression ().accept (this );
383385 }
384386 }
385-
386387 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 ));
390394 }
391395 }
392396
Original file line number Diff line number Diff line change @@ -259,4 +259,13 @@ public void visit(AllTableColumns all) {
259259 assertNotNull (holder [0 ]);
260260 assertEquals ("a.*" , holder [0 ].toString ());
261261 }
262+
263+ @ Test
264+ public void testAnalyticExpressionWithPartialWindowElement () 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+ }
262271}
You can’t perform that action at this time.
0 commit comments