Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FILTER over window functions is not supported #866

Closed
sivaraam opened this issue Oct 8, 2019 · 2 comments
Closed

FILTER over window functions is not supported #866

sivaraam opened this issue Oct 8, 2019 · 2 comments

Comments

@sivaraam
Copy link
Contributor

sivaraam commented Oct 8, 2019

Describe the bug

It is possible to use a FILTER clause before the OVER clause in some databases (PostgreSQL, SQLite; as a side note, it is actually part of the SQL standard). It is not possible to parse queries with the FILTER clause using the library.

Reference

To Reproduce

Steps to reproduce the behavior:

  1. Example SQL
SELECT COUNT(*) FILTER (WHERE name = 'Raj') OVER (PARTITION BY name) FROM table
  1. Parsing this SQL using JSqlParser with this statements
        try {
            Statement st = CCJSqlParserUtil.parse(
                    "SELECT COUNT(*) FILTER (WHERE name = 'Raj') OVER (PARTITION BY name) FROM table"
            );
            System.out.println(st);
        } catch (JSQLParserException e) {
            e.printStackTrace();
        }
  1. Exception
net.sf.jsqlparser.JSQLParserException
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:51)
...
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
    at line 1, column 24.

Was expecting one of:

    ","
    ";"
    "CONNECT"
    "EXCEPT"
    "FOR"
    "FROM"
    "GROUP"
    "HAVING"
    "INTERSECT"
    "INTO"
    "MINUS"
    "ORDER"
    "START"
    "UNION"
    "WHERE"
    "WINDOW"
    <EOF>

Expected behavior
It should possible to successfully parse queries with FILTER clause.

System

  • Database you are using: PostgreSQL, SQLite.
  • Java Version: 11.0.3
  • JSqlParser version: 3.0
@localdevjs
Copy link

Wow, I just literally ran into this problem tonight myself. It would be great if window functions could be supported.

@wumpz
Copy link
Member

wumpz commented Oct 9, 2019

Window functions are supported. This filter option is not. PRs are welcome.

@wumpz wumpz closed this as completed in 25e1dcc Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants