@Override public RuleSet getRules(OptimizerRulesContext context) { // add these rules because the MultiJoin produced in Multi-join analysis phase may have expressions like cast, // but HashJoinPrule requires simple references ImmutableList.Builder<RelOptRule> builder = ImmutableList.<RelOptRule>builder(); // Check if multi-join optimization has been enabled if (context.getPlannerSettings().isJoinOptimizationEnabled()) { builder .add(JOIN_PUSH_EXPRESSIONS_LOGICAL_RULE) .add(MergeProjectRule.LOGICAL_INSTANCE); if (context.getPlannerSettings().isExperimentalBushyJoinOptimizerEnabled()) { builder.add(MULTI_JOIN_OPTIMIZE_BUSHY_RULE); } else { builder.add(LOPT_OPTIMIZE_JOIN_RULE); } } return RuleSets.ofList(builder.add(JoinNormalizationRule.INSTANCE).build()); } },
@Override public Set<RelOptRule> getRules(OptimizerRulesContext optimizerContext, PlannerPhase phase, SourceType pluginType) { final OptionManager options = optimizerContext.getPlannerSettings().getOptions(); switch(phase){ case LOGICAL: return ImmutableSet.<RelOptRule>of(new ElasticScanRule(pluginType)); case PHYSICAL: ImmutableSet.Builder<RelOptRule> builder = ImmutableSet.builder(); builder.add(new ElasticScanPrule(optimizerContext.getFunctionRegistry())); if (options.getOption(ExecConstants.ELASTIC_RULES_PROJECT)) { builder.add(new ElasticProjectRule(optimizerContext.getFunctionRegistry())); } if (options.getOption(ExecConstants.ELASTIC_RULES_FILTER)) { builder.add(ElasticFilterRule.INSTANCE); } if (options.getOption(ExecConstants.ELASTIC_RULES_LIMIT)) { builder.add(ElasticLimitRule.INSTANCE); } if (options.getOption(ExecConstants.ELASTIC_RULES_SAMPLE)) { builder.add(ElasticSampleRule.INSTANCE); } return builder.build(); default: return ImmutableSet.of(); } }
private LogicalExpression materializePruneExpr(LogicalExpression pruneCondition, PlannerSettings settings, RelNode scanRel, VectorContainer container) { // materialize the expression container.buildSchema(); return ExpressionTreeMaterializer.materializeAndCheckErrors(pruneCondition, container.getSchema(), optimizerContext.getFunctionRegistry()); }
miscTimer.reset(); try(final BufferAllocator allocator = optimizerContext.getAllocator().newChildAllocator("prune-scan-rule", 0, Long.MAX_VALUE); final BitVector output = new BitVector("", allocator); final VectorContainer container = new VectorContainer();
@Override public RuleSet getRules(OptimizerRulesContext context) { final ImmutableList.Builder<RelOptRule> rules = ImmutableList.builder(); rules.add(AggregateReduceFunctionsRule.NO_REDUCE_SUM); if (context.getPlannerSettings() .getOptions() .getOption(PlannerSettings.JDBC_PUSH_DOWN_PLUS)) { rules.add( SimpleFilterJoinRule.CALCITE_INSTANCE, JOIN_CONDITION_PUSH_CALCITE_RULE, PushFilterPastProjectRule.CALCITE_INSTANCE ); } return RuleSets.ofList(rules.build()); } },
@Override public RuleSet getRules(OptimizerRulesContext context) { List<RelOptRule> moreRules = new ArrayList<>(); if(context.getPlannerSettings().isTransitiveJoinEnabled()) { moreRules.add(new JoinPushTransitivePredicatesRule(JoinRel.class, DremioRelFactories.LOGICAL_BUILDER)); } if(context.getPlannerSettings().isTransposeProjectFilterLogicalEnabled()) { moreRules.add(PUSH_PROJECT_PAST_FILTER_CALCITE_RULE); } if(context.getPlannerSettings().isFilterFlattenTransposeEnabled()){ moreRules.add(FilterFlattenTransposeRule.INSTANCE); } if(context.getPlannerSettings().isProjectLogicalCleanupEnabled()) { moreRules.add(MergeProjectRule.CALCITE_INSTANCE); moreRules.add(ProjectRemoveRule.INSTANCE); } if(moreRules.isEmpty()) { return LOGICAL_RULE_SET; } return PlannerPhase.mergedRuleSets(LOGICAL_RULE_SET, RuleSets.ofList(moreRules)); }
static final RuleSet getPhysicalRules(OptimizerRulesContext optimizerRulesContext) { final List<RelOptRule> ruleList = new ArrayList<>(); final PlannerSettings ps = optimizerRulesContext.getPlannerSettings();
/** * Get the list of enabled reduce expression (logical) rules. These rules are enabled using session/system options. * * @param optimizerRulesContext used to get the list of planner settings, other rules may * also in the future need to get other query state from this, * such as the available list of UDFs (as is used by the * MergeProjectRule) * @return list of enabled reduce expression (logical) rules */ static RuleSet getEnabledReduceExpressionsRules(OptimizerRulesContext optimizerRulesContext) { final PlannerSettings ps = optimizerRulesContext.getPlannerSettings(); // This list is used to store rules that can be turned on an off // by user facing planning options final ImmutableList.Builder<RelOptRule> userConfigurableRules = ImmutableList.builder(); userConfigurableRules.add(ConvertCountDistinctToHll.INSTANCE); if (ps.isConstantFoldingEnabled()) { // TODO - DRILL-2218, DX-2319 if (ps.isReduceProjectExpressionsEnabled()) { userConfigurableRules.add(PROJECT_REDUCE_EXPRESSIONS_CALCITE_RULE); } if (ps.isReduceFilterExpressionsEnabled()) { userConfigurableRules.add(FILTER_REDUCE_EXPRESSIONS_CALCITE_RULE); } if (ps.isReduceCalcExpressionsEnabled()) { userConfigurableRules.add(CALC_REDUCE_EXPRESSIONS_CALCITE_RULE); } } return RuleSets.ofList(userConfigurableRules.build()); }
@Override public Set<RelOptRule> getRules(OptimizerRulesContext optimizerContext, PlannerPhase phase, SourceType pluginType) { switch(phase){ case LOGICAL: ImmutableSet.Builder<RelOptRule> builder = ImmutableSet.builder(); builder.add(new FileSystemDrule(pluginType)); if(optimizerContext.getPlannerSettings().isPartitionPruningEnabled()){ builder.add(new PruneScanRuleFilterOnProject<>(pluginType, FilesystemScanDrel.class, optimizerContext)); builder.add(new PruneScanRuleFilterOnScan<>(pluginType, FilesystemScanDrel.class, optimizerContext)); } return builder.build(); case PHYSICAL: return ImmutableSet.<RelOptRule>of( new EasyFilesystemScanPrule(pluginType), new ParquetFilesystemScanPrule(pluginType), ConvertCountToDirectScan.getAggOnScan(pluginType), ConvertCountToDirectScan.getAggProjOnScan(pluginType) ); default: return ImmutableSet.<RelOptRule>of(); } }
@Override public Set<RelOptRule> getRules(OptimizerRulesContext optimizerContext, PlannerPhase phase, SourceType pluginType) { switch(phase){ case LOGICAL: ImmutableSet.Builder<RelOptRule> builder = ImmutableSet.builder(); builder.add(new HiveScanDrule(pluginType)); builder.add(EliminateEmptyScans.INSTANCE); final PlannerSettings plannerSettings = optimizerContext.getPlannerSettings(); if(plannerSettings.isPartitionPruningEnabled()){ builder.add(new PruneScanRuleFilterOnProject<>(pluginType, HiveScanDrel.class, optimizerContext)); builder.add(new PruneScanRuleFilterOnScan<>(pluginType, HiveScanDrel.class, optimizerContext)); } final OptionManager options = plannerSettings.getOptions(); if (options.getOption(HivePluginOptions.HIVE_ORC_READER_VECTORIZE) && options.getOption(HivePluginOptions.ENABLE_FILTER_PUSHDOWN_HIVE_ORC)) { builder.add(new ORCFilterPushDownRule(pluginType)); } return builder.build(); case PHYSICAL: return ImmutableSet.<RelOptRule>of( new HiveScanPrule(pluginType) ); default: return ImmutableSet.<RelOptRule>of(); } }
@Override public RuleSet getRules(OptimizerRulesContext context) { // Check if multi-join optimization has been disabled if (!context.getPlannerSettings().isJoinOptimizationEnabled()) { return RuleSets.ofList(); } return RuleSets.ofList( MULTIJOIN_BOTH_PROJECTS_TRANSPOSE_RULE, MULTIJOIN_LEFT_PROJECT_TRANSPOSE_RULE, MULTIJOIN_RIGHT_PROJECT_TRANSPOSE_RULE, JOIN_TO_MULTIJOIN_RULE, PROJECT_MULTIJOIN_MERGE_RULE, FILTER_MULTIJOIN_MERGE_RULE, MergeProjectRule.LOGICAL_INSTANCE, PROJECT_REMOVE_DRULE, FILTER_MERGE_DRULE ); } },