Skip to content

[BUG] NPE in TableNamesFinder in AnalyticExpression visitor #2443

Description

@davyboyhayes
SELECT c, SUM(COUNT(*)) OVER (ORDER BY c ASC ROWS UNBOUNDED PRECEDING) FROM tbl GROUP BY c

The window element here does not contain a range or an offset, yet this will throw an NPE in TableNamesFinder when it tries to walk the AnalyticExpression:

        String sqlStr = "SELECT c, SUM(COUNT(*)) OVER (ORDER BY c ASC ROWS UNBOUNDED PRECEDING) FROM tbl GROUP BY c";

        assertThatCode(() -> TablesNamesFinder.findTables(sqlStr))
                .doesNotThrowAnyException();

Gives:

Expecting code not to raise a throwable but caught                                                                                                                                                                                                                                                                                                                                                                                          
  "java.lang.NullPointerException: Cannot invoke "net.sf.jsqlparser.expression.WindowRange.getStart()" because the return value of "net.sf.jsqlparser.expression.WindowElement.getRange()" is null 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions