GeezerVison is showing github.com — [BUG] JSQLParser Version 5.4-Snapshot : PostgreSQL : 2nd Function Parameter with schema/table/column can't be parsed · Issue #2290 · JSQLParser/JSqlParser
[BUG] JSQLParser Version 5.4-Snapshot : PostgreSQL : 2nd Function Parameter with schema/table/column can't be parsed #2290DescriptionFailing SQL Feature:
- 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
SELECT
DATE_TRUNC(
'week',
(
"schema"."tbl"."column" + INTERVAL '1 day'
)
)
FROM
"schema"."tbl";
Note that:
SELECT
DATE_TRUNC(
'week',
(
"tbl"."column" + INTERVAL '1 day'
)
)
FROM
"schema"."tbl";
and
SELECT
FUNC(
(
"schema"."tbl"."column" + INTERVAL '1 day'
)
)
FROM
"schema"."tbl";
both work
Software Information:
- JSqlParser 5.4-Snapshot (f10b52e)
- PostgreSQL
Activitydavyboyhayes commented on Aug 5, 2025 ContributorAuthor More actions 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 commented on Aug 5, 2025 ContributorAuthor More actions SELECT
DATE_TRUNC(
'week',
"schema"."tbl"."column" + INTERVAL '1 day'
)
FROM
"schema"."tbl";
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 commented on Aug 11, 2025 ContributorAuthor More actions manticore-projects commented on 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 commented on Aug 11, 2025 ContributorAuthor More actions Thanks, I'll give that a try! davyboyhayes commented on Aug 11, 2025 ContributorAuthor More actions Simplifying this further:
SELECT f('x',(s.t.c + INTERVAL '1 day')) FROM s.t;
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 davyboyhayes commented on Aug 11, 2025 ContributorAuthor More actions at [email protected]/net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java)
at [email protected]/net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java)
at [email protected]/net.sf.jsqlparser.parser.CCJSqlParser.ParenthesedColumnList(CCJSqlParser.java:22396)
at [email protected]/net.sf.jsqlparser.parser.CCJSqlParser.LambdaExpression(CCJSqlParser.java:28655)
at [email protected]/net.sf.jsqlparser.parser.CCJSqlParser.ComplexExpressionList(CCJSqlParser.java:22425)
at [email protected]/net.sf.jsqlparser.parser.CCJSqlParser.ExpressionList(CCJSqlParser.java:22265)
at [email protected]/net.sf.jsqlparser.parser.CCJSqlParser.InternalFunction(CCJSqlParser.java:29592)
at [email protected]/net.sf.jsqlparser.parser.CCJSqlParser.Function(CCJSqlParser.java:29475)
davyboyhayes commented on Aug 11, 2025 ContributorAuthor More actions 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|