Program: 111832
Project: 111832
Buggy source:
/** 
 * Creates a query planner and initializes it with a default set of rules. 
 */
protected RelOptPlanner createPlanner(Context context){
  final VolcanoPlanner planner=new VolcanoPlanner();
  planner.addRelTraitDef(ConventionTraitDef.instance);
  if (ENABLE_COLLATION_TRAIT) {
    planner.addRelTraitDef(RelCollationTraitDef.INSTANCE);
    planner.registerAbstractRelationalRules();
  }
  RelOptUtil.registerAbstractRels(planner);
  planner.addRule(JavaRules.ENUMERABLE_JOIN_RULE);
  planner.addRule(JavaRules.ENUMERABLE_PROJECT_RULE);
  planner.addRule(JavaRules.ENUMERABLE_FILTER_RULE);
  planner.addRule(JavaRules.ENUMERABLE_AGGREGATE_RULE);
  planner.addRule(JavaRules.ENUMERABLE_SORT_RULE);
  planner.addRule(JavaRules.ENUMERABLE_LIMIT_RULE);
  planner.addRule(JavaRules.ENUMERABLE_UNION_RULE);
  planner.addRule(JavaRules.ENUMERABLE_INTERSECT_RULE);
  planner.addRule(JavaRules.ENUMERABLE_MINUS_RULE);
  planner.addRule(JavaRules.ENUMERABLE_TABLE_MODIFICATION_RULE);
  planner.addRule(JavaRules.ENUMERABLE_VALUES_RULE);
  planner.addRule(JavaRules.ENUMERABLE_WINDOW_RULE);
  planner.addRule(JavaRules.ENUMERABLE_ONE_ROW_RULE);
  planner.addRule(TableAccessRule.instance);
  planner.addRule(MergeProjectRule.instance);
  planner.addRule(PushFilterPastProjectRule.instance);
  planner.addRule(PushFilterPastJoinRule.FILTER_ON_JOIN);
  planner.addRule(RemoveDistinctAggregateRule.instance);
  planner.addRule(ReduceAggregatesRule.instance);
  planner.addRule(SwapJoinRule.instance);
  planner.addRule(PushJoinThroughJoinRule.RIGHT);
  planner.addRule(PushJoinThroughJoinRule.LEFT);
  planner.addRule(PushSortPastProjectRule.INSTANCE);
  context.spark().registerRules(planner);
  return planner;
}

Fixed version (ground truth):
/** 
 * Creates a query planner and initializes it with a default set of rules. 
 */
protected RelOptPlanner createPlanner(Context context){
  final VolcanoPlanner planner=new VolcanoPlanner();
  planner.addRelTraitDef(ConventionTraitDef.instance);
  if (ENABLE_COLLATION_TRAIT) {
    planner.addRelTraitDef(RelCollationTraitDef.INSTANCE);
    planner.registerAbstractRelationalRules();
  }
  RelOptUtil.registerAbstractRels(planner);
  planner.addRule(JavaRules.ENUMERABLE_JOIN_RULE);
  planner.addRule(JavaRules.ENUMERABLE_PROJECT_RULE);
  planner.addRule(JavaRules.ENUMERABLE_FILTER_RULE);
  planner.addRule(JavaRules.ENUMERABLE_AGGREGATE_RULE);
  planner.addRule(JavaRules.ENUMERABLE_SORT_RULE);
  planner.addRule(JavaRules.ENUMERABLE_LIMIT_RULE);
  planner.addRule(JavaRules.ENUMERABLE_UNION_RULE);
  planner.addRule(JavaRules.ENUMERABLE_INTERSECT_RULE);
  planner.addRule(JavaRules.ENUMERABLE_MINUS_RULE);
  planner.addRule(JavaRules.ENUMERABLE_TABLE_MODIFICATION_RULE);
  planner.addRule(JavaRules.ENUMERABLE_VALUES_RULE);
  planner.addRule(JavaRules.ENUMERABLE_WINDOW_RULE);
  planner.addRule(JavaRules.ENUMERABLE_ONE_ROW_RULE);
  planner.addRule(TableAccessRule.instance);
  planner.addRule(MergeProjectRule.instance);
  planner.addRule(PushFilterPastProjectRule.instance);
  planner.addRule(PushFilterPastJoinRule.FILTER_ON_JOIN);
  planner.addRule(RemoveDistinctAggregateRule.instance);
  planner.addRule(ReduceAggregatesRule.instance);
  planner.addRule(SwapJoinRule.instance);
  planner.addRule(PushJoinThroughJoinRule.RIGHT);
  planner.addRule(PushJoinThroughJoinRule.LEFT);
  planner.addRule(PushSortPastProjectRule.INSTANCE);
  if (false) {
    planner.addRule(ReduceExpressionsRule.PROJECT_INSTANCE);
    planner.addRule(ReduceExpressionsRule.FILTER_INSTANCE);
    planner.addRule(ReduceExpressionsRule.CALC_INSTANCE);
    planner.addRule(ReduceValuesRule.FILTER_INSTANCE);
    planner.addRule(ReduceValuesRule.PROJECT_FILTER_INSTANCE);
    planner.addRule(ReduceValuesRule.PROJECT_INSTANCE);
  }
  context.spark().registerRules(planner);
  return planner;
}