Search in sources :

Example 1 with DrillConstExecutor

use of org.apache.drill.exec.planner.logical.DrillConstExecutor in project drill by apache.

the class SqlConverter method toRel.

public RelNode toRel(final SqlNode validatedNode) {
    final RexBuilder rexBuilder = new DrillRexBuilder(typeFactory);
    if (planner == null) {
        planner = new VolcanoPlanner(costFactory, settings);
        planner.setExecutor(new DrillConstExecutor(functions, util, settings));
        planner.clearRelTraitDefs();
        planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
        planner.addRelTraitDef(DrillDistributionTraitDef.INSTANCE);
        planner.addRelTraitDef(RelCollationTraitDef.INSTANCE);
    }
    final RelOptCluster cluster = RelOptCluster.create(planner, rexBuilder);
    final SqlToRelConverter sqlToRelConverter = new SqlToRelConverter(new Expander(), validator, catalog, cluster, DrillConvertletTable.INSTANCE, sqlToRelConverterConfig);
    final RelNode rel = sqlToRelConverter.convertQuery(validatedNode, false, !isInnerQuery);
    final RelNode rel2 = sqlToRelConverter.flattenTypes(rel, true);
    final RelNode rel3 = RelDecorrelator.decorrelateQuery(rel2);
    return rel3;
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) SqlToRelConverter(org.apache.calcite.sql2rel.SqlToRelConverter) RelNode(org.apache.calcite.rel.RelNode) RexBuilder(org.apache.calcite.rex.RexBuilder) VolcanoPlanner(org.apache.calcite.plan.volcano.VolcanoPlanner) DrillConstExecutor(org.apache.drill.exec.planner.logical.DrillConstExecutor)

Example 2 with DrillConstExecutor

use of org.apache.drill.exec.planner.logical.DrillConstExecutor in project drill by apache.

the class SqlConverter method initPlanner.

private RelOptPlanner initPlanner() {
    if (planner == null) {
        planner = new VolcanoPlanner(costFactory, settings);
        planner.setExecutor(new DrillConstExecutor(functions, util, settings));
        planner.clearRelTraitDefs();
        planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
        planner.addRelTraitDef(DrillDistributionTraitDef.INSTANCE);
        planner.addRelTraitDef(RelCollationTraitDef.INSTANCE);
    }
    return planner;
}
Also used : VolcanoPlanner(org.apache.calcite.plan.volcano.VolcanoPlanner) DrillConstExecutor(org.apache.drill.exec.planner.logical.DrillConstExecutor)

Example 3 with DrillConstExecutor

use of org.apache.drill.exec.planner.logical.DrillConstExecutor in project drill by axbaretto.

the class SqlConverter method toRel.

public RelRoot toRel(final SqlNode validatedNode) {
    if (planner == null) {
        planner = new VolcanoPlanner(costFactory, settings);
        planner.setExecutor(new DrillConstExecutor(functions, util, settings));
        planner.clearRelTraitDefs();
        planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
        planner.addRelTraitDef(DrillDistributionTraitDef.INSTANCE);
        planner.addRelTraitDef(RelCollationTraitDef.INSTANCE);
    }
    if (cluster == null) {
        initCluster();
    }
    final SqlToRelConverter sqlToRelConverter = new SqlToRelConverter(new Expander(), validator, catalog, cluster, DrillConvertletTable.INSTANCE, sqlToRelConverterConfig);
    /*
     * Sets value to false to avoid simplifying project expressions
     * during creating new projects since it may cause changing data mode
     * which causes to assertion errors during type validation
     */
    Hook.REL_BUILDER_SIMPLIFY.add(Hook.property(false));
    // To avoid unexpected column errors set a value of top to false
    final RelRoot rel = sqlToRelConverter.convertQuery(validatedNode, false, false);
    final RelRoot rel2 = rel.withRel(sqlToRelConverter.flattenTypes(rel.rel, true));
    final RelRoot rel3 = rel2.withRel(RelDecorrelator.decorrelateQuery(rel2.rel));
    return rel3;
}
Also used : SqlToRelConverter(org.apache.calcite.sql2rel.SqlToRelConverter) VolcanoPlanner(org.apache.calcite.plan.volcano.VolcanoPlanner) DrillConstExecutor(org.apache.drill.exec.planner.logical.DrillConstExecutor) RelRoot(org.apache.calcite.rel.RelRoot)

Aggregations

VolcanoPlanner (org.apache.calcite.plan.volcano.VolcanoPlanner)3 DrillConstExecutor (org.apache.drill.exec.planner.logical.DrillConstExecutor)3 SqlToRelConverter (org.apache.calcite.sql2rel.SqlToRelConverter)2 RelOptCluster (org.apache.calcite.plan.RelOptCluster)1 RelNode (org.apache.calcite.rel.RelNode)1 RelRoot (org.apache.calcite.rel.RelRoot)1 RexBuilder (org.apache.calcite.rex.RexBuilder)1