Skip to content

[BUG] JSQLParser Version : Trino : additional clauses in function parameters unsupported #2368

Description

@davyboyhayes

Failing SQL Feature:

  • Trino uses functions which have paramaters with clauses ,'parameter' additional clauses) that isn't supported by JSQLParser

SQL Example:

select
    json_query(
        '{"customer" : 100, "region" : "AFRICA"},{"region" : "ASIA"},{"customer" : 300, "region" : "AFRICA", "comment" : null}',
        'strict $.keyvalue()' WITH ARRAY WRAPPER
    )
from
    tbl;

http://jsqlformatter.manticore-projects.com/jsqlformatter/demo.html?args=-c%20M4UwNiDGAuBQAEiBWwD2A7A+gRwK4gCcBPACgUQvgHIBvAIkl2GlQFtC74AueARgAZ+AGnh0CIAOYBLDJx50AggDEASgEkAwgroBfIfXHTZ3UQoDKa7XvqNmbDiYDMgkWMkz0c06s3bXkNnZ0aC90XDAwHSohckpqZgIpGHgAEgA6AGsQIgA3AEMwfBIASip4AHU1ABUACXgFFRUFAE0KpoAFdoBRFVji2AAzAjZY6AAjMABuIA$

Image

https://trino.io/docs/current/functions/json.html#json-query

Software Information:

  • JSqlParser 5.4-SNAPSHOT
  • Trino

