diff --git a/processing/src/main/java/org/apache/druid/query/QueryContexts.java b/processing/src/main/java/org/apache/druid/query/QueryContexts.java index 7d39edfde66..c3605bdc9ee 100644 --- a/processing/src/main/java/org/apache/druid/query/QueryContexts.java +++ b/processing/src/main/java/org/apache/druid/query/QueryContexts.java @@ -114,7 +114,7 @@ public class QueryContexts public static final boolean DEFAULT_ENABLE_SQL_JOIN_LEFT_SCAN_DIRECT = false; public static final boolean DEFAULT_USE_FILTER_CNF = false; public static final boolean DEFAULT_SECONDARY_PARTITION_PRUNING = true; - public static final boolean DEFAULT_ENABLE_DEBUG = false; + public static final boolean DEFAULT_ENABLE_DEBUG = true; public static final int DEFAULT_IN_SUB_QUERY_THRESHOLD = Integer.MAX_VALUE; public static final boolean DEFAULT_ENABLE_TIME_BOUNDARY_PLANNING = false; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/planner/CalciteRulesManager.java b/sql/src/main/java/org/apache/druid/sql/calcite/planner/CalciteRulesManager.java index 7fd7cb49b21..1180e0ad784 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/planner/CalciteRulesManager.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/planner/CalciteRulesManager.java @@ -133,7 +133,21 @@ public class CalciteRulesManager CoreRules.FILTER_VALUES_MERGE, CoreRules.PROJECT_FILTER_VALUES_MERGE, CoreRules.PROJECT_VALUES_MERGE, - CoreRules.AGGREGATE_VALUES + CoreRules.AGGREGATE_VALUES, + PruneEmptyRules.PROJECT_INSTANCE, +// PruneEmptyRules.UNION_INSTANCE, +// PruneEmptyRules.INTERSECT_INSTANCE, +// PruneEmptyRules.MINUS_INSTANCE, +// PruneEmptyRules.PROJECT_INSTANCE, +// PruneEmptyRules.FILTER_INSTANCE, +// PruneEmptyRules.SORT_INSTANCE, +// PruneEmptyRules.AGGREGATE_INSTANCE, +// PruneEmptyRules.JOIN_LEFT_INSTANCE, +// PruneEmptyRules.JOIN_RIGHT_INSTANCE, +// PruneEmptyRules.SORT_FETCH_ZERO_INSTANCE, + PruneEmptyRules.EMPTY_TABLE_INSTANCE +// CoreRules.FILTER_VALUES_MERGE, +// CoreRules.PROJECT_VALUES_MERGE ); /** @@ -233,7 +247,11 @@ public class CalciteRulesManager boolean isDebug = plannerContext.queryContext().isDebug(); return ImmutableList.of( - Programs.sequence(preProgram, Programs.ofRules(druidConventionRuleSet(plannerContext))), + Programs.sequence( + preProgram, +// Programs.ofRules(logicalConventionRuleSet(plannerContext)), + Programs.ofRules(druidConventionRuleSet(plannerContext)) + ), Programs.sequence(preProgram, Programs.ofRules(bindableConventionRuleSet(plannerContext))), Programs.sequence( // currently, adding logging program after every stage for easier debugging diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidLogicalRules.java b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidLogicalRules.java index d99cdce3d60..466a1fa5107 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidLogicalRules.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidLogicalRules.java @@ -49,17 +49,16 @@ public class DruidLogicalRules { return new ArrayList<>( ImmutableList.of( + new DruidValuesRule( + LogicalValues.class, + Convention.NONE, + DruidLogicalConvention.instance(), + DruidValuesRule.class.getSimpleName() + ), new DruidTableScanRule( RelOptRule.operand(LogicalTableScan.class, null, RelOptRule.any()), StringUtils.format("%s", DruidTableScanRule.class.getSimpleName()) ), - new DruidAggregateRule( - LogicalAggregate.class, - Convention.NONE, - DruidLogicalConvention.instance(), - DruidAggregateRule.class.getSimpleName(), - plannerContext - ), new DruidSortRule( LogicalSort.class, Convention.NONE, @@ -72,17 +71,18 @@ public class DruidLogicalRules DruidLogicalConvention.instance(), DruidProjectRule.class.getSimpleName() ), + new DruidAggregateRule( + LogicalAggregate.class, + Convention.NONE, + DruidLogicalConvention.instance(), + DruidAggregateRule.class.getSimpleName(), + plannerContext + ), new DruidFilterRule( LogicalFilter.class, Convention.NONE, DruidLogicalConvention.instance(), DruidFilterRule.class.getSimpleName() - ), - new DruidValuesRule( - LogicalValues.class, - Convention.NONE, - DruidLogicalConvention.instance(), - DruidValuesRule.class.getSimpleName() ) ) );