Skip to content

[BUG] JSQLParser Version 4.5: RDBMS : "Encountered unexpected token: "SELECT" <K_SELECT> at line 11, column 1." #1798

Description

@paolinho91

Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram

Failing SQL Feature:

  • Brief description of the failing SQL feature: method TablesNamesFinder.getTableList(statement) failed with error in title:
    "Encountered unexpected token: "SELECT" <K_SELECT> at line 11, column 1"

SQL Example:

  • Simplified Query Example, focusing on the failing feature:
    SELECT C1, SUM(N) AS N FROM ( ( SELECT C1, SUM(N) AS N FROM T1 GROUP BY C1 ) UNION ALL SELECT C1, 0 AS N FROM T2 ) GROUP BY C1

Software Information:

  • JSqlParser version: 4.5
  • Database: Oracle

Tips:

Query is very bad but works on Oracle DB. Line 11 is the "UNION ALL" SQL command.

Activity

  1. manticore-projects commented on May 30, 2023

    @manticore-projects
    Contributor

    Greetings!

    This has been fixed in PR #1778 which will be released as JSQLParser 5 soonest.
    You can try it here.

    The AST will look like this:

    SQL Text
     └─Statements: statement.select.PlainSelect
        ├─selectItems: statement.select.SelectItem
        │  └─Column: c1
        ├─selectItems: statement.select.SelectItem
        │  ├─expression: expression.Function
        │  │  └─ExpressionList: n
        │  └─Alias:  AS n
        ├─fromItem: statement.select.ParenthesedSelect
        │  └─select: statement.select.SetOperationList
        │     ├─selects: statement.select.ParenthesedSelect
        │     │  └─select: statement.select.PlainSelect
        │     │     ├─selectItems: statement.select.SelectItem
        │     │     │  └─Column: c1
        │     │     ├─selectItems: statement.select.SelectItem
        │     │     │  ├─expression: expression.Function
        │     │     │  │  └─ExpressionList: n
        │     │     │  └─Alias:  AS n
        │     │     ├─Table: t1
        │     │     └─groupBy: statement.select.GroupByElement
        │     │        └─ExpressionList: c1
        │     ├─selects: statement.select.PlainSelect
        │     │  ├─selectItems: statement.select.SelectItem
        │     │  │  └─Column: c1
        │     │  ├─selectItems: statement.select.SelectItem
        │     │  │  ├─LongValue: 0
        │     │  │  └─Alias:  AS n
        │     │  └─Table: t2
        │     └─UnionOp: UNION ALL
        └─groupBy: statement.select.GroupByElement
           └─ExpressionList: c1
    
  2. paolinho91 commented on May 30, 2023

    @paolinho91
    Author

    many thanks! It works

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