You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] JSQLParser Version 5.4-Snapshot : PostgreSQL : 2nd Function Parameter with schema/table/column can't be parsed #2290
Using a function with more than one parameter, where the second parameter includes schema.table.column, with an addition to an Interval, can't be parsed. However, if the same parameter is used as a singular parameter, or the same multi-parameter function is used without schema, the SQL can be parsed.
SQL Example:
Simplified Query Example, focusing on the failing feature
When there isn't parenthesis wrapping the second function, this parses. Problem is Metabase auto generates this SQL with parenthesis when trying to group records by week (and you have the week configured to start on a Monday - hence the interval addition)
It is trying to convert (s.t.c + INTERVAL '1 day') into a ParenthesedColumnList which then breaks because + makes no sense in a column list. However, this isn't a column list, but a parenthesed expression
at net.sf.jsqlparser@5.4-SNAPSHOT/net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java)
at net.sf.jsqlparser@5.4-SNAPSHOT/net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java)
at net.sf.jsqlparser@5.4-SNAPSHOT/net.sf.jsqlparser.parser.CCJSqlParser.ParenthesedColumnList(CCJSqlParser.java:22396)
at net.sf.jsqlparser@5.4-SNAPSHOT/net.sf.jsqlparser.parser.CCJSqlParser.LambdaExpression(CCJSqlParser.java:28655)
at net.sf.jsqlparser@5.4-SNAPSHOT/net.sf.jsqlparser.parser.CCJSqlParser.ComplexExpressionList(CCJSqlParser.java:22425)
at net.sf.jsqlparser@5.4-SNAPSHOT/net.sf.jsqlparser.parser.CCJSqlParser.ExpressionList(CCJSqlParser.java:22265)
at net.sf.jsqlparser@5.4-SNAPSHOT/net.sf.jsqlparser.parser.CCJSqlParser.InternalFunction(CCJSqlParser.java:29592)
at net.sf.jsqlparser@5.4-SNAPSHOT/net.sf.jsqlparser.parser.CCJSqlParser.Function(CCJSqlParser.java:29475)
Not sure if this is too much of a degredation of performance. (JMH numbers are in the PR), so if you have a different way of achieving this, I'd be happy to take a look.
Activity
davyboyhayes commentedon Aug 5, 2025
Again, I'm more than happy to take a steer on where I would need to make a change, and put a PR up
davyboyhayes commentedon Aug 5, 2025
When there isn't parenthesis wrapping the second function, this parses. Problem is Metabase auto generates this SQL with parenthesis when trying to group records by week (and you have the week configured to start on a Monday - hence the interval addition)
davyboyhayes commentedon Aug 11, 2025
@manticore-projects - do you have any hints where I could take a look please?
manticore-projects commentedon Aug 11, 2025
Greetings.
Best thing was enabling Token Debug mode in the Grammar and then run the specific test to see where/why it parses wrongly.
davyboyhayes commentedon Aug 11, 2025
Thanks, I'll give that a try!
davyboyhayes commentedon Aug 11, 2025
Simplifying this further:
It is trying to convert
(s.t.c + INTERVAL '1 day')into aParenthesedColumnListwhich then breaks because+makes no sense in a column list. However, this isn't a column list, but a parenthesed expressiondavyboyhayes commentedon Aug 11, 2025
davyboyhayes commentedon Aug 11, 2025
Not sure if this is too much of a degredation of performance. (JMH numbers are in the PR), so if you have a different way of achieving this, I'd be happy to take a look.