Source:
@Test public void testRelNodeCacheWithDigest() { HepProgramBuilder programBuilder = HepProgram.builder(); programBuilder.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE); programBuilder.addRuleInstance(ReduceExpressionsRule.CALC_INSTANCE); programBuilder.addRuleInstance(ProjectMergeRule.INSTANCE); HepPlanner planner = new HepPlanner(programBuilder.build()); RelBuilder relBuilder = RelBuilder.create(RelBuilderTest.config().build()); RelDataTypeFactory typeFactory = relBuilder.getTypeFactory(); RelDataType longType = typeFactory.createSqlType(SqlTypeName.BIGINT); RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER); RelDataType doubleType = typeFactory.createSqlType(SqlTypeName.DOUBLE); RelNode values = relBuilder .values(new String[] {"f1", "f2", "f3"}, 1, 2, 3) .build(); RelNode p1 = relBuilder .push(values) .project(relBuilder.getRexBuilder().makeLiteral(1, intType, false), relBuilder.getRexBuilder().makeLiteral(2, longType, false), relBuilder.getRexBuilder().makeLiteral(3.0D, doubleType, false)) .build(); RelNode p2 = relBuilder .push(values) .project(relBuilder.getRexBuilder().makeLiteral(1, longType, false), relBuilder.getRexBuilder().makeLiteral(2, intType, false), relBuilder.getRexBuilder().makeLiteral(3.0D, doubleType, false)) .build(); RelNode r = relBuilder .push(p1) .push(p2) .union(true) .build(); planner.setRoot(r); RelNode bestRel = planner.findBestExp(); assertThat(r.getInput(0).getRowType().equals(r.getInput(1).getRowType()), is(false)); assertThat(bestRel.getInput(0).getRowType().equals(bestRel.getInput(1).getRowType()), is(false)); }

Target:
@Test public void testRelNodeCacheWithDigest() { HepProgramBuilder programBuilder = HepProgram.builder(); programBuilder.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE); programBuilder.addRuleInstance(ReduceExpressionsRule.CALC_INSTANCE); programBuilder.addRuleInstance(ProjectMergeRule.INSTANCE); HepPlanner planner = new HepPlanner(programBuilder.build()); RelBuilder relBuilder = RelBuilder.create(RelBuilderTest.config().build()); RelDataTypeFactory typeFactory = relBuilder.getTypeFactory(); RelDataType longType = typeFactory.createSqlType(SqlTypeName.BIGINT); RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER); RelDataType doubleType = typeFactory.createSqlType(SqlTypeName.DOUBLE); RelNode values = relBuilder .values(new String[] {"f1", "f2", "f3"}, 1, 2, 3) .build(); RelNode p1 = relBuilder .push(values) .project(relBuilder.getRexBuilder().makeLiteral(1, intType, false), relBuilder.getRexBuilder().makeLiteral(2, longType, false), relBuilder.getRexBuilder().makeLiteral(3.0D, doubleType, false)) .build(); RelNode p2 = relBuilder .push(values) .project(relBuilder.getRexBuilder().makeLiteral(1, longType, false), relBuilder.getRexBuilder().makeLiteral(2, intType, false), relBuilder.getRexBuilder().makeLiteral(3.0D, doubleType, false)) .build(); RelNode r = relBuilder .push(p1) .push(p2) .union(true) .build(); planner.setRoot(r); RelNode bestRel = planner.findBestExp(); assertThat(r.getInput(0).getRowType().equals(r.getInput(1).getRowType()), is(false)); assertThat("The two inputs should have different row types after planner promotion.", bestRel.getInput(0).getRowType().equals(bestRel.getInput(1).getRowType()), is(false)); }