Search in sources :

Example 1 with HiveRulesRegistry

use of org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry in project hive by apache.

the class CalcitePlanner method createPlanner.

private static RelOptPlanner createPlanner(HiveConf conf, Set<RelNode> corrScalarRexSQWithAgg, Set<RelNode> scalarAggNoGbyNoWin) {
    final Double maxSplitSize = (double) HiveConf.getLongVar(conf, HiveConf.ConfVars.MAPREDMAXSPLITSIZE);
    final Double maxMemory = (double) HiveConf.getLongVar(conf, HiveConf.ConfVars.HIVECONVERTJOINNOCONDITIONALTASKTHRESHOLD);
    HiveAlgorithmsConf algorithmsConf = new HiveAlgorithmsConf(maxSplitSize, maxMemory);
    HiveRulesRegistry registry = new HiveRulesRegistry();
    Properties calciteConfigProperties = new Properties();
    calciteConfigProperties.setProperty(CalciteConnectionProperty.TIME_ZONE.camelName(), conf.getLocalTimeZone().getId());
    calciteConfigProperties.setProperty(CalciteConnectionProperty.MATERIALIZATIONS_ENABLED.camelName(), Boolean.FALSE.toString());
    CalciteConnectionConfig calciteConfig = new CalciteConnectionConfigImpl(calciteConfigProperties);
    boolean isCorrelatedColumns = HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_STATS_CORRELATED_MULTI_KEY_JOINS);
    HivePlannerContext confContext = new HivePlannerContext(algorithmsConf, registry, calciteConfig, corrScalarRexSQWithAgg, scalarAggNoGbyNoWin, new HiveConfPlannerContext(isCorrelatedColumns));
    return HiveVolcanoPlanner.createPlanner(confContext);
}
Also used : CalciteConnectionConfigImpl(org.apache.calcite.config.CalciteConnectionConfigImpl) HivePlannerContext(org.apache.hadoop.hive.ql.optimizer.calcite.HivePlannerContext) HiveRulesRegistry(org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry) CalciteConnectionConfig(org.apache.calcite.config.CalciteConnectionConfig) HiveConfPlannerContext(org.apache.hadoop.hive.ql.optimizer.calcite.HiveConfPlannerContext) QueryProperties(org.apache.hadoop.hive.ql.QueryProperties) Properties(java.util.Properties) HiveAlgorithmsConf(org.apache.hadoop.hive.ql.optimizer.calcite.cost.HiveAlgorithmsConf)

Example 2 with HiveRulesRegistry

use of org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry in project hive by apache.

the class CalcitePlanner method createPlanner.

private static RelOptPlanner createPlanner(HiveConf conf, Set<RelNode> corrScalarRexSQWithAgg, StatsSource statsSource, boolean isExplainPlan) {
    final Double maxSplitSize = (double) HiveConf.getLongVar(conf, HiveConf.ConfVars.MAPREDMAXSPLITSIZE);
    final Double maxMemory = (double) HiveConf.getLongVar(conf, HiveConf.ConfVars.HIVECONVERTJOINNOCONDITIONALTASKTHRESHOLD);
    HiveAlgorithmsConf algorithmsConf = new HiveAlgorithmsConf(maxSplitSize, maxMemory);
    HiveRulesRegistry registry = new HiveRulesRegistry();
    Properties calciteConfigProperties = new Properties();
    calciteConfigProperties.setProperty(CalciteConnectionProperty.TIME_ZONE.camelName(), conf.getLocalTimeZone().getId());
    calciteConfigProperties.setProperty(CalciteConnectionProperty.MATERIALIZATIONS_ENABLED.camelName(), Boolean.FALSE.toString());
    CalciteConnectionConfig calciteConfig = new CalciteConnectionConfigImpl(calciteConfigProperties);
    boolean isCorrelatedColumns = HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_CBO_STATS_CORRELATED_MULTI_KEY_JOINS);
    boolean heuristicMaterializationStrategy = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_MATERIALIZED_VIEW_REWRITING_SELECTION_STRATEGY).equals("heuristic");
    HivePlannerContext confContext = new HivePlannerContext(algorithmsConf, registry, calciteConfig, corrScalarRexSQWithAgg, new HiveConfPlannerContext(isCorrelatedColumns, heuristicMaterializationStrategy, isExplainPlan), statsSource);
    RelOptPlanner planner = HiveVolcanoPlanner.createPlanner(confContext);
    planner.addListener(new RuleEventLogger());
    return planner;
}
Also used : CalciteConnectionConfigImpl(org.apache.calcite.config.CalciteConnectionConfigImpl) HivePlannerContext(org.apache.hadoop.hive.ql.optimizer.calcite.HivePlannerContext) HiveRulesRegistry(org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry) CalciteConnectionConfig(org.apache.calcite.config.CalciteConnectionConfig) HiveConfPlannerContext(org.apache.hadoop.hive.ql.optimizer.calcite.HiveConfPlannerContext) QueryProperties(org.apache.hadoop.hive.ql.QueryProperties) Properties(java.util.Properties) RelOptPlanner(org.apache.calcite.plan.RelOptPlanner) HiveAlgorithmsConf(org.apache.hadoop.hive.ql.optimizer.calcite.cost.HiveAlgorithmsConf) RuleEventLogger(org.apache.hadoop.hive.ql.optimizer.calcite.RuleEventLogger)

