[
https://issues.apache.org/jira/browse/CALCITE-6178?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Hanumath Rao Maduri updated CALCITE-6178:
-
Description:
Here is a test case which shows that a recursive query becomes a non recursive
query when cloned using SqlShuttle.
Copy paste the below test case in SqlParserTest
{code:java}
@Test void testRecursiveQueryCloned() throws Exception {
SqlNode sqlNode = sql("with RECURSIVE emp2 as "
+ "(select * from emp union select * from emp2) select * from
emp2").parser().parseStmt();
SqlNode sqlNode1 = sqlNode.accept(new SqlShuttle() {
@Override public SqlNode visit(SqlIdentifier identifier) {
return new SqlIdentifier(identifier.names,
identifier.getParserPosition());
}
});
System.out.println(sqlNode1.toSqlString(c ->
c.withAlwaysUseParentheses(false)).getSql());
}{code}
The above test case generates following output.
{code:java}
WITH "EMP2" AS (SELECT *
FROM "EMP"
UNION
SELECT *
FROM "EMP2") SELECT *
FROM "EMP2"{code}
was:
Here is a test case which shows that a recursive query becomes a non recursive
query when cloned using SqlShuttle.
Copy paste the below test case in SqlParserTest
{code:java}
@Test void testRecursiveQueryCloned() throws Exception {
SqlNode sqlNode = sql("with RECURSIVE emp2 as "
+ "(select * from emp union select * from emp2) select * from
emp2").parser().parseStmt();
SqlNode sqlNode1 = sqlNode.accept(new SqlShuttle() {
@Override public SqlNode visit(SqlIdentifier identifier) {
return new SqlIdentifier(identifier.names,
identifier.getParserPosition());
}
});
System.out.println(sqlNode1.toSqlString(c ->
c.withAlwaysUseParentheses(false)).getSql());
}{code}
The above test case generates following output.
{code:java}
@Test void testRecursiveQueryCloned() throws Exception {
SqlNode sqlNode = sql("with RECURSIVE emp2 as "
+ "(select * from emp union select * from emp2) select * from
emp2").parser().parseStmt();
SqlNode sqlNode1 = sqlNode.accept(new SqlShuttle() {
@Override public SqlNode visit(SqlIdentifier identifier) {
return new SqlIdentifier(identifier.names,
identifier.getParserPosition());
}
});
System.out.println(sqlNode1.toSqlString(c ->
c.withAlwaysUseParentheses(false)).getSql());
} {code}
> WITH RECURSIVE query when cloned using sqlshuttle looses RECURSIVE property
> ---
>
> Key: CALCITE-6178
> URL: https://issues.apache.org/jira/browse/CALCITE-6178
> Project: Calcite
> Issue Type: Bug
> Components: core
>Affects Versions: 1.36.0
>Reporter: Hanumath Rao Maduri
>Assignee: Hanumath Rao Maduri
>Priority: Major
> Fix For: 1.37.0
>
>
> Here is a test case which shows that a recursive query becomes a non
> recursive query when cloned using SqlShuttle.
> Copy paste the below test case in SqlParserTest
> {code:java}
> @Test void testRecursiveQueryCloned() throws Exception {
> SqlNode sqlNode = sql("with RECURSIVE emp2 as "
> + "(select * from emp union select * from emp2) select * from
> emp2").parser().parseStmt();
> SqlNode sqlNode1 = sqlNode.accept(new SqlShuttle() {
>@Override public SqlNode visit(SqlIdentifier identifier) {
> return new SqlIdentifier(identifier.names,
> identifier.getParserPosition());
>}
> });
> System.out.println(sqlNode1.toSqlString(c ->
> c.withAlwaysUseParentheses(false)).getSql());
> }{code}
> The above test case generates following output.
> {code:java}
> WITH "EMP2" AS (SELECT *
> FROM "EMP"
> UNION
> SELECT *
> FROM "EMP2") SELECT *
> FROM "EMP2"{code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)