use of org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan in project hive by apache.
the class HiveIncrementalRelMdRowCount method getRowCount.
@Override
public Double getRowCount(TableScan rel, RelMetadataQuery mq) {
if (!(rel instanceof HiveTableScan)) {
return super.getRowCount(rel, mq);
}
HiveTableScan tableScan = (HiveTableScan) rel;
RelOptHiveTable relOptHiveTable = (RelOptHiveTable) tableScan.getTable();
org.apache.hadoop.hive.ql.metadata.Table table = relOptHiveTable.getHiveTableMD();
String fullyQualifiedName = TableName.getQualified(table.getCatName(), table.getDbName(), table.getTableName());
SourceTable sourceTable = sourceTableMap.get(fullyQualifiedName);
if (sourceTable == null) {
return super.getRowCount(rel, mq);
}
return (double) sourceTable.getInsertedCount();
}
use of org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan in project hive by apache.
the class HivePartitionPruneRule method perform.
protected void perform(RelOptRuleCall call, Filter filter, HiveTableScan tScan) {
// Original table
RelOptHiveTable hiveTable = (RelOptHiveTable) tScan.getTable();
// Copy original table scan and table
HiveTableScan tScanCopy = tScan.copyIncludingTable(tScan.getRowType());
RelOptHiveTable hiveTableCopy = (RelOptHiveTable) tScanCopy.getTable();
// Execute partition pruning
RexNode predicate = filter.getCondition();
Pair<RexNode, RexNode> predicates = PartitionPrune.extractPartitionPredicates(filter.getCluster(), hiveTableCopy, predicate);
RexNode partColExpr = predicates.left;
hiveTableCopy.computePartitionList(conf, partColExpr, tScanCopy.getPartOrVirtualCols());
if (StringUtils.equals(hiveTableCopy.getPartitionListKey(), hiveTable.getPartitionListKey())) {
// Nothing changed, we do not need to produce a new expression
return;
}
call.transformTo(filter.copy(filter.getTraitSet(), Collections.singletonList(tScanCopy)));
}
use of org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan in project hive by apache.
the class HiveRelFieldTrimmer method fetchColStats.
private void fetchColStats(RelNode key, TableScan tableAccessRel, ImmutableBitSet fieldsUsed, Set<RelDataTypeField> extraFields) {
final List<Integer> iRefSet = Lists.newArrayList();
if (key instanceof Project) {
final Project project = (Project) key;
for (RexNode rx : project.getProjects()) {
iRefSet.addAll(HiveCalciteUtil.getInputRefs(rx));
}
} else {
final int fieldCount = tableAccessRel.getRowType().getFieldCount();
if (fieldsUsed.equals(ImmutableBitSet.range(fieldCount)) && extraFields.isEmpty()) {
// get all cols
iRefSet.addAll(ImmutableBitSet.range(fieldCount).asList());
}
}
// Remove any virtual cols
if (tableAccessRel instanceof HiveTableScan) {
iRefSet.removeAll(((HiveTableScan) tableAccessRel).getVirtualCols());
}
if (!iRefSet.isEmpty()) {
final RelOptTable table = tableAccessRel.getTable();
if (table instanceof RelOptHiveTable) {
((RelOptHiveTable) table).getColStat(iRefSet, true);
LOG.debug("Got col stats for {} in {}", iRefSet, tableAccessRel.getTable().getQualifiedName());
}
}
}
Aggregations