Search in sources :

Example 11 with VolcanoPlanner

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;
}
Also used : VolcanoPlanner(org.apache.calcite.plan.volcano.VolcanoPlanner)

Example 12 with VolcanoPlanner

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);
                }
            }
        }
    }
}
Also used : RelNode(org.apache.calcite.rel.RelNode) RelOptMaterialization(org.apache.calcite.plan.RelOptMaterialization) VolcanoPlanner(org.apache.calcite.plan.volcano.VolcanoPlanner) HepPlanner(org.apache.calcite.plan.hep.HepPlanner) RelOptPlanner(org.apache.calcite.plan.RelOptPlanner) MaterializedViewSubstitutionVisitor(org.apache.calcite.plan.MaterializedViewSubstitutionVisitor)

Aggregations

VolcanoPlanner (org.apache.calcite.plan.volcano.VolcanoPlanner)12 RelNode (org.apache.calcite.rel.RelNode)6 RelOptPlanner (org.apache.calcite.plan.RelOptPlanner)5 RelOptMaterialization (org.apache.calcite.plan.RelOptMaterialization)3 RelOptRule (org.apache.calcite.plan.RelOptRule)3 HepPlanner (org.apache.calcite.plan.hep.HepPlanner)3 DrillConstExecutor (org.apache.drill.exec.planner.logical.DrillConstExecutor)3 RelTraitSet (org.apache.calcite.plan.RelTraitSet)2 HepProgramBuilder (org.apache.calcite.plan.hep.HepProgramBuilder)2 JaninoRelMetadataProvider (org.apache.calcite.rel.metadata.JaninoRelMetadataProvider)2 RexBuilder (org.apache.calcite.rex.RexBuilder)2 SqlToRelConverter (org.apache.calcite.sql2rel.SqlToRelConverter)2 Program (org.apache.calcite.tools.Program)2 RuleSet (org.apache.calcite.tools.RuleSet)2 Stopwatch (com.google.common.base.Stopwatch)1 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 ImmutableList (com.google.common.collect.ImmutableList)1 DistributionTraitDef (com.hazelcast.jet.sql.impl.opt.distribution.DistributionTraitDef)1 QueryConverter (com.hazelcast.jet.sql.impl.parse.QueryConverter)1