Added an assing under the agg op for assigning a dummy partitioning variable.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_fix_agg@500 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/PushAggFuncIntoStandaloneAggregateRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/PushAggFuncIntoStandaloneAggregateRule.java
index 65372e7..5770f4b 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/PushAggFuncIntoStandaloneAggregateRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/PushAggFuncIntoStandaloneAggregateRule.java
@@ -18,6 +18,7 @@
import java.util.List;
import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.commons.lang3.mutable.MutableObject;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -29,6 +30,7 @@
import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable;
import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
@@ -115,6 +117,21 @@
// The assign now just "renames" the variable to make sure the upstream plan still works.
srcAssignExprRef.setValue(new VariableReferenceExpression(aggVar));
+ // Create a new assign for a TRUE variable.
+ LogicalVariable trueVar = context.newVar();
+ AssignOperator trueAssignOp = new AssignOperator(trueVar, new MutableObject<ILogicalExpression>(ConstantExpression.TRUE));
+
+ ILogicalOperator aggInput = aggOp.getInputs().get(0).getValue();
+ aggOp.getInputs().get(0).setValue(trueAssignOp);
+ trueAssignOp.getInputs().add(new MutableObject<ILogicalOperator>(aggInput));
+
+ // Set partitioning variable.
+ aggOp.setPartitioningVariable(trueVar);
+
+ context.computeAndSetTypeEnvironmentForOperator(trueAssignOp);
+ context.computeAndSetTypeEnvironmentForOperator(aggOp);
+ context.computeAndSetTypeEnvironmentForOperator(assignOp);
+
return true;
}
}