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

ROW function can not work with RewriteIntersectAllRule

    XMLWordPrintableJSON

Details

    Description

      Reproduce case:

      create table row_sink (
        `b` ROW<b1 STRING, b2 INT>
      ) with (
        'connector' = 'values'
      )
      
      util.verifyRelPlanInsert(
      "INSERT INTO row_sink " +
        "SELECT ROW(a, b) FROM complex_type_src intersect all " +
        "SELECT ROW(c, d) FROM complex_type_src ")
      
      

      It will fails with

      Caused by: java.lang.IllegalArgumentException: Type mismatch:
      rel rowtype: RecordType(RecordType:peek_no_expand(VARCHAR(2147483647) CHARACTER SET "UTF-16LE" EXPR$0, INTEGER EXPR$1) NOT NULL EXPR$0) NOT NULL
      equiv rowtype: RecordType(RecordType(VARCHAR(2147483647) CHARACTER SET "UTF-16LE" EXPR$0, INTEGER EXPR$1) NOT NULL EXPR$0) NOT NULL
      Difference:
      EXPR$0: RecordType:peek_no_expand(VARCHAR(2147483647) CHARACTER SET "UTF-16LE" EXPR$0, INTEGER EXPR$1) NOT NULL -> RecordType(VARCHAR(2147483647) CHARACTER SET "UTF-16LE" EXPR$0, INTEGER EXPR$1) NOT NULL
      
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.register(VolcanoPlanner.java:592)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:613)
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.transformTo(VolcanoRuleCall.java:144)
      	... 68 more
      

      The reason is:

      ROW function will generates the FULLY_QUALIFIED type. But after the RewriteIntersectAllRule optimization, it will produce the PEEK_FIELDS_NO_EXPAND. So the volcano planner complains with type mismatch.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              aitozi WenJun Min
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: