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

Support unparse special syntax when operator is INSERT

    XMLWordPrintableJSON

    Details

      Description

      This exception can be reproduced as below:
      SqlParserTest:

       @Test void test() throws Exception {
          final String sql = "insert into emps select * from emps";
          final SqlNode sqlNode = getSqlParser(sql).parseStmt();
          final SqlNode sqlNodeVisited = sqlNode.accept(new SqlShuttle() {
            @Override public SqlNode visit(SqlIdentifier identifier) {
              return new SqlIdentifier(identifier.names,
                  identifier.getParserPosition());
            }
          });
          System.out.println(sqlNodeVisited.toString());
        }
      


      Method threw 'java.lang.UnsupportedOperationException' exception. Cannot evaluate org.apache.calcite.sql.SqlBasicCall.toString()

      SqlInsert is a SqlSpecialOperator, when `toString` method is called, this problem is shown.We can see that `SqlSyntax#SPECIAL#unparse()` hasn't been implemented yet.

      exception :
      java.lang.UnsupportedOperationException: class org.apache.calcite.sql.SqlSyntax$6: SPECIAL

      at org.apache.calcite.util.Util.needToImplement(Util.java:967)
      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116)
      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:333)
      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:462)
      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:104)
      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:151)
      at org.apache.calcite.sql.SqlNode.toString(SqlNode.java:126)

        Attachments

          Activity

            People

            • Assignee:
              yanlin-Lynn Wang Yanlin
              Reporter:
              xzh_dz xzh_dz
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 3h 10m
                3h 10m