diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableScan.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableScan.java index cccbd2f..e0ef82b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableScan.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableScan.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Set; +import com.google.common.collect.Lists; import org.apache.calcite.plan.RelOptCluster; import org.apache.calcite.plan.RelOptCost; import org.apache.calcite.plan.RelOptPlanner; @@ -47,6 +48,8 @@ import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Relational expression representing a scan of a HiveDB collection. @@ -67,6 +70,8 @@ // insiderView will tell this TableScan is inside a view or not. private final boolean insideView; + private static final Logger LOG = LoggerFactory.getLogger(HiveTableScan.class); + public String getTableAlias() { return tblAlias; } @@ -194,6 +199,17 @@ public RelNode project(ImmutableBitSet fieldsUsed, Set extraFi HiveProject hp = (HiveProject) relBuilder.push(newHT) .project(exprList, new ArrayList(fieldNames)).build(); + // Get stats for relevant cols + List iRefSet = Lists.newArrayList(); + for(RexNode rx: hp.getChildExps()) { + iRefSet.addAll(HiveCalciteUtil.getInputRefs(rx)); + } + if (!iRefSet.isEmpty()) { + LOG.info("Getting stats for cols {}, fieldNames {} in {} with alias {}", + iRefSet, fieldNames, getTable().getQualifiedName(), getTableAlias()); + getColStat(iRefSet); + } + // 6. Set synthetic flag, so that we would push filter below this one hp.setSynthetic();