Description
The parser fails to parse queries with CTEs that use both forms, the WITH <expression> AS <identifier> form and the WITH <identifier> AS <subquery expression> form (see syntax). See this example:
SqlParser parser = new SqlParser();
ParsedStatement stmt = parser.parsedStatement("with 1 as a, b as (select 1) select a from b");
assertFalse(stmt.isHasErrors());
The following queries can be parsed without issues:
with 1 as a, 2 as b select a, b; -- two CTEs of the first form
with a as (select 1), b as (select 2) select * from a, b; -- two CTEs of the second form
Steps to reproduce
- Run the java code above in a test
- Observe a test failure
Error Log or Exception StackTrace
When debugging this in the test, you can see that inside parsedStatement() the parseTree.children.get(0).exception is org.antlr.v4.runtime.NoViableAltException.
Expected Behaviour
Both forms of CTEs should be parseable if used in a single query.
Description
The parser fails to parse queries with CTEs that use both forms, the
WITH <expression> AS <identifier>form and theWITH <identifier> AS <subquery expression>form (see syntax). See this example:The following queries can be parsed without issues:
Steps to reproduce
Error Log or Exception StackTrace
When debugging this in the test, you can see that inside
parsedStatement()theparseTree.children.get(0).exceptionisorg.antlr.v4.runtime.NoViableAltException.Expected Behaviour
Both forms of CTEs should be parseable if used in a single query.