Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6178

WITH RECURSIVE query when cloned using SqlShuttle loses RECURSIVE property

    XMLWordPrintableJSON

Details

    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

       @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());
        }

      The above test case generates following output.

      WITH "EMP2" AS (SELECT *
                  FROM "EMP"
                  UNION
                  SELECT *
                  FROM "EMP2") SELECT *
              FROM "EMP2"

       

      Attachments

        Issue Links

          Activity

            People

              hanu.ncr Hanumath Rao Maduri
              hanu.ncr Hanumath Rao Maduri
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: