GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #2290

New issue
Copy link
New issue
Copy link
Closed
#2293
Closed
[BUG] JSQLParser Version 5.4-Snapshot : PostgreSQL : 2nd Function Parameter with schema/table/column can't be parsed#2290
#2293
Copy link

Description

@davyboyhayes
davyboyhayes
opened on Aug 5, 2025
Issue body actions

Failing 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

Image

Software Information:

  • JSqlParser 5.4-Snapshot (f10b52e)
  • PostgreSQL

Activity

  1. davyboyhayes commented on Aug 5, 2025

    @davyboyhayes
    davyboyhayes
    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

  2. davyboyhayes commented on Aug 5, 2025

    @davyboyhayes
    davyboyhayes
    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)

  3. davyboyhayes commented on Aug 11, 2025

    @davyboyhayes
    davyboyhayes
    on Aug 11, 2025
    ContributorAuthor
    More actions

    @manticore-projects - do you have any hints where I could take a look please?

  4. manticore-projects commented on Aug 11, 2025

    @manticore-projects
    manticore-projects
    on Aug 11, 2025
    Contributor
    More actions

    Greetings.

    Best thing was enabling Token Debug mode in the Grammar and then run the specific test to see where/why it parses wrongly.

  5. davyboyhayes commented on Aug 11, 2025

    @davyboyhayes
    davyboyhayes
    on Aug 11, 2025
    ContributorAuthor
    More actions

    Thanks, I'll give that a try!

  6. davyboyhayes commented on Aug 11, 2025

    @davyboyhayes
    davyboyhayes
    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

  7. davyboyhayes commented on Aug 11, 2025

    @davyboyhayes
    davyboyhayes
    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)
    
  8. davyboyhayes commented on Aug 11, 2025

    @davyboyhayes
    davyboyhayes
    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.

  9. manticore-projects
    closed this as completedin #2293on Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.