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

Type mismatch for ANY subquery in project

    XMLWordPrintableJSON

Details

    Description

      Repro:

      @Test public void testGtAnyInProject() {
          final String sql = "select name, \n"
              + " deptno > ANY (\n"
              + " select deptno from emp) \n"
              + " from dept";
          checkSubQuery(sql).withLateDecorrelation(true).check();
        }
      

      Exception:

      java.lang.AssertionError: Cannot add expression of different type to set:
      set type is RecordType(VARCHAR(10) NOT NULL NAME, BOOLEAN NOT NULL EXPR$1) NOT NULL
      expression type is RecordType(VARCHAR(10) NOT NULL NAME, BOOLEAN EXPR$1) NOT NULL
      set is rel#5:LogicalProject(input=HepRelVertex#4,NAME=$1,EXPR$1=> SOME($0, {
      LogicalProject(DEPTNO=[$7])
        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      }))
      expression is LogicalProject(NAME=[$1], EXPR$1=[OR(AND(IS TRUE(>($0, $2)), <>($3, 0)), AND(>($3, $4), null, <>($3, 0), IS NOT TRUE(>($0, $2))), AND(>($0, $2), <>($3, 0), IS NOT TRUE(>($0, $2)), <=($3, $4)))])
        LogicalJoin(condition=[true], joinType=[inner])
          LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
          LogicalAggregate(group=[{}], m=[MIN($0)], c=[COUNT()], d=[COUNT($0)])
            LogicalProject(DEPTNO=[$7])
              LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      
      
      	at org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:382)
      	at org.apache.calcite.plan.hep.HepRuleCall.transformTo(HepRuleCall.java:57)
      	at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:236)
      	at org.apache.calcite.rel.rules.SubQueryRemoveRule$SubQueryProjectRemoveRule.onMatch(SubQueryRemoveRule.java:519)
      

      Attachments

        Issue Links

          Activity

            People

              vgarg Vineet Garg
              hyuan Haisheng Yuan
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 1h 20m
                  1h 20m