checkpoint: debugging the listify argument for aggregate functions
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 bee8c40..9af6c48 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
@@ -21,7 +21,6 @@
 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;
@@ -33,7 +32,6 @@
 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;
@@ -43,7 +41,7 @@
 import edu.uci.ics.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
 
 /**
- * Pushes aggregate functions into a stand alone aggregate operator (no group by). 
+ * Pushes aggregate functions into a stand alone aggregate operator (no group by).
  */
 public class PushAggFuncIntoStandaloneAggregateRule implements IAlgebraicRewriteRule {
 
@@ -60,6 +58,7 @@
         if (op.getOperatorTag() != LogicalOperatorTag.ASSIGN) {
             return false;
         }
+
         Mutable<ILogicalOperator> opRef2 = op.getInputs().get(0);
         AbstractLogicalOperator op2 = (AbstractLogicalOperator) opRef2.getValue();
         if (op2.getOperatorTag() != LogicalOperatorTag.AGGREGATE) {
@@ -71,7 +70,7 @@
         if (op3.getOperatorTag() == LogicalOperatorTag.GROUP) {
             return false;
         }
-        
+
         AssignOperator assignOp = (AssignOperator) op;
         AggregateOperator aggOp = (AggregateOperator) op2;
         if (aggOp.getVariables().size() != 1) {
@@ -87,56 +86,61 @@
         if (origAggFuncExpr.getFunctionIdentifier() != AsterixBuiltinFunctions.LISTIFY) {
             return false;
         }
-        
+
         LogicalVariable aggVar = aggOp.getVariables().get(0);
         List<LogicalVariable> used = new LinkedList<LogicalVariable>();
         VariableUtilities.getUsedVariables(assignOp, used);
         if (!used.contains(aggVar)) {
             return false;
         }
-        
+
         Mutable<ILogicalExpression> srcAssignExprRef = fingAggFuncExprRef(assignOp.getExpressions(), aggVar);
         if (srcAssignExprRef == null) {
-        	return false;
+            return false;
         }
         AbstractFunctionCallExpression assignFuncExpr = (AbstractFunctionCallExpression) srcAssignExprRef.getValue();
-        FunctionIdentifier aggFuncIdent = AsterixBuiltinFunctions.getAggregateFunction(assignFuncExpr.getFunctionIdentifier());
-        
+        FunctionIdentifier aggFuncIdent = AsterixBuiltinFunctions.getAggregateFunction(assignFuncExpr
+                .getFunctionIdentifier());
+
         // Push the agg func into the agg op.                
-        AbstractFunctionCallExpression aggOpExpr = (AbstractFunctionCallExpression) aggOp.getExpressions().get(0).getValue();
+        AbstractFunctionCallExpression aggOpExpr = (AbstractFunctionCallExpression) aggOp.getExpressions().get(0)
+                .getValue();
         List<Mutable<ILogicalExpression>> aggArgs = new ArrayList<Mutable<ILogicalExpression>>();
         aggArgs.add(aggOpExpr.getArguments().get(0));
-        AggregateFunctionCallExpression aggFuncExpr = AsterixBuiltinFunctions.makeAggregateFunctionExpression(aggFuncIdent, aggArgs);
+        AggregateFunctionCallExpression aggFuncExpr = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
+                aggFuncIdent, aggArgs);
         aggOp.getExpressions().get(0).setValue(aggFuncExpr);
-        
+
         // The assign now just "renames" the variable to make sure the upstream plan still works.
         srcAssignExprRef.setValue(new VariableReferenceExpression(aggVar));
-        
+
         context.computeAndSetTypeEnvironmentForOperator(aggOp);
         context.computeAndSetTypeEnvironmentForOperator(assignOp);
-        
+
         return true;
     }
-    
-    private Mutable<ILogicalExpression> fingAggFuncExprRef(List<Mutable<ILogicalExpression>> exprRefs, LogicalVariable aggVar) {
-    	for (Mutable<ILogicalExpression> exprRef : exprRefs) {
+
+    private Mutable<ILogicalExpression> fingAggFuncExprRef(List<Mutable<ILogicalExpression>> exprRefs,
+            LogicalVariable aggVar) {
+        for (Mutable<ILogicalExpression> exprRef : exprRefs) {
             ILogicalExpression expr = exprRef.getValue();
             if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
                 continue;
             }
             AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
-            FunctionIdentifier funcIdent = AsterixBuiltinFunctions.getAggregateFunction(funcExpr.getFunctionIdentifier());
+            FunctionIdentifier funcIdent = AsterixBuiltinFunctions.getAggregateFunction(funcExpr
+                    .getFunctionIdentifier());
             if (funcIdent == null) {
-            	// Recursively look in func args.
-            	return fingAggFuncExprRef(funcExpr.getArguments(), aggVar);
+                // Recursively look in func args.
+                return fingAggFuncExprRef(funcExpr.getArguments(), aggVar);
             }
             // Check if this is the expr that uses aggVar.
             Collection<LogicalVariable> usedVars = new HashSet<LogicalVariable>();
             funcExpr.getUsedVariables(usedVars);
             if (usedVars.contains(aggVar)) {
-            	return exprRef;
+                return exprRef;
             }
-    	}
-    	return null;
+        }
+        return null;
     }
 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.2.update.aql
index fbe9098..4e0db2b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.2.update.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.2.update.aql
@@ -6,6 +6,6 @@
 
 use dataverse test;
 
-insert into dataset Test ({"id": 0, "val": 4.32, "valplus": 2});
+insert into dataset Test ({"id": 0, "val": 4.32, "valplus": 473847});
 insert into dataset Test ({"id": 1, "val": 5.32});
 insert into dataset Test ({"id": 2, "val": 6.32, "valplus": 38473827484738239});
diff --git a/asterix-transactions/.gitignore b/asterix-transactions/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/asterix-transactions/.gitignore
@@ -0,0 +1 @@
+/target