Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIVE-28252: AssertionError when using HiveTableScan with a HepPlanner cluster #5244

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private HiveTableScan(RelOptCluster cluster, RelTraitSet traitSet, RelOptHiveTab
String alias, String concatQbIDAlias, RelDataType newRowtype, boolean useQBIdInDigest, boolean insideView,
HiveTableScanTrait tableScanTrait) {
super(cluster, TraitsUtil.getDefaultTraitSet(cluster), table);
assert getConvention() == HiveRelNode.CONVENTION;
assert getTraitSet().containsIfApplicable(HiveRelNode.CONVENTION);
this.tblAlias = alias;
this.concatQbIDAlias = concatQbIDAlias;
this.hiveTableScanRowType = newRowtype;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hive.ql.optimizer.calcite.reloperators;

import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
import org.apache.calcite.plan.ConventionTraitDef;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.hep.HepPlanner;
import org.apache.calcite.plan.hep.HepProgram;
import org.apache.calcite.plan.volcano.VolcanoPlanner;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.metadata.Table;
import org.apache.hadoop.hive.ql.optimizer.calcite.RelOptHiveTable;
import org.apache.hadoop.hive.ql.parse.QueryTables;

import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class TestHiveTableScan {

@Test
public void testGetConventionWithWithHepPlannerCluster() {
RelNode scan = createScanWithPlanner(new HepPlanner(HepProgram.builder().build()));
assertNull(scan.getConvention());
}

@Test
public void testGetConventionWithVolcanoPlannerCluster() {
RelNode scan = createScanWithPlanner(new VolcanoPlanner());
assertEquals(HiveRelNode.CONVENTION, scan.getConvention());
}

private static RelNode createScanWithPlanner(RelOptPlanner planner) {
JavaTypeFactoryImpl typeFactory = new JavaTypeFactoryImpl();
planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
RelOptCluster cluster = RelOptCluster.create(planner, new RexBuilder(typeFactory));
return new HiveTableScan(cluster, cluster.traitSet(), dummyRelOptTable(typeFactory), "alias", "alias", false,
false);
}

private static RelOptHiveTable dummyRelOptTable(RelDataTypeFactory factory) {
RelDataType tblType = factory.builder().add("col1", SqlTypeName.INTEGER).add("col2", SqlTypeName.VARCHAR).build();
Table tblMeta = new Table("default", "dummy");
return new RelOptHiveTable(null, factory, Arrays.asList("default", "dummy"), tblType, tblMeta,
Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), new HiveConf(), null,
new QueryTables(), new HashMap<>(), new HashMap<>(), new AtomicInteger(0));
}
}
Loading