diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/RelOptHiveTable.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/RelOptHiveTable.java index 4ea877e..746b107 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/RelOptHiveTable.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/RelOptHiveTable.java @@ -78,7 +78,6 @@ PrunedPartitionList partitionList; Map partitionCache; AtomicInteger noColsMissingStats; - private final String qbID; protected static final Log LOG = LogFactory .getLog(RelOptHiveTable.class @@ -87,8 +86,7 @@ public RelOptHiveTable(RelOptSchema calciteSchema, String qualifiedTblName, RelDataType rowType, Table hiveTblMetadata, List hiveNonPartitionCols, List hivePartitionCols, List hiveVirtualCols, HiveConf hconf, - Map partitionCache, AtomicInteger noColsMissingStats, - String qbID) { + Map partitionCache, AtomicInteger noColsMissingStats) { super(calciteSchema, qualifiedTblName, rowType); this.hiveTblMetadata = hiveTblMetadata; this.hiveNonPartitionCols = ImmutableList.copyOf(hiveNonPartitionCols); @@ -100,7 +98,6 @@ public RelOptHiveTable(RelOptSchema calciteSchema, String qualifiedTblName, this.hiveConf = hconf; this.partitionCache = partitionCache; this.noColsMissingStats = noColsMissingStats; - this.qbID = qbID; } public RelOptHiveTable copy(RelDataType newRowType) { @@ -136,7 +133,7 @@ public RelOptHiveTable copy(RelDataType newRowType) { // 3. Build new Table return new RelOptHiveTable(this.schema, this.name, newRowType, this.hiveTblMetadata, newHiveNonPartitionCols, newHivePartitionCols, newHiveVirtualCols, - this.hiveConf, this.partitionCache, this.noColsMissingStats, qbID); + this.hiveConf, this.partitionCache, this.noColsMissingStats); } @Override @@ -443,10 +440,6 @@ public boolean containsPartitionColumnsOnly(ImmutableBitSet cols) { return this.hiveNonPartitionCols; } - public String getQBID() { - return qbID; - } - public int getNoOfNonVirtualCols() { return noOfNonVirtualCols; } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableScan.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableScan.java index e81cafe..3d45a01 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableScan.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableScan.java @@ -58,11 +58,16 @@ private final RelDataType hiveTableScanRowType; private final ImmutableList neededColIndxsFrmReloptHT; private final String tblAlias; + private final String qbID; public String getTableAlias() { return tblAlias; } + public String getQbID() { + return qbID; + } + /** * Creates a HiveTableScan. * @@ -75,15 +80,16 @@ public String getTableAlias() { * @param table * HiveDB table */ - public HiveTableScan(RelOptCluster cluster, RelTraitSet traitSet, RelOptHiveTable table, String alias) { - this(cluster, traitSet, table, alias, table.getRowType()); + public HiveTableScan(RelOptCluster cluster, RelTraitSet traitSet, RelOptHiveTable table, String alias, String qbID) { + this(cluster, traitSet, table, alias, qbID, table.getRowType()); } - private HiveTableScan(RelOptCluster cluster, RelTraitSet traitSet, RelOptHiveTable table, String alias, + private HiveTableScan(RelOptCluster cluster, RelTraitSet traitSet, RelOptHiveTable table, String alias, String qbID, RelDataType newRowtype) { super(cluster, TraitsUtil.getDefaultTraitSet(cluster), table); assert getConvention() == HiveRelNode.CONVENTION; this.tblAlias = alias; + this.qbID = qbID; this.hiveTableScanRowType = newRowtype; this.neededColIndxsFrmReloptHT = buildNeededColIndxsFrmReloptHT(table.getRowType(), newRowtype); } @@ -102,7 +108,7 @@ public RelNode copy(RelTraitSet traitSet, List inputs) { * @return */ public HiveTableScan copy(RelDataType newRowtype) { - return new HiveTableScan(getCluster(), getTraitSet(), ((RelOptHiveTable) table), this.tblAlias, + return new HiveTableScan(getCluster(), getTraitSet(), ((RelOptHiveTable) table), this.tblAlias, this.qbID, newRowtype); } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java index 22b4a13..3afcb54 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java @@ -243,7 +243,7 @@ OpAttr visit(HiveTableScan scanRel) { // 2. Setup TableScan TableScanOperator ts = (TableScanOperator) OperatorFactory.get(tsd, new RowSchema(colInfos)); - topOps.put(ht.getQBID(), ts); + topOps.put(scanRel.getQbID(), ts); if (LOG.isDebugEnabled()) { LOG.debug("Generated " + ts + " with row schema: [" + ts.getSchema() + "]"); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java index 60d4677..8b78471 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java @@ -1357,10 +1357,10 @@ private RelNode genTableLogicalPlan(String tableAlias, QB qb) throws SemanticExc } RelOptHiveTable optTable = new RelOptHiveTable(relOptSchema, fullyQualifiedTabName, rowType, tabMetaData, nonPartitionColumns, partitionColumns, virtualCols, conf, - partitionCache, noColsMissingStats, getAliasId(tableAlias, qb)); + partitionCache, noColsMissingStats); // 5. Build Hive Table Scan Rel - tableRel = new HiveTableScan(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION), optTable, null == tableAlias ? tabMetaData.getTableName() : tableAlias); + tableRel = new HiveTableScan(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION), optTable, null == tableAlias ? tabMetaData.getTableName() : tableAlias, getAliasId(tableAlias, qb)); // 6. Add Schema(RR) to RelNode-Schema map ImmutableMap hiveToCalciteColMap = buildHiveToCalciteColumnMap(rr,