Describe the bug
Nested WITH statements throws an parsing error. nested with statements might not be the best practice, but it's at least supported in Snowflake.
To Reproduce
Run test:
@Test
public void testGetTableListWithStmtFails() throws Exception {
String sql = "WITH TESTSTMT1 AS ( WITH TESTSTMT2 AS (SELECT * FROM MY_TABLE2) SELECT col1, col2 FROM TESTSTMT2) SELECT * FROM TESTSTMT";
net.sf.jsqlparser.statement.Statement statement = pm.parse(new StringReader(sql));
Select selectStatement = (Select) statement;
TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
assertEquals(2, tableList.size());
assertEquals("MY_TABLE1", tableList.get(0));
assertEquals("MY_TABLE2", tableList.get(1));
}
Expected behavior
The test should more or less pass, or at least not throw an error.
System
- Database you are using: Snowflkae
- Java Version:openjdk version "1.8.0_232"
- JSqlParser version: 4.1
Describe the bug
Nested WITH statements throws an parsing error. nested with statements might not be the best practice, but it's at least supported in Snowflake.
To Reproduce
Run test:
Expected behavior
The test should more or less pass, or at least not throw an error.
System