Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-22654

SqlCreateTable toString()/unparse() lose CONSTRAINTS and watermarks

    XMLWordPrintableJSON

    Details

      Description

      create a SqlCreateTable using like clause   and then toString() or unparse()  will lose watermark 

      if  no column. 

      public static SqlParser getSqlParser(String sql) {
          SourceStringReader sqlReader = new SourceStringReader(sql);
      
          return SqlParser.create(sqlReader,
                  SqlParser.configBuilder()
                          .setParserFactory(FlinkSqlParserImpl.FACTORY)
                          .setLex(Lex.JAVA)
                          .setIdentifierMaxLength(256)
                          .setConformance(FlinkSqlConformance.DEFAULT)
                          .build());
      }
      
      public static void main(String[] args) throws Exception {
      
      
          SqlParser sqlParser = getSqlParser("" +
                  "create TEMPORARY table t_order_course (\n" +
                  "   WATERMARK FOR last_update_time AS last_update_time - INTERVAL '5' SECOND\n" +
                  ") with (\n" +
                  "  'scan.startup.mode' = 'specific-offsets',\n" +
                  "  'scan.startup.specific-offsets' = 'partition:0,offset:1169129'\n" +
                  ") like cdc.`qq_data(sh-backend-tst:3306)`.t_order_course (\n" +
                  "   OVERWRITING  WATERMARKS\n" +
                  "   OVERWRITING OPTIONS\n" +
                  "   EXCLUDING CONSTRAINTS\n" +
                  " \n" +
                  ")");
          SqlNode sqlNode = sqlParser.parseStmt();
      
          System.out.println(sqlNode.toString());
      
      }
      

      output:

      CREATE TEMPORARY TABLE `t_order_course` WITH ( 'scan.startup.mode' = 'specific-offsets', 'scan.startup.specific-offsets' = 'partition:0,offset:1169129' ) LIKE `cdc`.`qq_data(sh-backend-tst:3306)`.`t_order_course` ( OVERWRITING WATERMARKS OVERWRITING OPTIONS EXCLUDING CONSTRAINTS )

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Terry1897 Terry Wang
                Reporter:
                qin1040392240 youxianq
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: