You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/03/11 17:16:34 UTC

[GitHub] [calcite] siddharthteotia commented on a change in pull request #1033: [CALCITE-2820] Avoid reducing certain aggregate functions when it is not necessary

siddharthteotia commented on a change in pull request #1033: [CALCITE-2820] Avoid reducing certain aggregate functions when it is not necessary
URL: https://github.com/apache/calcite/pull/1033#discussion_r264339078
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/rel/rules/AggregateReduceFunctionsRule.java
 ##########
 @@ -97,16 +99,55 @@
       new AggregateReduceFunctionsRule(operand(LogicalAggregate.class, any()),
           RelFactories.LOGICAL_BUILDER);
 
+  private EnumSet<SqlKind> functionsToReduce;
+
   //~ Constructors -----------------------------------------------------------
 
   /** Creates an AggregateReduceFunctionsRule. */
   public AggregateReduceFunctionsRule(RelOptRuleOperand operand,
       RelBuilderFactory relBuilderFactory) {
     super(operand, relBuilderFactory, null);
+    // by default, this rule will reduce all functions it handles
+    functionsToReduce = EnumSet.noneOf(SqlKind.class);
+    addDefaultSetOfFunctionsToReduce();
+  }
+
+  /**
+   * Creates an AggregateReduceFunctionsRule with client
+   * provided information on which specific functions will
+   * be reduced by this rule
+   * @param aggregateClass aggregate class
+   * @param relBuilderFactory builder for relational expressions
+   * @param functionsToReduce client provided information
+   *                          on which specific functions
+   *                          will be reduced by this rule
+   */
+  public AggregateReduceFunctionsRule(Class<? extends Aggregate> aggregateClass,
+      RelBuilderFactory relBuilderFactory, EnumSet<SqlKind> functionsToReduce) {
+    super(operand(aggregateClass, any()), relBuilderFactory, null);
+    Preconditions.checkArgument(functionsToReduce != null,
 
 Review comment:
   Done.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services