Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-17568

HiveJoinPushTransitivePredicatesRule may exchange predicates which are not valid on the other branch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0
    • Logical Optimizer
    • None

    Description

      Joining 2 tables on at least 1 column which is not the same type ; (integer/double for example).

      The calcite expressions require double/integer inputs which will became invalid if HiveJoinPushTransitivePredicatesRule pushes them to the other branch.

      query:

      create table t1 (v string, k int);
      insert into t1 values ('people', 10), ('strangers', 20), ('parents', 30);
      
      create table t2 (v string, k double);
      insert into t2 values ('people', 10), ('strangers', 20), ('parents', 30);
      
      select * from t1 where t1.k in (select t2.k from t2 where t2.v='people') and t1.k<15;
      

      results in:

      java.lang.AssertionError: type mismatch:
      type1:
      DOUBLE
      type2:
      INTEGER
      	at org.apache.calcite.util.Litmus$1.fail(Litmus.java:31)
      	at org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:1841)
      	at org.apache.calcite.rex.RexProgramBuilder$RegisterInputShuttle.visitInputRef(RexProgramBuilder.java:941)
      	at org.apache.calcite.rex.RexProgramBuilder$RegisterInputShuttle.visitInputRef(RexProgramBuilder.java:919)
      	at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112)
      	at org.apache.calcite.rex.RexShuttle.visitList(RexShuttle.java:153)
      	at org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:102)
      	at org.apache.calcite.rex.RexProgramBuilder$RegisterShuttle.visitCall(RexProgramBuilder.java:884)
      	at org.apache.calcite.rex.RexProgramBuilder$RegisterShuttle.visitCall(RexProgramBuilder.java:882)
      	at org.apache.calcite.rex.RexCall.accept(RexCall.java:104)
      	at org.apache.calcite.rex.RexProgramBuilder.registerInput(RexProgramBuilder.java:296)
      	at org.apache.calcite.rex.RexProgramBuilder.addCondition(RexProgramBuilder.java:271)
      	at org.apache.calcite.rel.rules.FilterMergeRule.createProgram(FilterMergeRule.java:98)
      	at org.apache.calcite.rel.rules.FilterMergeRule.onMatch(FilterMergeRule.java:67)
      [...]
      

      Attachments

        1. HIVE-17568.01.patch
          4 kB
          Zoltan Haindrich
        2. HIVE-17568.02.patch
          8 kB
          Zoltan Haindrich
        3. HIVE-17568.03.patch
          8 kB
          Zoltan Haindrich

        Activity

          People

            kgyrtkirk Zoltan Haindrich
            kgyrtkirk Zoltan Haindrich
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: