use of org.apache.calcite.rel.core.Project in project hive by apache.
the class HiveProjectMergeRule method onMatch.
public void onMatch(RelOptRuleCall call) {
final Project topProject = call.rel(0);
final Project bottomProject = call.rel(1);
// If top project does not reference any column at the bottom project,
// we can just remove botton project
final ImmutableBitSet topRefs = RelOptUtil.InputFinder.bits(topProject.getProjects(), null);
if (topRefs.isEmpty()) {
RelBuilder relBuilder = call.builder();
relBuilder.push(bottomProject.getInput());
relBuilder.project(topProject.getProjects());
call.transformTo(relBuilder.build());
return;
}
super.onMatch(call);
}
use of org.apache.calcite.rel.core.Project in project hive by apache.
the class HiveFilterProjectTransposeRule method onMatch.
public void onMatch(RelOptRuleCall call) {
final Filter filter = call.rel(0);
final Project origproject = call.rel(1);
RexNode filterCondToPushBelowProj = filter.getCondition();
RexNode unPushedFilCondAboveProj = null;
if (RexUtil.containsCorrelation(filterCondToPushBelowProj)) {
// Correlate from being de-correlated.
return;
}
if (RexOver.containsOver(origproject.getProjects(), null)) {
RexNode origFilterCond = filterCondToPushBelowProj;
filterCondToPushBelowProj = null;
if (pushThroughWindowing) {
Set<Integer> commonPartitionKeys = getCommonPartitionCols(origproject.getProjects());
List<RexNode> newPartKeyFilConds = new ArrayList<>();
List<RexNode> unpushedFilConds = new ArrayList<>();
// from t1 where value < 10)t1)t2
if (!commonPartitionKeys.isEmpty()) {
for (RexNode ce : RelOptUtil.conjunctions(origFilterCond)) {
RexNode newCondition = RelOptUtil.pushPastProject(ce, origproject);
if (HiveCalciteUtil.isDeterministicFuncWithSingleInputRef(newCondition, commonPartitionKeys)) {
newPartKeyFilConds.add(ce);
} else {
unpushedFilConds.add(ce);
}
}
if (!newPartKeyFilConds.isEmpty()) {
filterCondToPushBelowProj = RexUtil.composeConjunction(filter.getCluster().getRexBuilder(), newPartKeyFilConds, true);
}
if (!unpushedFilConds.isEmpty()) {
unPushedFilCondAboveProj = RexUtil.composeConjunction(filter.getCluster().getRexBuilder(), unpushedFilConds, true);
}
}
}
}
if (filterCondToPushBelowProj != null && !isRedundantIsNotNull(origproject, filterCondToPushBelowProj)) {
RelNode newProjRel = getNewProject(filterCondToPushBelowProj, unPushedFilCondAboveProj, origproject, filter.getCluster().getTypeFactory(), call.builder());
call.transformTo(newProjRel);
}
}
use of org.apache.calcite.rel.core.Project in project hive by apache.
the class HiveAntiSemiJoinRule method onMatch.
// is null filter over a left join.
public void onMatch(final RelOptRuleCall call) {
final Project project = call.rel(0);
final Filter filter = call.rel(1);
final Join join = call.rel(2);
perform(call, project, filter, join);
}
use of org.apache.calcite.rel.core.Project in project hive by apache.
the class HiveMaterializedViewFilterScanRule method onMatch.
//~ Methods ----------------------------------------------------------------
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
final Filter filter = call.rel(1);
final TableScan scan = call.rel(2);
apply(call, project, filter, scan);
}
use of org.apache.calcite.rel.core.Project in project hive by apache.
the class SubstitutionVisitor method toMutable.
private static MutableRel toMutable(RelNode rel) {
if (rel instanceof TableScan) {
return MutableScan.of((TableScan) rel);
}
if (rel instanceof Values) {
return MutableValues.of((Values) rel);
}
if (rel instanceof Project) {
final Project project = (Project) rel;
final MutableRel input = toMutable(project.getInput());
return MutableProject.of(input, project.getProjects(), project.getRowType().getFieldNames());
}
if (rel instanceof Filter) {
final Filter filter = (Filter) rel;
final MutableRel input = toMutable(filter.getInput());
return MutableFilter.of(input, filter.getCondition());
}
if (rel instanceof Aggregate) {
final Aggregate aggregate = (Aggregate) rel;
final MutableRel input = toMutable(aggregate.getInput());
return MutableAggregate.of(input, aggregate.indicator, aggregate.getGroupSet(), aggregate.getGroupSets(), aggregate.getAggCallList());
}
if (rel instanceof Join) {
final Join join = (Join) rel;
final MutableRel left = toMutable(join.getLeft());
final MutableRel right = toMutable(join.getRight());
return MutableJoin.of(join.getCluster(), left, right, join.getCondition(), join.getJoinType(), join.getVariablesSet());
}
if (rel instanceof Sort) {
final Sort sort = (Sort) rel;
final MutableRel input = toMutable(sort.getInput());
return MutableSort.of(input, sort.getCollation(), sort.offset, sort.fetch);
}
throw new RuntimeException("cannot translate " + rel + " to MutableRel");
}
Aggregations