use of org.apache.calcite.plan.volcano.VolcanoPlanner in project hive by apache.
the class HiveVolcanoPlanner method createPlanner.
public static RelOptPlanner createPlanner(HivePlannerContext conf) {
final VolcanoPlanner planner = new HiveVolcanoPlanner(conf);
planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
if (ENABLE_COLLATION_TRAIT) {
planner.addRelTraitDef(RelCollationTraitDef.INSTANCE);
}
if (ENABLE_DISTRIBUTION_TRAIT) {
planner.addRelTraitDef(RelDistributionTraitDef.INSTANCE);
}
return planner;
}
use of org.apache.calcite.plan.volcano.VolcanoPlanner in project calcite by apache.
the class MaterializedViewFilterScanRule method apply.
protected void apply(RelOptRuleCall call, Filter filter, TableScan scan) {
RelOptPlanner planner = call.getPlanner();
List<RelOptMaterialization> materializations = (planner instanceof VolcanoPlanner) ? ((VolcanoPlanner) planner).getMaterializations() : ImmutableList.<RelOptMaterialization>of();
if (!materializations.isEmpty()) {
RelNode root = filter.copy(filter.getTraitSet(), Collections.singletonList((RelNode) scan));
List<RelOptMaterialization> applicableMaterializations = RelOptMaterializations.getApplicableMaterializations(root, materializations);
for (RelOptMaterialization materialization : applicableMaterializations) {
if (RelOptUtil.areRowTypesEqual(scan.getRowType(), materialization.queryRel.getRowType(), false)) {
RelNode target = materialization.queryRel;
final HepPlanner hepPlanner = new HepPlanner(program, planner.getContext());
hepPlanner.setRoot(target);
target = hepPlanner.findBestExp();
List<RelNode> subs = new MaterializedViewSubstitutionVisitor(target, root).go(materialization.tableRel);
for (RelNode s : subs) {
call.transformTo(s);
}
}
}
}
}
Aggregations