Example 3 with HiveRulesRegistry

use of org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry in project hive by apache.

the class HiveJoin method copy.

@Override
public final HiveJoin copy(RelTraitSet traitSet, RexNode conditionExpr, RelNode left, RelNode right, JoinRelType joinType, boolean semiJoinDone) {
    try {
        Set<String> variablesStopped = Collections.emptySet();
        HiveJoin join = new HiveJoin(getCluster(), traitSet, left, right, conditionExpr, joinType, variablesStopped, joinAlgorithm);
        // If available, copy state to registry for optimization rules
        HiveRulesRegistry registry = join.getCluster().getPlanner().getContext().unwrap(HiveRulesRegistry.class);
        if (registry != null) {
            registry.copyPushedPredicates(this, join);
        }
        return join;
    } catch (InvalidRelException | CalciteSemanticException e) {
        // internal error.
        throw new AssertionError(e);
    }
}
Also used : InvalidRelException(org.apache.calcite.rel.InvalidRelException) HiveRulesRegistry(org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry) CalciteSemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)

Example 4 with HiveRulesRegistry

use of org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry in project hive by apache.

the class HiveAntiJoin method copy.

@Override
public HiveAntiJoin copy(RelTraitSet traitSet, RexNode condition, RelNode left, RelNode right, JoinRelType joinType, boolean semiJoinDone) {
    try {
        HiveAntiJoin antiJoin = new HiveAntiJoin(getCluster(), traitSet, left, right, condition);
        // If available, copy state to registry for optimization rules
        HiveRulesRegistry registry = antiJoin.getCluster().getPlanner().getContext().unwrap(HiveRulesRegistry.class);
        if (registry != null) {
            registry.copyPushedPredicates(this, antiJoin);
        }
        return antiJoin;
    } catch (CalciteSemanticException e) {
        // internal error.
        throw new AssertionError(e);
    }
}
Also used : HiveRulesRegistry(org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry) CalciteSemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)

Example 5 with HiveRulesRegistry

use of org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry in project hive by apache.

the class HiveSemiJoin method copy.

@Override
public HiveSemiJoin copy(RelTraitSet traitSet, RexNode condition, RelNode left, RelNode right, JoinRelType joinType, boolean semiJoinDone) {
    try {
        final JoinInfo joinInfo = JoinInfo.of(left, right, condition);
        HiveSemiJoin semijoin = new HiveSemiJoin(getCluster(), traitSet, left, right, condition);
        // If available, copy state to registry for optimization rules
        HiveRulesRegistry registry = semijoin.getCluster().getPlanner().getContext().unwrap(HiveRulesRegistry.class);
        if (registry != null) {
            registry.copyPushedPredicates(this, semijoin);
        }
        return semijoin;
    } catch (InvalidRelException | CalciteSemanticException e) {
        // internal error.
        throw new AssertionError(e);
    }
}
Also used : JoinInfo(org.apache.calcite.rel.core.JoinInfo) InvalidRelException(org.apache.calcite.rel.InvalidRelException) HiveRulesRegistry(org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry) CalciteSemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)

Aggregations

HiveRulesRegistry (org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry)6 CalciteSemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)3 Properties (java.util.Properties)2 CalciteConnectionConfig (org.apache.calcite.config.CalciteConnectionConfig)2 CalciteConnectionConfigImpl (org.apache.calcite.config.CalciteConnectionConfigImpl)2 InvalidRelException (org.apache.calcite.rel.InvalidRelException)2 QueryProperties (org.apache.hadoop.hive.ql.QueryProperties)2 HiveConfPlannerContext (org.apache.hadoop.hive.ql.optimizer.calcite.HiveConfPlannerContext)2 HivePlannerContext (org.apache.hadoop.hive.ql.optimizer.calcite.HivePlannerContext)2 HiveAlgorithmsConf (org.apache.hadoop.hive.ql.optimizer.calcite.cost.HiveAlgorithmsConf)2 JavaTypeFactoryImpl (org.apache.calcite.jdbc.JavaTypeFactoryImpl)1 RelOptCluster (org.apache.calcite.plan.RelOptCluster)1 RelOptPlanner (org.apache.calcite.plan.RelOptPlanner)1 RelOptRule (org.apache.calcite.plan.RelOptRule)1 HepPlanner (org.apache.calcite.plan.hep.HepPlanner)1 HepProgramBuilder (org.apache.calcite.plan.hep.HepProgramBuilder)1 AbstractRelNode (org.apache.calcite.rel.AbstractRelNode)1 RelNode (org.apache.calcite.rel.RelNode)1 JoinInfo (org.apache.calcite.rel.core.JoinInfo)1 CachingRelMetadataProvider (org.apache.calcite.rel.metadata.CachingRelMetadataProvider)1