[ https://issues.apache.org/jira/browse/HIVE-17568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16178773#comment-16178773 ]
Zoltan Haindrich commented on HIVE-17568: ----------------------------------------- the problem arises from the fact that the two types differ in nullability: {code} import static org.junit.Assert.assertEquals; import org.apache.calcite.jdbc.JavaTypeFactoryImpl; import org.apache.calcite.rel.type.RelDataType; import org.apache.calcite.sql.type.SqlTypeName; import org.junit.Ignore; import org.junit.Test; public class CalciteTypeCompare { JavaTypeFactoryImpl typeFactory = new JavaTypeFactoryImpl(); RelDataType b0 = typeFactory.builder().add("t", SqlTypeName.BOOLEAN).nullable(true).build(); RelDataType b1 = typeFactory.builder().add("t", SqlTypeName.BOOLEAN).nullable(false).build(); RelDataType b1x = typeFactory.builder().add("x", SqlTypeName.BOOLEAN).nullable(false).build(); @Test @Ignore("this test case will fail; because these types are different") public void compareTypesIgnoringNullability() { assertEquals(b0, b1); } @Test public void typeSqlNameEquals() { assertEquals(b0.getSqlTypeName(), b1.getSqlTypeName()); } @Test public void typeSqlNameEqualsIgnoresFieldName() { assertEquals(b0.getSqlTypeName(), b1x.getSqlTypeName()); } } {code} I complement the patch with an addition check for the {{sqlTypeName()}} > HiveJoinPushTransitivePredicatesRule may exchange predicates which are not > valid on the other branch > ---------------------------------------------------------------------------------------------------- > > Key: HIVE-17568 > URL: https://issues.apache.org/jira/browse/HIVE-17568 > Project: Hive > Issue Type: Bug > Components: Logical Optimizer > Reporter: Zoltan Haindrich > Assignee: Zoltan Haindrich > Attachments: HIVE-17568.01.patch, HIVE-17568.02.patch > > > 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: > {code} > 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; > {code} > results in: > {code} > 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) > [...] > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)