Activity

  1. davyboyhayes commented on Jan 21, 2026

    @davyboyhayes
    ContributorAuthor

    @manticore-projects, I have tried to add:

    <S_NOT_COMMA_OR_CLOSING_BRACKET: (~[",", ")"])+>
    ...
    ExpressionList ComplexExpressionList():
    {
        ExpressionList<Column> columns;
        ExpressionList expressions = new ExpressionList();
        Expression expr;
    }
    {
        (
            LOOKAHEAD(2) expr=OracleNamedFunctionParameter()
            |
            LOOKAHEAD(7) expr=ExpressionWithClause()
            |
            expr=Expression()
        )
        {
            expressions.add(expr);
        }
    
        (
            LOOKAHEAD(2, {!interrupted}) ","
            (
                LOOKAHEAD(2) expr=OracleNamedFunctionParameter()
                |
                LOOKAHEAD(7) expr=LambdaExpression()
                |
                LOOKAHEAD(7) expr=ExpressionWithClause()
                |
                expr=Expression()
            ) { expressions.add(expr); }
        )*
    
        {
            return expressions;
        }
    }
    ...
    ExpressionWithClause ExpressionWithClause() : {
        ExpressionWithClause expressionWithClause = new ExpressionWithClause();
        Token token = null;
        Token extendedToken = null;
        Expression expr = null;
    }
    {
        expr = Expression()
        token = <S_NOT_COMMA_OR_CLOSING_BRACKET>
        {
            expressionWithClause.setExpression(expr);
            expressionWithClause.setClause(token.image);
        }
        LOOKAHEAD(2) (
            extendedToken = <S_NOT_COMMA_OR_CLOSING_BRACKET>
            {
                expressionWithClause.setClause(expressionWithClause.getClause() + " " + extendedToken.image);
            }
        )*
        {
        return expressionWithClause;
        }
    }
    

    But this isn't working

    Warning: Choice conflict in (...)* construct at line 7935, column 18.
             Expansion nested within construct and expansion following construct
             have common prefixes, one of which is: <S_NOT_COMMA_OR_CLOSING_BRACKET>
             Consider using a lookahead of 2 or more for nested expansion.
    

    I'm happy to create a PR to fix this, but struggling to get this working. If I try replacing <S_NOT_COMMA_OR_CLOSING_BRACKET> with <S_IDENTIFIER> then it ExpressionWithClause becomes over greedy:
    ExecutorValidatorTest:

    /Users/dhayes/.sdkman/candidates/java/21.0.5-oracle/bin/java -javaagent:/Users/dhayes/Library/Caches/JetBrains/IntelliJIdea2025.2/captureAgent/debugger-agent.jar=file:///var/folders/th/kmk_447n7fxd0_fld5mrf4xr0000gr/T/capture4197005359511052478.props -ea --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED -Xmx2G -Xms800m -Xss4m -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Users/dhayes/Applications/IntelliJ IDEA Ultimate.app/Contents/lib/idea_rt.jar=57903 -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -Ddebugger.agent.enable.coroutines=true -Dkotlinx.coroutines.debug.enable.flows.stack.trace=true -Dkotlinx.coroutines.debug.enable.mutable.state.flows.stack.trace=true --patch-module net.sf.jsqlparser=/Users/dhayes/Developer/JSqlParser/target/test-classes --add-reads net.sf.jsqlparser=ALL-UNNAMED --add-opens net.sf.jsqlparser/net.sf.jsqlparser.util.validation.validator=ALL-UNNAMED --add-modules net.sf.jsqlparser -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /Users/dhayes/.m2/repository/org/junit/platform/junit-platform-launcher/1.11.4/junit-platform-launcher-1.11.4.jar:/Users/dhayes/Applications/IntelliJ IDEA Ultimate.app/Contents/lib/idea_rt.jar:/Users/dhayes/Applications/IntelliJ IDEA Ultimate.app/Contents/plugins/junit/lib/junit6-rt.jar:/Users/dhayes/Applications/IntelliJ IDEA Ultimate.app/Contents/plugins/junit/lib/junit5-rt.jar:/Users/dhayes/Applications/IntelliJ IDEA Ultimate.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/dhayes/Developer/JSqlParser/target/test-classes:/Users/dhayes/.m2/repository/org/javacc/generator/java/8.1.0-SNAPSHOT/java-8.1.0-SNAPSHOT.jar:/Users/dhayes/.m2/repository/org/javacc/core/8.1.0-SNAPSHOT/core-8.1.0-SNAPSHOT.jar:/Users/dhayes/.m2/repository/commons-io/commons-io/2.18.0/commons-io-2.18.0.jar:/Users/dhayes/.m2/repository/org/junit/jupiter/junit-jupiter/5.11.4/junit-jupiter-5.11.4.jar:/Users/dhayes/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.11.4/junit-jupiter-api-5.11.4.jar:/Users/dhayes/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/Users/dhayes/.m2/repository/org/junit/platform/junit-platform-commons/1.11.4/junit-platform-commons-1.11.4.jar:/Users/dhayes/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/dhayes/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.11.4/junit-jupiter-params-5.11.4.jar:/Users/dhayes/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.11.4/junit-jupiter-engine-5.11.4.jar:/Users/dhayes/.m2/repository/org/junit/platform/junit-platform-engine/1.11.4/junit-platform-engine-1.11.4.jar:/Users/dhayes/.m2/repository/org/mockito/mockito-core/5.15.2/mockito-core-5.15.2.jar:/Users/dhayes/.m2/repository/net/bytebuddy/byte-buddy/1.15.11/byte-buddy-1.15.11.jar:/Users/dhayes/.m2/repository/net/bytebuddy/byte-buddy-agent/1.15.11/byte-buddy-agent-1.15.11.jar:/Users/dhayes/.m2/repository/org/objenesis/objenesis/3.3/objenesis-3.3.jar:/Users/dhayes/.m2/repository/org/mockito/mockito-junit-jupiter/5.15.2/mockito-junit-jupiter-5.15.2.jar:/Users/dhayes/.m2/repository/org/assertj/assertj-core/3.27.3/assertj-core-3.27.3.jar:/Users/dhayes/.m2/repository/org/apache/commons/commons-lang3/3.20.0/commons-lang3-3.20.0.jar:/Users/dhayes/.m2/repository/com/h2database/h2/2.4.240/h2-2.4.240.jar:/Users/dhayes/.m2/repository/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3.jar:/Users/dhayes/.m2/repository/org/openjdk/jmh/jmh-core/1.37/jmh-core-1.37.jar:/Users/dhayes/.m2/repository/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar:/Users/dhayes/.m2/repository/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar:/Users/dhayes/.m2/repository/org/openjdk/jmh/jmh-generator-annprocess/1.37/jmh-generator-annprocess-1.37.jar -p /Users/dhayes/Developer/JSqlParser/target/classes com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 net.sf.jsqlparser.util.validation.validator.ExecuteValidatorTest
    
    org.opentest4j.AssertionFailedError: Expected 0 errors, but got: [ValidationError [
    statement=CALL myproc ('a', 2, 'b')
    capability=parsing
    errors=[ParseException: Cannot parse statement: net.sf.jsqlparser.parser.ParseException: Encountered: <EOF>, at line 1, column 25, in lexical state DEFAULT.
    Was expecting this terminal within expansion starting at 7929:17:
        <S_IDENTIFIER> (inside 7929:17) ...
    ]
    ]] ==> 
    
  2. added a commit that references this issue on Feb 13, 2026
    d61020c
  3. davyboyhayes commented on Feb 13, 2026

    @davyboyhayes
    ContributorAuthor

    @manticore-projects - I've created a PR - I've used Codex 5.3 to help guide me through these changes.

  4. added 3 commits that reference this issue on Feb 18, 2026
    57e6504
    197a0d6
    9765050
  5. added a commit that references this issue on Feb 24, 2026
    d33d61a
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