You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by dl...@apache.org on 2018/10/25 21:32:05 UTC

[01/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Repository: asterixdb
Updated Branches:
  refs/heads/master 776e1c25b -> 2a42da456


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..c636538
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class LocalSqlVarPopAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new LocalSqlVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.LOCAL_SQL_VAR_POP;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new LocalSqlVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarAggregateDescriptor.java
new file mode 100644
index 0000000..f25364a
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarAggregateDescriptor.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class LocalVarAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new LocalVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.LOCAL_VAR;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new LocalVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarAggregateFunction.java
new file mode 100644
index 0000000..41ec26d
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarAggregateFunction.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class LocalVarAggregateFunction extends AbstractSingleVarStatisticsAggregateFunction {
+
+    private final boolean isPop;
+
+    public LocalVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context, boolean isPop,
+            SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple) throws HyracksDataException {
+        processDataValues(tuple);
+    }
+
+    @Override
+    public void finish(IPointable result) throws HyracksDataException {
+        finishPartialResults(result);
+    }
+
+    @Override
+    public void finishPartial(IPointable result) throws HyracksDataException {
+        finish(result);
+    }
+
+    @Override
+    protected void processNull() {
+        aggType = ATypeTag.NULL;
+    }
+
+    @Override
+    protected boolean skipStep() {
+        return aggType == ATypeTag.NULL;
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..0e31b7b
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalVarPopAggregateDescriptor.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class LocalVarPopAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new LocalVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.LOCAL_VAR_POP;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new LocalVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..aaa4863
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarAggregateDescriptor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SqlVarAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SqlVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SQL_VAR;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SqlVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarAggregateFunction.java
new file mode 100644
index 0000000..e1c8793
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarAggregateFunction.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class SqlVarAggregateFunction extends AbstractSingleVarStatisticsAggregateFunction {
+
+    private final boolean isPop;
+    private final int delta;
+
+    public SqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context, boolean isPop,
+            SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+        if (isPop) {
+            delta = 0;
+        } else {
+            delta = 1;
+        }
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple) throws HyracksDataException {
+        processDataValues(tuple);
+    }
+
+    @Override
+    public void finish(IPointable result) throws HyracksDataException {
+        finishVarFinalResults(result, delta);
+    }
+
+    @Override
+    public void finishPartial(IPointable result) throws HyracksDataException {
+        finishPartialResults(result);
+    }
+
+    @Override
+    protected void processNull() {
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..0e79da6
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/SqlVarPopAggregateDescriptor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SqlVarPopAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SqlVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SQL_VAR_POP;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SqlVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarAggregateDescriptor.java
new file mode 100644
index 0000000..5e36fba
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarAggregateDescriptor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class VarAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new VarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.VAR;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new VarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarAggregateFunction.java
new file mode 100644
index 0000000..aed39ee
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarAggregateFunction.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class VarAggregateFunction extends AbstractSingleVarStatisticsAggregateFunction {
+
+    private final boolean isPop;
+    private final int delta;
+
+    public VarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context, boolean isPop,
+            SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+        if (isPop) {
+            delta = 0;
+        } else {
+            delta = 1;
+        }
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple) throws HyracksDataException {
+        processDataValues(tuple);
+    }
+
+    @Override
+    public void finish(IPointable result) throws HyracksDataException {
+        finishVarFinalResults(result, delta);
+    }
+
+    @Override
+    public void finishPartial(IPointable result) throws HyracksDataException {
+        finish(result);
+    }
+
+    @Override
+    protected void processNull() {
+        aggType = ATypeTag.NULL;
+    }
+
+    @Override
+    protected boolean skipStep() {
+        return aggType == ATypeTag.NULL;
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarPopAggregateDescriptor.java
new file mode 100644
index 0000000..c1a6df1
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/VarPopAggregateDescriptor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class VarPopAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new VarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.VAR_POP;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new VarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
index c8f1238..19c33db 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
@@ -42,9 +42,13 @@ import org.apache.asterix.runtime.aggregates.scalar.ScalarSqlMinAggregateDescrip
 import org.apache.asterix.runtime.aggregates.scalar.ScalarSqlStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.scalar.ScalarSqlStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.scalar.ScalarSqlSumAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.scalar.ScalarSqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.scalar.ScalarSqlVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.scalar.ScalarStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.scalar.ScalarStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.scalar.ScalarSumAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.scalar.ScalarVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.scalar.ScalarVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableAvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableCountAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableGlobalAvgAggregateDescriptor;
@@ -53,12 +57,20 @@ import org.apache.asterix.runtime.aggregates.serializable.std.SerializableGlobal
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableGlobalSqlStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableGlobalStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableGlobalStddevPopAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableGlobalSqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableGlobalSqlVarPopAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableGlobalVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableGlobalVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateAvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateSqlAvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateSqlStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateSqlStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateStddevPopAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateSqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateSqlVarPopAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableIntermediateVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalAvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalSqlAvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalSqlStddevAggregateDescriptor;
@@ -67,14 +79,22 @@ import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalS
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalSqlSumAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalSumAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalSqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalSqlVarPopAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableLocalVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableSqlAvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableSqlCountAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableSqlStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableSqlStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableSqlSumAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableSqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableSqlVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.serializable.std.SerializableSumAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.serializable.std.SerializableVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.AvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.CountAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.GlobalAvgAggregateDescriptor;
@@ -84,12 +104,20 @@ import org.apache.asterix.runtime.aggregates.std.GlobalSqlStddevAggregateDescrip
 import org.apache.asterix.runtime.aggregates.std.GlobalSqlStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.GlobalStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.GlobalStddevPopAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.GlobalSqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.GlobalSqlVarPopAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.GlobalVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.GlobalVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.IntermediateAvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.IntermediateSqlAvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.IntermediateSqlStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.IntermediateSqlStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.IntermediateStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.IntermediateStddevPopAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.IntermediateSqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.IntermediateSqlVarPopAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.IntermediateVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.IntermediateVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.LocalAvgAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.LocalMaxAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.LocalMinAggregateDescriptor;
@@ -100,9 +128,13 @@ import org.apache.asterix.runtime.aggregates.std.LocalSqlMinAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.LocalSqlStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.LocalSqlStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.LocalSqlSumAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.LocalSqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.LocalSqlVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.LocalStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.LocalStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.LocalSumAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.LocalVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.LocalVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.MaxAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.MinAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.SqlAvgAggregateDescriptor;
@@ -112,9 +144,13 @@ import org.apache.asterix.runtime.aggregates.std.SqlMinAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.SqlStddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.SqlStddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.SqlSumAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.SqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.SqlVarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.StddevAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.StddevPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.std.SumAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.VarAggregateDescriptor;
+import org.apache.asterix.runtime.aggregates.std.VarPopAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.stream.EmptyStreamAggregateDescriptor;
 import org.apache.asterix.runtime.aggregates.stream.NonEmptyStreamAggregateDescriptor;
 import org.apache.asterix.runtime.evaluators.accessors.CircleCenterAccessor;
@@ -484,6 +520,14 @@ public final class FunctionCollection implements IFunctionCollection {
         fc.add(LocalStddevPopAggregateDescriptor.FACTORY);
         fc.add(IntermediateStddevPopAggregateDescriptor.FACTORY);
         fc.add(GlobalStddevPopAggregateDescriptor.FACTORY);
+        fc.add(VarAggregateDescriptor.FACTORY);
+        fc.add(LocalVarAggregateDescriptor.FACTORY);
+        fc.add(IntermediateVarAggregateDescriptor.FACTORY);
+        fc.add(GlobalVarAggregateDescriptor.FACTORY);
+        fc.add(VarPopAggregateDescriptor.FACTORY);
+        fc.add(LocalVarPopAggregateDescriptor.FACTORY);
+        fc.add(IntermediateVarPopAggregateDescriptor.FACTORY);
+        fc.add(GlobalVarPopAggregateDescriptor.FACTORY);
 
         // serializable aggregates
         fc.add(SerializableCountAggregateDescriptor.FACTORY);
@@ -501,6 +545,14 @@ public final class FunctionCollection implements IFunctionCollection {
         fc.add(SerializableLocalStddevPopAggregateDescriptor.FACTORY);
         fc.add(SerializableIntermediateStddevPopAggregateDescriptor.FACTORY);
         fc.add(SerializableGlobalStddevPopAggregateDescriptor.FACTORY);
+        fc.add(SerializableVarAggregateDescriptor.FACTORY);
+        fc.add(SerializableLocalVarAggregateDescriptor.FACTORY);
+        fc.add(SerializableIntermediateVarAggregateDescriptor.FACTORY);
+        fc.add(SerializableGlobalVarAggregateDescriptor.FACTORY);
+        fc.add(SerializableVarPopAggregateDescriptor.FACTORY);
+        fc.add(SerializableLocalVarPopAggregateDescriptor.FACTORY);
+        fc.add(SerializableIntermediateVarPopAggregateDescriptor.FACTORY);
+        fc.add(SerializableGlobalVarPopAggregateDescriptor.FACTORY);
 
         // scalar aggregates
         fc.add(ScalarCountAggregateDescriptor.FACTORY);
@@ -512,6 +564,8 @@ public final class FunctionCollection implements IFunctionCollection {
         fc.add(NonEmptyStreamAggregateDescriptor.FACTORY);
         fc.add(ScalarStddevAggregateDescriptor.FACTORY);
         fc.add(ScalarStddevPopAggregateDescriptor.FACTORY);
+        fc.add(ScalarVarAggregateDescriptor.FACTORY);
+        fc.add(ScalarVarPopAggregateDescriptor.FACTORY);
 
         // SQL aggregates
         fc.add(SqlCountAggregateDescriptor.FACTORY);
@@ -533,6 +587,14 @@ public final class FunctionCollection implements IFunctionCollection {
         fc.add(LocalSqlStddevPopAggregateDescriptor.FACTORY);
         fc.add(IntermediateSqlStddevPopAggregateDescriptor.FACTORY);
         fc.add(GlobalSqlStddevPopAggregateDescriptor.FACTORY);
+        fc.add(SqlVarAggregateDescriptor.FACTORY);
+        fc.add(LocalSqlVarAggregateDescriptor.FACTORY);
+        fc.add(IntermediateSqlVarAggregateDescriptor.FACTORY);
+        fc.add(GlobalSqlVarAggregateDescriptor.FACTORY);
+        fc.add(SqlVarPopAggregateDescriptor.FACTORY);
+        fc.add(LocalSqlVarPopAggregateDescriptor.FACTORY);
+        fc.add(IntermediateSqlVarPopAggregateDescriptor.FACTORY);
+        fc.add(GlobalSqlVarPopAggregateDescriptor.FACTORY);
 
         // SQL serializable aggregates
         fc.add(SerializableSqlCountAggregateDescriptor.FACTORY);
@@ -550,6 +612,14 @@ public final class FunctionCollection implements IFunctionCollection {
         fc.add(SerializableLocalSqlStddevPopAggregateDescriptor.FACTORY);
         fc.add(SerializableIntermediateSqlStddevPopAggregateDescriptor.FACTORY);
         fc.add(SerializableGlobalSqlStddevPopAggregateDescriptor.FACTORY);
+        fc.add(SerializableSqlVarAggregateDescriptor.FACTORY);
+        fc.add(SerializableLocalSqlVarAggregateDescriptor.FACTORY);
+        fc.add(SerializableIntermediateSqlVarAggregateDescriptor.FACTORY);
+        fc.add(SerializableGlobalSqlVarAggregateDescriptor.FACTORY);
+        fc.add(SerializableSqlVarPopAggregateDescriptor.FACTORY);
+        fc.add(SerializableLocalSqlVarPopAggregateDescriptor.FACTORY);
+        fc.add(SerializableIntermediateSqlVarPopAggregateDescriptor.FACTORY);
+        fc.add(SerializableGlobalSqlVarPopAggregateDescriptor.FACTORY);
 
         // SQL scalar aggregates
         fc.add(ScalarSqlCountAggregateDescriptor.FACTORY);
@@ -559,6 +629,8 @@ public final class FunctionCollection implements IFunctionCollection {
         fc.add(ScalarSqlMinAggregateDescriptor.FACTORY);
         fc.add(ScalarSqlStddevAggregateDescriptor.FACTORY);
         fc.add(ScalarSqlStddevPopAggregateDescriptor.FACTORY);
+        fc.add(ScalarSqlVarAggregateDescriptor.FACTORY);
+        fc.add(ScalarSqlVarPopAggregateDescriptor.FACTORY);
 
         // boolean functions
         fc.add(AndDescriptor.FACTORY);


[09/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16/var_int16.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16/var_int16.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16/var_int16.3.query.sqlpp
new file mode 100644
index 0000000..75950f0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16/var_int16.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.array_var((
+    select element x
+    from  [test.smallint('1'),test.smallint('2'),test.smallint('3')] as x
+))), 'var_pop': (select element test.array_var_pop((
+    select element x
+    from  [test.smallint('1'),test.smallint('2'),test.smallint('3')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16_null/var_int16_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16_null/var_int16_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16_null/var_int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..6788afc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16_null/var_int16_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : bigint,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16_null/var_int16_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16_null/var_int16_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16_null/var_int16_null.3.query.sqlpp
new file mode 100644
index 0000000..d7a9716
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16_null/var_int16_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.array_var((
+    select element x.int16Field
+    from  Numeric as x
+)), 'var_pop':test.array_var_pop((
+    select element x.int16Field
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32/var_int32.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32/var_int32.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32/var_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32/var_int32.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32/var_int32.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32/var_int32.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32/var_int32.3.query.sqlpp
new file mode 100644
index 0000000..c9f71a5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32/var_int32.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.array_var((
+    select element x
+    from  [test.integer('1'),test.integer('2'),test.integer('3')] as x
+))), 'var_pop': (select element test.array_var_pop((
+    select element x
+    from  [test.integer('1'),test.integer('2'),test.integer('3')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32_null/var_int32_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32_null/var_int32_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32_null/var_int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..6788afc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32_null/var_int32_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : bigint,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32_null/var_int32_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32_null/var_int32_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32_null/var_int32_null.3.query.sqlpp
new file mode 100644
index 0000000..427e4a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int32_null/var_int32_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.array_var((
+    select element x.int32Field
+    from  Numeric as x
+)), 'var_pop':test.array_var_pop((
+    select element x.int32Field
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64/var_int64.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64/var_int64.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64/var_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64/var_int64.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64/var_int64.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64/var_int64.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64/var_int64.3.query.sqlpp
new file mode 100644
index 0000000..487070d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64/var_int64.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.array_var((
+    select element x
+    from  [test.bigint('1'),test.bigint('2'),test.bigint('3')] as x
+))), 'var_pop': (select element test.array_var_pop((
+    select element x
+    from  [test.bigint('1'),test.bigint('2'),test.bigint('3')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64_null/var_int64_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64_null/var_int64_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64_null/var_int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..6788afc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64_null/var_int64_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : bigint,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64_null/var_int64_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64_null/var_int64_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64_null/var_int64_null.3.query.sqlpp
new file mode 100644
index 0000000..012c8b3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int64_null/var_int64_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.array_var((
+    select element x.int64Field
+    from  Numeric as x
+)), 'var_pop':test.array_var_pop((
+    select element x.int64Field
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8/var_int8.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8/var_int8.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8/var_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8/var_int8.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8/var_int8.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8/var_int8.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8/var_int8.3.query.sqlpp
new file mode 100644
index 0000000..6bafd02
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8/var_int8.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.array_var((
+    select element x
+    from  [test.tinyint('1'),test.tinyint('2'),test.tinyint('3')] as x
+))), 'var_pop': (select element test.array_var_pop((
+    select element x
+    from  [test.tinyint('1'),test.tinyint('2'),test.tinyint('3')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8_null/var_int8_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8_null/var_int8_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8_null/var_int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..6788afc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8_null/var_int8_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : bigint,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8_null/var_int8_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8_null/var_int8_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8_null/var_int8_null.3.query.sqlpp
new file mode 100644
index 0000000..d36ab7a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int8_null/var_int8_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.array_var((
+    select element x.int8Field
+    from  Numeric as x
+)), 'var_pop':test.array_var_pop((
+    select element x.int8Field
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_mixed/var_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_mixed/var_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_mixed/var_mixed.3.query.sqlpp
new file mode 100644
index 0000000..3063caa
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_mixed/var_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run array_var over an multiset with mixed types
+* Expected Res : Failure
+* Date         : March 5th 2018
+*/
+
+select element array_var((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_pop_mixed/var_pop_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_pop_mixed/var_pop_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_pop_mixed/var_pop_mixed.3.query.sqlpp
new file mode 100644
index 0000000..e385855
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_pop_mixed/var_pop_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run array_var_pop over an multiset with mixed types
+* Expected Res : Failure
+* Date         : Feb 7th 2014
+*/
+
+select element array_var_pop((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.3.query.sqlpp
index f1eb9dd..b865561 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.3.query.sqlpp
@@ -22,4 +22,4 @@
 * Date         : Jun 2nd 2013
 */
 
-{'count1':strict_count([null]),'average1':strict_avg([null]),'sum1':strict_sum([null]),'min1':strict_min([null]),'max1':strict_max([null]),'stddev1':strict_stddev([null]),'stddev_pop1':strict_stddev_pop([null]),'count2':strict_count({{null,null}}),'average2':strict_avg({{null,null}}),'sum2':strict_sum({{null,null}}),'min2':strict_min({{null,null}}),'max2':strict_max({{null,null}}),'stddev2':strict_stddev({{null,null}}),'stddev_pop2':strict_stddev_pop({{null,null}})};
+{'count1':strict_count([null]),'average1':strict_avg([null]),'sum1':strict_sum([null]),'min1':strict_min([null]),'max1':strict_max([null]),'stddev1':strict_stddev([null]),'stddev_pop1':strict_stddev_pop([null]),'var1':strict_var([null]),'var_pop1':strict_var_pop([null]),'count2':strict_count({{null,null}}),'average2':strict_avg({{null,null}}),'sum2':strict_sum({{null,null}}),'min2':strict_min({{null,null}}),'max2':strict_max({{null,null}}),'stddev2':strict_stddev({{null,null}}),'stddev_pop2':strict_stddev_pop({{null,null}}),'var2':strict_var({{null,null}}),'var_pop2':strict_var_pop({{null,null}})};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.query.sqlpp
index 6796570..03c7668 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.query.sqlpp
@@ -46,4 +46,10 @@ use test;
 )), 'stddev_pop':test.strict_stddev_pop((
     select element t.valplus
     from  Test as t
+)), 'var':test.strict_var((
+    select element t.valplus
+    from  Test as t
+)), 'var_pop':test.strict_var_pop((
+    select element t.valplus
+    from  Test as t
 ))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
index e58aefb..2d97c79 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
@@ -64,4 +64,16 @@ use test;
         select element t
         from  Test as t
     ) as i
+)),'var':test.strict_var((
+    select element i.val
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+)),'var_pop':test.strict_var_pop((
+    select element i.val
+    from  (
+        select element t
+        from  Test as t
+    ) as i
 ))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.3.query.sqlpp
index 680f5c9..e0d4dca 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.3.query.sqlpp
@@ -22,4 +22,4 @@
 * Date         : Jun 2nd 2013
 */
 
-{'count1':strict_count([float('2.0'),double('3.0'),93847382783847382,1]),'average1':strict_avg([float('2.0'),double('3.0'),93847382783847382,1]),'sum1':strict_sum([float('2.0'),double('3.0'),93847382783847382,1]),'min1':strict_min([float('2.0'),double('3.0'),93847382783847382,1]),'max1':strict_max([float('2.0'),double('3.0'),93847382783847382,1]),'stddev1':strict_stddev([float('2.0'),double('3.0'),93847382783847382,1]),'stddev_pop1':strict_stddev_pop([float('2.0'),double('3.0'),93847382783847382,1]),'count2':strict_count({{float('2.0'),double('3.0'),93847382783847382,1}}),'average2':strict_avg({{float('2.0'),double('3.0'),93847382783847382,1}}),'sum2':strict_sum({{float('2.0'),double('3.0'),93847382783847382,1}}),'min2':strict_min({{float('2.0'),double('3.0'),93847382783847382,1}}),'max2':strict_max({{float('2.0'),double('3.0'),93847382783847382,1}}),'stddev2':strict_stddev([float('2.0'),double('3.0'),93847382783847382,1]),'stddev_pop2':strict_stddev_pop([float('2.0'),double('3.0'),
 93847382783847382,1])};
\ No newline at end of file
+{'count1':strict_count([float('2.0'),double('3.0'),93847382783847382,1]),'average1':strict_avg([float('2.0'),double('3.0'),93847382783847382,1]),'sum1':strict_sum([float('2.0'),double('3.0'),93847382783847382,1]),'min1':strict_min([float('2.0'),double('3.0'),93847382783847382,1]),'max1':strict_max([float('2.0'),double('3.0'),93847382783847382,1]),'stddev1':strict_stddev([float('2.0'),double('3.0'),93847382783847382,1]),'stddev_pop1':strict_stddev_pop([float('2.0'),double('3.0'),93847382783847382,1]),'var1':strict_var([float('2.0'),double('3.0'),93847382783847382,1]),'var_pop1':strict_var_pop([float('2.0'),double('3.0'),93847382783847382,1]),'count2':strict_count({{float('2.0'),double('3.0'),93847382783847382,1}}),'average2':strict_avg({{float('2.0'),double('3.0'),93847382783847382,1}}),'sum2':strict_sum({{float('2.0'),double('3.0'),93847382783847382,1}}),'min2':strict_min({{float('2.0'),double('3.0'),93847382783847382,1}}),'max2':strict_max({{float('2.0'),double('3.0'),9384738278384
 7382,1}}),'stddev2':strict_stddev([float('2.0'),double('3.0'),93847382783847382,1]),'stddev_pop2':strict_stddev_pop([float('2.0'),double('3.0'),93847382783847382,1]),'var2':strict_var([float('2.0'),double('3.0'),93847382783847382,1]),'var_pop2':strict_var_pop([float('2.0'),double('3.0'),93847382783847382,1])};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.query.sqlpp
index 1144a95..e2937d3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.query.sqlpp
@@ -46,4 +46,10 @@ use test;
 )),'stddev_pop':test.strict_stddev_pop((
     select element t.valplus
     from  Test as t
+)),'var':test.strict_var((
+    select element t.valplus
+    from  Test as t
+)),'var_pop':test.strict_var_pop((
+    select element t.valplus
+    from  Test as t
 ))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.3.query.sqlpp
index 0085e3f..d07bdc8 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 /*
-* Description  : Run avg over an ordered list with mixed types
+* Description  : Run avg over an multiset with mixed types
 * Expected Res : Failure
 * Date         : Jun 2nd 2013
 */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var/scalar_var.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var/scalar_var.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var/scalar_var.1.ddl.sqlpp
new file mode 100644
index 0000000..3a3a45c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var/scalar_var.1.ddl.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop without nulls.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var/scalar_var.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var/scalar_var.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var/scalar_var.3.query.sqlpp
new file mode 100644
index 0000000..669e686
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var/scalar_var.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+{'var': (with  i8 as test.strict_var([test.tinyint('1'),test.tinyint('2'),test.tinyint('3')]),
+      i16 as test.strict_var([test.smallint('1'),test.smallint('2'),test.smallint('3')]),
+      i32 as test.strict_var([test.integer('1'),test.integer('2'),test.integer('3')]),
+      i64 as test.strict_var([test.bigint('1'),test.bigint('2'),test.bigint('3')]),
+      f as test.strict_var([test.float('1'),test.float('2'),test.float('3')]),
+      d as test.strict_var([test.double('1'),test.double('2'),test.double('3')])
+select element i
+from  [i8,i16,i32,i64,f,d] as i),
+'var_pop': (with  i8 as test.strict_var_pop([test.tinyint('1'),test.tinyint('2'),test.tinyint('3')]),
+      i16 as test.strict_var_pop([test.smallint('1'),test.smallint('2'),test.smallint('3')]),
+      i32 as test.strict_var_pop([test.integer('1'),test.integer('2'),test.integer('3')]),
+      i64 as test.strict_var_pop([test.bigint('1'),test.bigint('2'),test.bigint('3')]),
+      f as test.strict_var_pop([test.float('1'),test.float('2'),test.float('3')]),
+      d as test.strict_var_pop([test.double('1'),test.double('2'),test.double('3')])
+select element i
+from  [i8,i16,i32,i64,f,d] as i)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..aceb0a1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.1.ddl.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop with an empty list.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.3.query.sqlpp
new file mode 100644
index 0000000..35c2a77
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop with an empty list.
+ * Success        : Yes
+ */
+
+{'var': (select element strict_var([])),
+'var_pop': (select element strict_var_pop([]))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_null/scalar_var_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_null/scalar_var_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_null/scalar_var_null.1.ddl.sqlpp
new file mode 100644
index 0000000..4e53c2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_null/scalar_var_null.1.ddl.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop with nulls.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_null/scalar_var_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_null/scalar_var_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_null/scalar_var_null.3.query.sqlpp
new file mode 100644
index 0000000..1c74d53
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_var_null/scalar_var_null.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+{'var': (with  i8 as test.strict_var([test.tinyint('1'),test.tinyint('2'),test.tinyint('3'),null]),
+      i16 as test.strict_var([test.smallint('1'),test.smallint('2'),test.smallint('3'),null]),
+      i32 as test.strict_var([test.integer('1'),test.integer('2'),test.integer('3'),null]),
+      i64 as test.strict_var([test.bigint('1'),test.bigint('2'),test.bigint('3'),null]),
+      f as test.strict_var([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test.strict_var([test.double('1'),test.double('2'),test.double('3'),null])
+select element i
+from  [i8,i16,i32,i64,f,d] as i),
+'var_pop': (with  i8 as test.strict_var_pop([test.tinyint('1'),test.tinyint('2'),test.tinyint('3'),null]),
+      i16 as test.strict_var_pop([test.smallint('1'),test.smallint('2'),test.smallint('3'),null]),
+      i32 as test.strict_var_pop([test.integer('1'),test.integer('2'),test.integer('3'),null]),
+      i64 as test.strict_var_pop([test.bigint('1'),test.bigint('2'),test.bigint('3'),null]),
+      f as test.strict_var_pop([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test.strict_var_pop([test.double('1'),test.double('2'),test.double('3'),null])
+select element i
+from  [i8,i16,i32,i64,f,d] as i)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp
index db27904..d7889c2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
  /*
- * Description  : Run serial-stddev over an ordered list with mixed types
+ * Description  : Run serial-stddev over an multiset with mixed types
  * Expected Res : Failure
  * Date         : March 5th 2018
  */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp
index 329fc59..51bdc07 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
  /*
- * Description  : Run serial-stddev_pop over an ordered list with mixed types
+ * Description  : Run serial-stddev_pop over an multiset with mixed types
  * Expected Res : Failure
  * Date         : March 5th 2018
  */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.2.update.sqlpp
new file mode 100644
index 0000000..88d820c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':double(4.32),'valplus':double(473847.0)};
+insert into Test
+select element {'id':1,'gid':1,'val':double(5.32)};
+insert into Test
+select element {'id':2,'gid':1,'val':double(6.32),'valplus':double(38473827484738239.0)};
+insert into Test
+select element {'id':3,'gid':1,'val':double(4.32),'valplus':double(678900.0)};
+insert into Test
+select element {'id':4,'gid':1,'val':double(4.32),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.3.query.sqlpp
new file mode 100644
index 0000000..23e33cc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double/serial_var_double.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.val from g)) as var,
+   strict_var_pop((select value g.val from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.2.update.sqlpp
new file mode 100644
index 0000000..88d820c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':double(4.32),'valplus':double(473847.0)};
+insert into Test
+select element {'id':1,'gid':1,'val':double(5.32)};
+insert into Test
+select element {'id':2,'gid':1,'val':double(6.32),'valplus':double(38473827484738239.0)};
+insert into Test
+select element {'id':3,'gid':1,'val':double(4.32),'valplus':double(678900.0)};
+insert into Test
+select element {'id':4,'gid':1,'val':double(4.32),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.3.query.sqlpp
new file mode 100644
index 0000000..7116737
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.valplus from g)) as var,
+   strict_var_pop((select value g.valplus from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_empty/serial_var_empty.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_empty/serial_var_empty.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_empty/serial_var_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_empty/serial_var_empty.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_empty/serial_var_empty.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_empty/serial_var_empty.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_empty/serial_var_empty.3.query.sqlpp
new file mode 100644
index 0000000..23e33cc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_empty/serial_var_empty.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.val from g)) as var,
+   strict_var_pop((select value g.val from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.1.ddl.sqlpp
new file mode 100644
index 0000000..ddac6a0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : float
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.2.update.sqlpp
new file mode 100644
index 0000000..c83ba1c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':float('4.32'),'valplus':float('473847')};
+insert into Test
+select element {'id':1,'gid':1,'val':float('5.32')};
+insert into Test
+select element {'id':2,'gid':1,'val':float('6.32'),'valplus':float('38473827484738239')};
+insert into Test
+select element {'id':3,'gid':1,'val':float('4.32'),'valplus':float('678900')};
+insert into Test
+select element {'id':4,'gid':1,'val':float('4.32'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.3.query.sqlpp
new file mode 100644
index 0000000..23e33cc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float/serial_var_float.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.val from g)) as var,
+   strict_var_pop((select value g.val from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddac6a0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : float
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.2.update.sqlpp
new file mode 100644
index 0000000..c83ba1c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':float('4.32'),'valplus':float('473847')};
+insert into Test
+select element {'id':1,'gid':1,'val':float('5.32')};
+insert into Test
+select element {'id':2,'gid':1,'val':float('6.32'),'valplus':float('38473827484738239')};
+insert into Test
+select element {'id':3,'gid':1,'val':float('4.32'),'valplus':float('678900')};
+insert into Test
+select element {'id':4,'gid':1,'val':float('4.32'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.3.query.sqlpp
new file mode 100644
index 0000000..7116737
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.valplus from g)) as var,
+   strict_var_pop((select value g.valplus from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..0c0bfee
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : smallint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.2.update.sqlpp
new file mode 100644
index 0000000..6210af4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':smallint('4'),'valplus':smallint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':smallint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':smallint('6'),'valplus':smallint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':smallint('4'),'valplus':smallint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':smallint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.3.query.sqlpp
new file mode 100644
index 0000000..23e33cc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16/serial_var_int16.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.val from g)) as var,
+   strict_var_pop((select value g.val from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..0c0bfee
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : smallint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.2.update.sqlpp
new file mode 100644
index 0000000..6210af4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':smallint('4'),'valplus':smallint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':smallint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':smallint('6'),'valplus':smallint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':smallint('4'),'valplus':smallint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':smallint('4'),'valplus':null};


[10/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddac6a0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : float
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.2.update.sqlpp
new file mode 100644
index 0000000..40641b5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':float('4.32'),'valplus':float('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':float('5.32')};
+insert into Test
+select element {'id':2,'gid':1,'val':float('6.32'),'valplus':float('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':float('4.32'),'valplus':float('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':float('4.32'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.3.query.sqlpp
new file mode 100644
index 0000000..abd0d49
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.valplus) as var, var_pop(t.valplus) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..0c0bfee
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : smallint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.2.update.sqlpp
new file mode 100644
index 0000000..6210af4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':smallint('4'),'valplus':smallint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':smallint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':smallint('6'),'valplus':smallint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':smallint('4'),'valplus':smallint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':smallint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.3.query.sqlpp
new file mode 100644
index 0000000..48a30f1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.val) as var, var_pop(t.val) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..0c0bfee
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : smallint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.2.update.sqlpp
new file mode 100644
index 0000000..6210af4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':smallint('4'),'valplus':smallint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':smallint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':smallint('6'),'valplus':smallint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':smallint('4'),'valplus':smallint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':smallint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.3.query.sqlpp
new file mode 100644
index 0000000..abd0d49
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.valplus) as var, var_pop(t.valplus) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..07312bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : integer
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.2.update.sqlpp
new file mode 100644
index 0000000..a248a0f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':integer('4'),'valplus':integer('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':integer('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':integer('6'),'valplus':integer('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':integer('4'),'valplus':integer('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':integer('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.3.query.sqlpp
new file mode 100644
index 0000000..48a30f1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.val) as var, var_pop(t.val) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..07312bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : integer
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.2.update.sqlpp
new file mode 100644
index 0000000..a248a0f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':integer('4'),'valplus':integer('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':integer('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':integer('6'),'valplus':integer('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':integer('4'),'valplus':integer('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':integer('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.3.query.sqlpp
new file mode 100644
index 0000000..abd0d49
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.valplus) as var, var_pop(t.valplus) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..5e9972c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : bigint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.2.update.sqlpp
new file mode 100644
index 0000000..b460af2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':bigint('4'),'valplus':bigint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':bigint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':bigint('6'),'valplus':bigint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':bigint('4'),'valplus':bigint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':bigint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.3.query.sqlpp
new file mode 100644
index 0000000..48a30f1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.val) as var, var_pop(t.val) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..5e9972c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : bigint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.2.update.sqlpp
new file mode 100644
index 0000000..b460af2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':bigint('4'),'valplus':bigint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':bigint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':bigint('6'),'valplus':bigint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':bigint('4'),'valplus':bigint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':bigint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.3.query.sqlpp
new file mode 100644
index 0000000..abd0d49
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.valplus) as var, var_pop(t.valplus) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..c45dbfe
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : tinyint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.2.update.sqlpp
new file mode 100644
index 0000000..5a65a20
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':tinyint('4'),'valplus':tinyint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':tinyint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':tinyint('6'),'valplus':tinyint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':tinyint('4'),'valplus':tinyint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':tinyint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.3.query.sqlpp
new file mode 100644
index 0000000..48a30f1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.val) as var, var_pop(t.val) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..c45dbfe
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : tinyint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.2.update.sqlpp
new file mode 100644
index 0000000..5a65a20
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':tinyint('4'),'valplus':tinyint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':tinyint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':tinyint('6'),'valplus':tinyint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':tinyint('4'),'valplus':tinyint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':tinyint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.3.query.sqlpp
new file mode 100644
index 0000000..abd0d49
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.valplus) as var, var_pop(t.valplus) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.2.update.sqlpp
new file mode 100644
index 0000000..8c0b731
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':double(4.32),'valplus':float('2.0')};
+insert into Test
+select element {'id':1,'gid':1,'val':double(5.32)};
+insert into Test
+select element {'id':2,'gid':1,'val':double(6.32),'valplus':'hello world'};
+insert into Test
+select element {'id':3,'gid':1,'val':double(4.32),'valplus':double('3.0')};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.3.query.sqlpp
new file mode 100644
index 0000000..3f53ea5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_mixed/serial_var_mixed.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ /*
+ * Description  : Run serial-var over an multiset with mixed types
+ * Expected Res : Failure
+ * Date         : March 5th 2018
+ */
+
+use test;
+
+select gid, array_var((select value g.valplus from g)) as var
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.2.update.sqlpp
new file mode 100644
index 0000000..8c0b731
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':double(4.32),'valplus':float('2.0')};
+insert into Test
+select element {'id':1,'gid':1,'val':double(5.32)};
+insert into Test
+select element {'id':2,'gid':1,'val':double(6.32),'valplus':'hello world'};
+insert into Test
+select element {'id':3,'gid':1,'val':double(4.32),'valplus':double('3.0')};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.3.query.sqlpp
new file mode 100644
index 0000000..ebc7c66
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ /*
+ * Description  : Run serial-var over an multiset with mixed types
+ * Expected Res : Failure
+ * Date         : March 5th 2018
+ */
+
+use test;
+
+select gid, array_var_pop((select value g.valplus from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_mixed/stddev_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_mixed/stddev_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_mixed/stddev_mixed.3.query.sqlpp
index 9eb1323..97da862 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_mixed/stddev_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_mixed/stddev_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 /*
-* Description  : Run array_stddev over an ordered list with mixed types
+* Description  : Run array_stddev over an multiset with mixed types
 * Expected Res : Failure
 * Date         : March 5th 2018
 */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp
index 64538e8..9d3d681 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 /*
-* Description  : Run array_stddev_pop over an ordered list with mixed types
+* Description  : Run array_stddev_pop over an multiset with mixed types
 * Expected Res : Failure
 * Date         : Feb 7th 2014
 */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.query.sqlpp
index 3cbd242..fed4cc9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 /*
-* Description  : Run array_sum over an ordered list with mixed types
+* Description  : Run array_sum over an multiset with mixed types
 * Expected Res : Failure
 * Date         : Feb 7th 2014
 */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_distinct/var_distinct.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_distinct/var_distinct.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_distinct/var_distinct.1.query.sqlpp
new file mode 100644
index 0000000..2dd3402
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_distinct/var_distinct.1.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ {
+   't1': to_bigint(array_var(distinct [10,20,30,10,20,30,10])),
+   't2': to_bigint(array_var(distinct [null,missing,null,missing])),
+   't3': to_bigint(array_var(distinct [40,null,missing,50,40,null,missing,50,40])),
+   't4': to_bigint(array_var(distinct [])),
+   't5': to_bigint(array_var_pop(distinct [10,20,30,10,20,30,10])),
+   't6': to_bigint(array_var_pop(distinct [null,missing,null,missing])),
+   't7': to_bigint(array_var_pop(distinct [40,null,missing,50,40,null,missing,50,40])),
+   't8': to_bigint(array_var_pop(distinct []))
+ };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double/var_double.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double/var_double.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double/var_double.1.ddl.sqlpp
new file mode 100644
index 0000000..ad97753
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double/var_double.1.ddl.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double/var_double.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double/var_double.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double/var_double.3.query.sqlpp
new file mode 100644
index 0000000..52dfea2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double/var_double.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+{'var': (select element array_var((
+    select element x
+    from  [1.0,2.0,double('3.0')] as x
+))), 'var_pop': (select element array_var_pop((
+    select element x
+    from  [1.0,2.0,double('3.0')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double_null/var_double_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double_null/var_double_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double_null/var_double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..3f2c5bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double_null/var_double_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : integer,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double_null/var_double_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double_null/var_double_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double_null/var_double_null.3.query.sqlpp
new file mode 100644
index 0000000..bf0df4f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_double_null/var_double_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.array_var((
+    select element x.doubleField
+    from  Numeric as x
+)), 'var_pop':test.array_var_pop((
+    select element x.doubleField
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_01/var_empty_01.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_01/var_empty_01.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_01/var_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..2e5b5b9
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_01/var_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that array_var aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_01/var_empty_01.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_01/var_empty_01.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_01/var_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..75cbfcc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_01/var_empty_01.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that var and var_pop aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+{'var': (select element test.array_var((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+))), 'var_pop': (select element test.array_var_pop((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_02/var_empty_02.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_02/var_empty_02.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_02/var_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..b2d1d8c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_02/var_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that array_var aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_02/var_empty_02.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_02/var_empty_02.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_02/var_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..63459e2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_empty_02/var_empty_02.3.query.sqlpp
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that var and var_pop aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+{'var': (select element test.array_var((
+    select element x.val
+    from  Test as x
+))), 'var_pop': (select element test.array_var_pop((
+    select element x.val
+    from  Test as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float/var_float.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float/var_float.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float/var_float.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float/var_float.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float/var_float.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float/var_float.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float/var_float.3.query.sqlpp
new file mode 100644
index 0000000..b022fe5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float/var_float.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.array_var((
+    select element x
+    from  [test.float('1'),test.float('2'),test.float('3')] as x
+))), 'var_pop': (select element test.array_var_pop((
+    select element x
+    from  [test.float('1'),test.float('2'),test.float('3')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float_null/var_float_nu.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float_null/var_float_nu.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float_null/var_float_nu.1.ddl.sqlpp
new file mode 100644
index 0000000..6788afc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float_null/var_float_nu.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : bigint,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float_null/var_float_nu.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float_null/var_float_nu.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float_null/var_float_nu.3.query.sqlpp
new file mode 100644
index 0000000..10089c1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_float_null/var_float_nu.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.array_var((
+    select element x.floatField
+    from  Numeric as x
+)), 'var_pop':test.array_var_pop((
+    select element x.floatField
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16/var_int16.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16/var_int16.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16/var_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/var_int16/var_int16.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+


[02/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateFunction.java
new file mode 100644
index 0000000..675d319
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateFunction.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableLocalSqlVarAggregateFunction
+        extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+    private final boolean isPop;
+
+    public SerializableLocalSqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+            boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+        processDataValues(tuple, state, start, len);
+    }
+
+    @Override
+    public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishPartialResults(state, start, len, result);
+    }
+
+    @Override
+    public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finish(state, start, len, result);
+    }
+
+    @Override
+    protected void processNull(byte[] state, int start) {
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..8cebd37
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableLocalSqlVarPopAggregateDescriptor
+        extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableLocalSqlVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_LOCAL_SQL_VAR_POP;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableLocalSqlVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarAggregateDescriptor.java
new file mode 100644
index 0000000..7337794
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableLocalVarAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableLocalVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_LOCAL_VAR;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableLocalVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarAggregateFunction.java
new file mode 100644
index 0000000..04ceef3
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarAggregateFunction.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableLocalVarAggregateFunction
+        extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+    private final boolean isPop;
+
+    public SerializableLocalVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+            boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+        processDataValues(tuple, state, start, len);
+    }
+
+    @Override
+    public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishPartialResults(state, start, len, result);
+    }
+
+    @Override
+    public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finish(state, start, len, result);
+    }
+
+    @Override
+    protected void processNull(byte[] state, int start) {
+        state[start + AGG_TYPE_OFFSET] = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+    }
+
+    @Override
+    protected boolean skipStep(byte[] state, int start) {
+        ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
+        return aggType == ATypeTag.NULL;
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..26cb1c0
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalVarPopAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableLocalVarPopAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableLocalVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_LOCAL_VAR_POP;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableLocalVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..870b28c
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarAggregateDescriptor.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableSqlVarAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableSqlVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_SQL_VAR;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarAggregateFunction.java
new file mode 100644
index 0000000..decdc13
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarAggregateFunction.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableSqlVarAggregateFunction extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+    private final boolean isPop;
+    private final int delta;
+
+    public SerializableSqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+            boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+        if (isPop) {
+            delta = 0;
+        } else {
+            delta = 1;
+        }
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+        processDataValues(tuple, state, start, len);
+    }
+
+    @Override
+    public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishVarFinalResults(state, start, len, result, delta);
+    }
+
+    @Override
+    public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finish(state, start, len, result);
+    }
+
+    @Override
+    protected void processNull(byte[] state, int start) {
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..5bba003
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableSqlVarPopAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableSqlVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_SQL_VAR_POP;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableSqlVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarAggregateDescriptor.java
new file mode 100644
index 0000000..bcb79c1
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableVarAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_VAR;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) throws AlgebricksException {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarAggregateFunction.java
new file mode 100644
index 0000000..3e8d275
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarAggregateFunction.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableVarAggregateFunction extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+    private final boolean isPop;
+    private final int delta;
+
+    public SerializableVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context, boolean isPop,
+            SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+        if (isPop) {
+            delta = 0;
+        } else {
+            delta = 1;
+        }
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+        processDataValues(tuple, state, start, len);
+    }
+
+    @Override
+    public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishVarFinalResults(state, start, len, result, delta);
+    }
+
+    @Override
+    public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finish(state, start, len, result);
+    }
+
+    @Override
+    protected void processNull(byte[] state, int start) {
+        state[start + AGG_TYPE_OFFSET] = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+    }
+
+    @Override
+    protected boolean skipStep(byte[] state, int start) {
+        ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
+        return aggType == ATypeTag.NULL;
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..15571ed
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableVarPopAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableVarPopAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_VAR_POP;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) throws AlgebricksException {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractSingleVarStatisticsAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractSingleVarStatisticsAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractSingleVarStatisticsAggregateFunction.java
index f4171bd..e8cbca7 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractSingleVarStatisticsAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractSingleVarStatisticsAggregateFunction.java
@@ -253,6 +253,21 @@ public abstract class AbstractSingleVarStatisticsAggregateFunction extends Abstr
         result.set(resultStorage);
     }
 
+    protected void finishVarFinalResults(IPointable result, int delta) throws HyracksDataException {
+        resultStorage.reset();
+        try {
+            if (moments.getCount() <= 1 || aggType == ATypeTag.NULL) {
+                nullSerde.serialize(ANull.NULL, resultStorage.getDataOutput());
+            } else {
+                aDouble.setValue(moments.getM2() / (moments.getCount() - delta));
+                doubleSerde.serialize(aDouble, resultStorage.getDataOutput());
+            }
+        } catch (IOException e) {
+            throw HyracksDataException.create(e);
+        }
+        result.set(resultStorage);
+    }
+
     protected boolean skipStep() {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..f1ead82
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class GlobalSqlVarAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new GlobalSqlVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.GLOBAL_SQL_VAR;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new GlobalSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarAggregateFunction.java
new file mode 100644
index 0000000..a999c33
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarAggregateFunction.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class GlobalSqlVarAggregateFunction extends AbstractSingleVarStatisticsAggregateFunction {
+
+    private final boolean isPop;
+    private final int delta;
+
+    public GlobalSqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context, boolean isPop,
+            SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+        if (isPop) {
+            delta = 0;
+        } else {
+            delta = 1;
+        }
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple) throws HyracksDataException {
+        processPartialResults(tuple);
+    }
+
+    @Override
+    public void finish(IPointable result) throws HyracksDataException {
+        finishVarFinalResults(result, delta);
+    }
+
+    @Override
+    public void finishPartial(IPointable result) throws HyracksDataException {
+        finishPartialResults(result);
+    }
+
+    @Override
+    protected void processNull() {
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..2dbbfc8
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class GlobalSqlVarPopAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new GlobalSqlVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.GLOBAL_SQL_VAR_POP;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new GlobalSqlVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarAggregateDescriptor.java
new file mode 100644
index 0000000..83b7b87
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class GlobalVarAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new GlobalVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.GLOBAL_VAR;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new GlobalVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarAggregateFunction.java
new file mode 100644
index 0000000..9ee5008
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarAggregateFunction.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class GlobalVarAggregateFunction extends AbstractSingleVarStatisticsAggregateFunction {
+
+    private final boolean isPop;
+    private final int delta;
+
+    public GlobalVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context, boolean isPop,
+            SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+        if (isPop) {
+            delta = 0;
+        } else {
+            delta = 1;
+        }
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple) throws HyracksDataException {
+        processPartialResults(tuple);
+    }
+
+    @Override
+    public void finish(IPointable result) throws HyracksDataException {
+        finishVarFinalResults(result, delta);
+    }
+
+    @Override
+    public void finishPartial(IPointable result) throws HyracksDataException {
+        finishPartialResults(result);
+    }
+
+    @Override
+    protected void processNull() {
+        aggType = ATypeTag.NULL;
+    }
+
+    @Override
+    protected boolean skipStep() {
+        return aggType == ATypeTag.NULL;
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..03c5429
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalVarPopAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class GlobalVarPopAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new GlobalVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.GLOBAL_VAR_POP;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new GlobalVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..8f01239
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarAggregateDescriptor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class IntermediateSqlVarAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new IntermediateSqlVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.INTERMEDIATE_SQL_VAR;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new IntermediateSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarAggregateFunction.java
new file mode 100644
index 0000000..efcb334
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarAggregateFunction.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class IntermediateSqlVarAggregateFunction extends AbstractSingleVarStatisticsAggregateFunction {
+
+    private final boolean isPop;
+
+    public IntermediateSqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+            boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple) throws HyracksDataException {
+        processPartialResults(tuple);
+    }
+
+    @Override
+    public void finish(IPointable result) throws HyracksDataException {
+        finishPartialResults(result);
+    }
+
+    @Override
+    public void finishPartial(IPointable result) throws HyracksDataException {
+        finishPartialResults(result);
+    }
+
+    @Override
+    protected void processNull() {
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..f456b2f
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class IntermediateSqlVarPopAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new IntermediateSqlVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.INTERMEDIATE_SQL_VAR_POP;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new IntermediateSqlVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarAggregateDescriptor.java
new file mode 100644
index 0000000..6da3083
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class IntermediateVarAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new IntermediateVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.INTERMEDIATE_VAR;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new IntermediateVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarAggregateFunction.java
new file mode 100644
index 0000000..214ae47
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarAggregateFunction.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class IntermediateVarAggregateFunction extends AbstractSingleVarStatisticsAggregateFunction {
+
+    private final boolean isPop;
+
+    public IntermediateVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context, boolean isPop,
+            SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple) throws HyracksDataException {
+        processPartialResults(tuple);
+    }
+
+    @Override
+    public void finish(IPointable result) throws HyracksDataException {
+        finishPartialResults(result);
+    }
+
+    @Override
+    public void finishPartial(IPointable result) throws HyracksDataException {
+        finishPartialResults(result);
+    }
+
+    @Override
+    protected void processNull() {
+        aggType = ATypeTag.NULL;
+    }
+
+    @Override
+    protected boolean skipStep() {
+        return aggType == ATypeTag.NULL;
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..32e7587
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateVarPopAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class IntermediateVarPopAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new IntermediateVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.INTERMEDIATE_VAR_POP;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new IntermediateVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..035abbb
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarAggregateDescriptor.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class LocalSqlVarAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new LocalSqlVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.LOCAL_SQL_VAR;
+    }
+
+    @Override
+    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new LocalSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarAggregateFunction.java
new file mode 100644
index 0000000..85fd011
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalSqlVarAggregateFunction.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class LocalSqlVarAggregateFunction extends AbstractSingleVarStatisticsAggregateFunction {
+
+    private final boolean isPop;
+
+    public LocalSqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context, boolean isPop,
+            SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple) throws HyracksDataException {
+        processDataValues(tuple);
+    }
+
+    @Override
+    public void finish(IPointable result) throws HyracksDataException {
+        finishPartialResults(result);
+    }
+
+    @Override
+    public void finishPartial(IPointable result) throws HyracksDataException {
+        finish(result);
+    }
+
+    @Override
+    protected void processNull() {
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+}


[03/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
index 4813be9..3fb03a1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
@@ -490,6 +490,21 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-intermediate-stddev_pop", 1);
     public static final FunctionIdentifier LOCAL_STDDEV_POP =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-stddev_pop", 1);
+    public static final FunctionIdentifier VAR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-var", 1);
+    public static final FunctionIdentifier GLOBAL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-var", 1);
+    public static final FunctionIdentifier INTERMEDIATE_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-intermediate-var", 1);
+    public static final FunctionIdentifier LOCAL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-var", 1);
+    public static final FunctionIdentifier VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-var_pop", 1);
+    public static final FunctionIdentifier GLOBAL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-var_pop", 1);
+    public static final FunctionIdentifier INTERMEDIATE_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-intermediate-var_pop", 1);
+    public static final FunctionIdentifier LOCAL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-var_pop", 1);
 
     public static final FunctionIdentifier SCALAR_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "avg", 1);
     public static final FunctionIdentifier SCALAR_COUNT =
@@ -515,6 +530,17 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-stddev_pop", 1);
     public static final FunctionIdentifier SCALAR_LOCAL_STDDEV_POP =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-stddev_pop", 1);
+    public static final FunctionIdentifier SCALAR_VAR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var", 1);
+    public static final FunctionIdentifier SCALAR_GLOBAL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-var", 1);
+    public static final FunctionIdentifier SCALAR_LOCAL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-var", 1);
+    public static final FunctionIdentifier SCALAR_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var_pop", 1);
+    public static final FunctionIdentifier SCALAR_GLOBAL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-var_pop", 1);
+    public static final FunctionIdentifier SCALAR_LOCAL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-var_pop", 1);
 
     // serializable aggregate functions
     public static final FunctionIdentifier SERIAL_AVG =
@@ -547,6 +573,22 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-stddev_pop-serial", 1);
     public static final FunctionIdentifier SERIAL_INTERMEDIATE_STDDEV_POP =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-stddev_pop-serial", 1);
+    public static final FunctionIdentifier SERIAL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var-serial", 1);
+    public static final FunctionIdentifier SERIAL_GLOBAL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-var-serial", 1);
+    public static final FunctionIdentifier SERIAL_LOCAL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-var-serial", 1);
+    public static final FunctionIdentifier SERIAL_INTERMEDIATE_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-var-serial", 1);
+    public static final FunctionIdentifier SERIAL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var_pop-serial", 1);
+    public static final FunctionIdentifier SERIAL_GLOBAL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-var_pop-serial", 1);
+    public static final FunctionIdentifier SERIAL_LOCAL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-var_pop-serial", 1);
+    public static final FunctionIdentifier SERIAL_INTERMEDIATE_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-var_pop-serial", 1);
 
     // distinct aggregate functions
     public static final FunctionIdentifier COUNT_DISTINCT =
@@ -577,6 +619,14 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-stddev_pop-distinct", 1);
     public static final FunctionIdentifier SCALAR_STDDEV_POP_DISTINCT =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "stddev_pop-distinct", 1);
+    public static final FunctionIdentifier VAR_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-var-distinct", 1);
+    public static final FunctionIdentifier SCALAR_VAR_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var-distinct", 1);
+    public static final FunctionIdentifier VAR_POP_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-var_pop-distinct", 1);
+    public static final FunctionIdentifier SCALAR_VAR_POP_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var_pop-distinct", 1);
 
     // sql aggregate functions
     public static final FunctionIdentifier SQL_AVG =
@@ -617,6 +667,22 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-sql-stddev_pop", 1);
     public static final FunctionIdentifier LOCAL_SQL_STDDEV_POP =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-sql-stddev_pop", 1);
+    public static final FunctionIdentifier SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-var", 1);
+    public static final FunctionIdentifier INTERMEDIATE_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-agg-sql-var", 1);
+    public static final FunctionIdentifier GLOBAL_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-sql-var", 1);
+    public static final FunctionIdentifier LOCAL_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-sql-var", 1);
+    public static final FunctionIdentifier SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-var_pop", 1);
+    public static final FunctionIdentifier INTERMEDIATE_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-agg-sql-var_pop", 1);
+    public static final FunctionIdentifier GLOBAL_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-sql-var_pop", 1);
+    public static final FunctionIdentifier LOCAL_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-sql-var_pop", 1);
 
     public static final FunctionIdentifier SCALAR_SQL_AVG =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-avg", 1);
@@ -644,6 +710,18 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-stddev_pop", 1);
     public static final FunctionIdentifier SCALAR_LOCAL_SQL_STDDEV_POP =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-stddev_pop", 1);
+    public static final FunctionIdentifier SCALAR_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var", 1);
+    public static final FunctionIdentifier SCALAR_GLOBAL_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-var", 1);
+    public static final FunctionIdentifier SCALAR_LOCAL_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-var", 1);
+    public static final FunctionIdentifier SCALAR_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var_pop", 1);
+    public static final FunctionIdentifier SCALAR_GLOBAL_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-var_pop", 1);
+    public static final FunctionIdentifier SCALAR_LOCAL_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-var_pop", 1);
 
     // serializable sql aggregate functions
     public static final FunctionIdentifier SERIAL_SQL_AVG =
@@ -676,6 +754,22 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-sql-stddev_pop-serial", 1);
     public static final FunctionIdentifier SERIAL_LOCAL_SQL_STDDEV_POP =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-stddev_pop-serial", 1);
+    public static final FunctionIdentifier SERIAL_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var-serial", 1);
+    public static final FunctionIdentifier SERIAL_GLOBAL_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-var-serial", 1);
+    public static final FunctionIdentifier SERIAL_INTERMEDIATE_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-sql-var-serial", 1);
+    public static final FunctionIdentifier SERIAL_LOCAL_SQL_VAR =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-var-serial", 1);
+    public static final FunctionIdentifier SERIAL_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var_pop-serial", 1);
+    public static final FunctionIdentifier SERIAL_GLOBAL_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-var_pop-serial", 1);
+    public static final FunctionIdentifier SERIAL_INTERMEDIATE_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-sql-var_pop-serial", 1);
+    public static final FunctionIdentifier SERIAL_LOCAL_SQL_VAR_POP =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-var_pop-serial", 1);
 
     // distinct sql aggregate functions
     public static final FunctionIdentifier SQL_COUNT_DISTINCT =
@@ -706,6 +800,14 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-stddev_pop-distinct", 1);
     public static final FunctionIdentifier SCALAR_SQL_STDDEV_POP_DISTINCT =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-stddev_pop-distinct", 1);
+    public static final FunctionIdentifier SQL_VAR_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-var-distinct", 1);
+    public static final FunctionIdentifier SCALAR_SQL_VAR_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var-distinct", 1);
+    public static final FunctionIdentifier SQL_VAR_POP_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-var_pop-distinct", 1);
+    public static final FunctionIdentifier SCALAR_SQL_VAR_POP_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var_pop-distinct", 1);
 
     // unnesting functions
     public static final FunctionIdentifier SCAN_COLLECTION =
@@ -1451,6 +1553,12 @@ public class BuiltinFunctions {
         addPrivateFunction(LOCAL_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
         addFunction(STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
         addPrivateFunction(GLOBAL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(LOCAL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addFunction(VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(GLOBAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(LOCAL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addFunction(VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(GLOBAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
 
         addPrivateFunction(SERIAL_SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
         addPrivateFunction(SERIAL_SQL_COUNT, AInt64TypeComputer.INSTANCE, true);
@@ -1483,6 +1591,22 @@ public class BuiltinFunctions {
         addPrivateFunction(SERIAL_GLOBAL_SQL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
         addPrivateFunction(SERIAL_LOCAL_SQL_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
         addPrivateFunction(SERIAL_INTERMEDIATE_SQL_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SCALAR_GLOBAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SCALAR_LOCAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(INTERMEDIATE_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_GLOBAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_LOCAL_SQL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_INTERMEDIATE_SQL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SCALAR_GLOBAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SCALAR_LOCAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(INTERMEDIATE_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_GLOBAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_LOCAL_SQL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_INTERMEDIATE_SQL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
 
         addFunction(SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
         addPrivateFunction(GLOBAL_SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
@@ -1517,6 +1641,20 @@ public class BuiltinFunctions {
         addFunction(SCALAR_SQL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
         addPrivateFunction(SCALAR_GLOBAL_SQL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
         addPrivateFunction(SCALAR_LOCAL_SQL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addFunction(SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(GLOBAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(LOCAL_SQL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(INTERMEDIATE_SQL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SCALAR_GLOBAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SCALAR_LOCAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addFunction(SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(GLOBAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(LOCAL_SQL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(INTERMEDIATE_SQL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SCALAR_GLOBAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SCALAR_LOCAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
 
         addPrivateFunction(SERIAL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
         addPrivateFunction(SERIAL_COUNT, AInt64TypeComputer.INSTANCE, true);
@@ -1533,6 +1671,14 @@ public class BuiltinFunctions {
         addPrivateFunction(SERIAL_GLOBAL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
         addPrivateFunction(SERIAL_LOCAL_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
         addPrivateFunction(SERIAL_INTERMEDIATE_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_GLOBAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_LOCAL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_INTERMEDIATE_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_GLOBAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_LOCAL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+        addPrivateFunction(SERIAL_INTERMEDIATE_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
 
         // Distinct aggregate functions
 
@@ -1571,6 +1717,16 @@ public class BuiltinFunctions {
         addFunction(SQL_STDDEV_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
         addFunction(SCALAR_SQL_STDDEV_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
 
+        addFunction(VAR_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_VAR_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+        addFunction(SQL_VAR_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_SQL_VAR_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+
+        addFunction(VAR_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_VAR_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+        addFunction(SQL_VAR_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_SQL_VAR_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+
         // Similarity functions
         addFunction(EDIT_DISTANCE_CONTAINS, OrderedListOfAnyTypeComputer.INSTANCE, true);
         addFunction(SIMILARITY_JACCARD, AFloatTypeComputer.INSTANCE, true);
@@ -1957,6 +2113,70 @@ public class BuiltinFunctions {
         addDistinctAgg(STDDEV_POP_DISTINCT, SCALAR_STDDEV_POP);
         addScalarAgg(STDDEV_POP_DISTINCT, SCALAR_STDDEV_POP_DISTINCT);
 
+        // VAR
+
+        addAgg(VAR);
+        addAgg(LOCAL_VAR);
+        addAgg(GLOBAL_VAR);
+        addLocalAgg(VAR, LOCAL_VAR);
+        addIntermediateAgg(VAR, INTERMEDIATE_VAR);
+        addIntermediateAgg(LOCAL_VAR, INTERMEDIATE_VAR);
+        addIntermediateAgg(GLOBAL_VAR, INTERMEDIATE_VAR);
+        addGlobalAgg(VAR, GLOBAL_VAR);
+
+        addScalarAgg(VAR, SCALAR_VAR);
+        addScalarAgg(GLOBAL_VAR, SCALAR_GLOBAL_VAR);
+        addScalarAgg(LOCAL_VAR, SCALAR_LOCAL_VAR);
+
+        addSerialAgg(VAR, SERIAL_VAR);
+        addSerialAgg(LOCAL_VAR, SERIAL_LOCAL_VAR);
+        addSerialAgg(GLOBAL_VAR, SERIAL_GLOBAL_VAR);
+        addAgg(SERIAL_VAR);
+        addAgg(SERIAL_LOCAL_VAR);
+        addAgg(SERIAL_GLOBAL_VAR);
+        addLocalAgg(SERIAL_VAR, SERIAL_LOCAL_VAR);
+        addIntermediateAgg(SERIAL_VAR, SERIAL_INTERMEDIATE_VAR);
+        addIntermediateAgg(SERIAL_LOCAL_VAR, SERIAL_INTERMEDIATE_VAR);
+        addIntermediateAgg(SERIAL_GLOBAL_VAR, SERIAL_INTERMEDIATE_VAR);
+        addGlobalAgg(SERIAL_VAR, SERIAL_GLOBAL_VAR);
+
+        // VAR DISTINCT
+
+        addDistinctAgg(VAR_DISTINCT, SCALAR_VAR);
+        addScalarAgg(VAR_DISTINCT, SCALAR_VAR_DISTINCT);
+
+        // VAR_POP
+
+        addAgg(VAR_POP);
+        addAgg(LOCAL_VAR_POP);
+        addAgg(GLOBAL_VAR_POP);
+        addLocalAgg(VAR_POP, LOCAL_VAR_POP);
+        addIntermediateAgg(VAR_POP, INTERMEDIATE_VAR_POP);
+        addIntermediateAgg(LOCAL_VAR_POP, INTERMEDIATE_VAR_POP);
+        addIntermediateAgg(GLOBAL_VAR_POP, INTERMEDIATE_VAR_POP);
+        addGlobalAgg(VAR_POP, GLOBAL_VAR_POP);
+
+        addScalarAgg(VAR_POP, SCALAR_VAR_POP);
+        addScalarAgg(GLOBAL_VAR_POP, SCALAR_GLOBAL_VAR_POP);
+        addScalarAgg(LOCAL_VAR_POP, SCALAR_LOCAL_VAR_POP);
+
+        addSerialAgg(VAR_POP, SERIAL_VAR_POP);
+        addSerialAgg(LOCAL_VAR_POP, SERIAL_LOCAL_VAR_POP);
+        addSerialAgg(GLOBAL_VAR_POP, SERIAL_GLOBAL_VAR_POP);
+        addAgg(SERIAL_VAR_POP);
+        addAgg(SERIAL_LOCAL_VAR_POP);
+        addAgg(SERIAL_GLOBAL_VAR_POP);
+        addLocalAgg(SERIAL_VAR_POP, SERIAL_LOCAL_VAR_POP);
+        addIntermediateAgg(SERIAL_VAR_POP, SERIAL_INTERMEDIATE_VAR_POP);
+        addIntermediateAgg(SERIAL_LOCAL_VAR_POP, SERIAL_INTERMEDIATE_VAR_POP);
+        addIntermediateAgg(SERIAL_GLOBAL_VAR_POP, SERIAL_INTERMEDIATE_VAR_POP);
+        addGlobalAgg(SERIAL_VAR_POP, SERIAL_GLOBAL_VAR_POP);
+
+        // VAR_POP DISTINCT
+
+        addDistinctAgg(VAR_POP_DISTINCT, SCALAR_VAR_POP);
+        addScalarAgg(VAR_POP_DISTINCT, SCALAR_VAR_POP_DISTINCT);
+
         // FIRST_ELEMENT
 
         addAgg(SCALAR_FIRST_ELEMENT);
@@ -2103,6 +2323,60 @@ public class BuiltinFunctions {
         addIntermediateAgg(SERIAL_GLOBAL_SQL_STDDEV_POP, SERIAL_INTERMEDIATE_SQL_STDDEV_POP);
         addGlobalAgg(SERIAL_SQL_STDDEV_POP, SERIAL_GLOBAL_SQL_STDDEV_POP);
 
+        // SQL VAR
+
+        addAgg(SQL_VAR);
+        addAgg(LOCAL_SQL_VAR);
+        addAgg(GLOBAL_SQL_VAR);
+        addLocalAgg(SQL_VAR, LOCAL_SQL_VAR);
+        addIntermediateAgg(SQL_VAR, INTERMEDIATE_SQL_VAR);
+        addIntermediateAgg(LOCAL_SQL_VAR, INTERMEDIATE_SQL_VAR);
+        addIntermediateAgg(GLOBAL_SQL_VAR, INTERMEDIATE_SQL_VAR);
+        addGlobalAgg(SQL_VAR, GLOBAL_SQL_VAR);
+
+        addScalarAgg(SQL_VAR, SCALAR_SQL_VAR);
+        addScalarAgg(GLOBAL_SQL_VAR, SCALAR_GLOBAL_SQL_VAR);
+        addScalarAgg(LOCAL_SQL_VAR, SCALAR_LOCAL_SQL_VAR);
+
+        addSerialAgg(SQL_VAR, SERIAL_SQL_VAR);
+        addSerialAgg(LOCAL_SQL_VAR, SERIAL_LOCAL_SQL_VAR);
+        addSerialAgg(GLOBAL_SQL_VAR, SERIAL_GLOBAL_SQL_VAR);
+        addAgg(SERIAL_SQL_VAR);
+        addAgg(SERIAL_LOCAL_SQL_VAR);
+        addAgg(SERIAL_GLOBAL_SQL_VAR);
+        addLocalAgg(SERIAL_SQL_VAR, SERIAL_LOCAL_SQL_VAR);
+        addIntermediateAgg(SERIAL_SQL_VAR, SERIAL_INTERMEDIATE_SQL_VAR);
+        addIntermediateAgg(SERIAL_LOCAL_SQL_VAR, SERIAL_INTERMEDIATE_SQL_VAR);
+        addIntermediateAgg(SERIAL_GLOBAL_SQL_VAR, SERIAL_INTERMEDIATE_SQL_VAR);
+        addGlobalAgg(SERIAL_SQL_VAR, SERIAL_GLOBAL_SQL_VAR);
+
+        // SQL VAR_POP
+
+        addAgg(SQL_VAR_POP);
+        addAgg(LOCAL_SQL_VAR_POP);
+        addAgg(GLOBAL_SQL_VAR_POP);
+        addLocalAgg(SQL_VAR_POP, LOCAL_SQL_VAR_POP);
+        addIntermediateAgg(SQL_VAR_POP, INTERMEDIATE_SQL_VAR_POP);
+        addIntermediateAgg(LOCAL_SQL_VAR_POP, INTERMEDIATE_SQL_VAR_POP);
+        addIntermediateAgg(GLOBAL_SQL_VAR_POP, INTERMEDIATE_SQL_VAR_POP);
+        addGlobalAgg(SQL_VAR_POP, GLOBAL_SQL_VAR_POP);
+
+        addScalarAgg(SQL_VAR_POP, SCALAR_SQL_VAR_POP);
+        addScalarAgg(GLOBAL_SQL_VAR_POP, SCALAR_GLOBAL_SQL_VAR_POP);
+        addScalarAgg(LOCAL_SQL_VAR_POP, SCALAR_LOCAL_SQL_VAR_POP);
+
+        addSerialAgg(SQL_VAR_POP, SERIAL_SQL_VAR_POP);
+        addSerialAgg(LOCAL_SQL_VAR_POP, SERIAL_LOCAL_SQL_VAR_POP);
+        addSerialAgg(GLOBAL_SQL_VAR_POP, SERIAL_GLOBAL_SQL_VAR_POP);
+        addAgg(SERIAL_SQL_VAR_POP);
+        addAgg(SERIAL_LOCAL_SQL_VAR_POP);
+        addAgg(SERIAL_GLOBAL_SQL_VAR_POP);
+        addLocalAgg(SERIAL_SQL_VAR_POP, SERIAL_LOCAL_SQL_VAR_POP);
+        addIntermediateAgg(SERIAL_SQL_VAR_POP, SERIAL_INTERMEDIATE_SQL_VAR_POP);
+        addIntermediateAgg(SERIAL_LOCAL_SQL_VAR_POP, SERIAL_INTERMEDIATE_SQL_VAR_POP);
+        addIntermediateAgg(SERIAL_GLOBAL_SQL_VAR_POP, SERIAL_INTERMEDIATE_SQL_VAR_POP);
+        addGlobalAgg(SERIAL_SQL_VAR_POP, SERIAL_GLOBAL_SQL_VAR_POP);
+
         // SQL AVG DISTINCT
 
         addDistinctAgg(SQL_AVG_DISTINCT, SCALAR_SQL_AVG);
@@ -2118,6 +2392,16 @@ public class BuiltinFunctions {
         addDistinctAgg(SQL_STDDEV_POP_DISTINCT, SCALAR_SQL_STDDEV_POP);
         addScalarAgg(SQL_STDDEV_POP_DISTINCT, SCALAR_SQL_STDDEV_POP_DISTINCT);
 
+        // SQL VAR DISTINCT
+
+        addDistinctAgg(SQL_VAR_DISTINCT, SCALAR_SQL_VAR);
+        addScalarAgg(SQL_VAR_DISTINCT, SCALAR_SQL_VAR_DISTINCT);
+
+        // SQL VAR_POP DISTINCT
+
+        addDistinctAgg(SQL_VAR_POP_DISTINCT, SCALAR_SQL_VAR_POP);
+        addScalarAgg(SQL_VAR_POP_DISTINCT, SCALAR_SQL_VAR_POP_DISTINCT);
+
         // SQL COUNT
 
         addAgg(SQL_COUNT);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..853aec3
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarAggregateDescriptor.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.scalar;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.std.SqlVarAggregateDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+
+public class ScalarSqlVarAggregateDescriptor extends AbstractScalarAggregateDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public final static FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_VAR;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new ScalarSqlVarAggregateDescriptor(SqlVarAggregateDescriptor.FACTORY.createFunctionDescriptor());
+        }
+    };
+
+    private ScalarSqlVarAggregateDescriptor(IFunctionDescriptor aggFuncDesc) {
+        super(aggFuncDesc);
+    }
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..072a9bd
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.scalar;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.std.SqlVarPopAggregateDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+
+public class ScalarSqlVarPopAggregateDescriptor extends AbstractScalarAggregateDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public final static FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_VAR_POP;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new ScalarSqlVarPopAggregateDescriptor(
+                    SqlVarPopAggregateDescriptor.FACTORY.createFunctionDescriptor());
+        }
+    };
+
+    private ScalarSqlVarPopAggregateDescriptor(IFunctionDescriptor aggFuncDesc) {
+        super(aggFuncDesc);
+    }
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarAggregateDescriptor.java
new file mode 100644
index 0000000..73a5dda
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarAggregateDescriptor.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.scalar;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.std.VarAggregateDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+
+public class ScalarVarAggregateDescriptor extends AbstractScalarAggregateDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public final static FunctionIdentifier FID = BuiltinFunctions.SCALAR_VAR;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new ScalarVarAggregateDescriptor(VarAggregateDescriptor.FACTORY.createFunctionDescriptor());
+        }
+    };
+
+    private ScalarVarAggregateDescriptor(IFunctionDescriptor aggFuncDesc) {
+        super(aggFuncDesc);
+    }
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..d843a70
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopAggregateDescriptor.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.aggregates.scalar;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.std.VarPopAggregateDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+
+public class ScalarVarPopAggregateDescriptor extends AbstractScalarAggregateDescriptor {
+
+    private static final long serialVersionUID = 1L;
+
+    public final static FunctionIdentifier FID = BuiltinFunctions.SCALAR_VAR_POP;
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new ScalarVarPopAggregateDescriptor(VarPopAggregateDescriptor.FACTORY.createFunctionDescriptor());
+        }
+    };
+
+    private ScalarVarPopAggregateDescriptor(IFunctionDescriptor aggFuncDesc) {
+        super(aggFuncDesc);
+    }
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java
index d537043..ec03472 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java
@@ -289,6 +289,23 @@ public abstract class AbstractSerializableSingleVariableStatisticsAggregateFunct
         }
     }
 
+    protected void finishVarFinalResults(byte[] state, int start, int len, DataOutput result, int delta)
+            throws HyracksDataException {
+        double m2 = BufferSerDeUtil.getDouble(state, start + M2_OFFSET);
+        long count = BufferSerDeUtil.getLong(state, start + COUNT_OFFSET);
+        ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
+        try {
+            if (count <= 1 || aggType == ATypeTag.NULL) {
+                nullSerde.serialize(ANull.NULL, result);
+            } else {
+                aDouble.setValue(m2 / (count - delta));
+                doubleSerde.serialize(aDouble, result);
+            }
+        } catch (IOException e) {
+            throw HyracksDataException.create(e);
+        }
+    }
+
     protected boolean skipStep(byte[] state, int start) {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..878b8ce
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableGlobalSqlVarAggregateDescriptor
+        extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableGlobalSqlVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_GLOBAL_SQL_VAR;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableGlobalSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateFunction.java
new file mode 100644
index 0000000..c00fee3
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateFunction.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableGlobalSqlVarAggregateFunction
+        extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+    private final boolean isPop;
+    private final int delta;
+
+    public SerializableGlobalSqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+            boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+        if (isPop) {
+            delta = 0;
+        } else {
+            delta = 1;
+        }
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+        processPartialResults(tuple, state, start, len);
+    }
+
+    @Override
+    public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishVarFinalResults(state, start, len, result, delta);
+    }
+
+    @Override
+    public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishPartialResults(state, start, len, result);
+    }
+
+    @Override
+    protected void processNull(byte[] state, int start) {
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..f3f1c8c
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableGlobalSqlVarPopAggregateDescriptor
+        extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableGlobalSqlVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_GLOBAL_SQL_VAR_POP;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableGlobalSqlVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateDescriptor.java
new file mode 100644
index 0000000..f0130ec
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableGlobalVarAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableGlobalVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_GLOBAL_VAR;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableGlobalVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateFunction.java
new file mode 100644
index 0000000..4f33735
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateFunction.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableGlobalVarAggregateFunction
+        extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+    private final boolean isPop;
+    private final int delta;
+
+    public SerializableGlobalVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+            boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+        if (isPop) {
+            delta = 0;
+        } else {
+            delta = 1;
+        }
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+        processPartialResults(tuple, state, start, len);
+    }
+
+    @Override
+    public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishVarFinalResults(state, start, len, result, delta);
+    }
+
+    @Override
+    public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishPartialResults(state, start, len, result);
+    }
+
+    @Override
+    protected void processNull(byte[] state, int start) {
+        state[start + AGG_TYPE_OFFSET] = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+    }
+
+    @Override
+    protected boolean skipStep(byte[] state, int start) {
+        ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
+        return aggType == ATypeTag.NULL;
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..6a42614
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarPopAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableGlobalVarPopAggregateDescriptor
+        extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableGlobalVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_GLOBAL_VAR_POP;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableGlobalVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..b158e1a
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableIntermediateSqlVarAggregateDescriptor
+        extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableIntermediateSqlVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_INTERMEDIATE_SQL_VAR;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableIntermediateSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateFunction.java
new file mode 100644
index 0000000..c14dd54
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateFunction.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableIntermediateSqlVarAggregateFunction
+        extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+    private final boolean isPop;
+
+    public SerializableIntermediateSqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+            boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+        processPartialResults(tuple, state, start, len);
+    }
+
+    @Override
+    public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishPartialResults(state, start, len, result);
+    }
+
+    @Override
+    public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishPartialResults(state, start, len, result);
+    }
+
+    @Override
+    protected void processNull(byte[] state, int start) {
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..f34f604
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableIntermediateSqlVarPopAggregateDescriptor
+        extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableIntermediateSqlVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_INTERMEDIATE_SQL_VAR_POP;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableIntermediateSqlVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateDescriptor.java
new file mode 100644
index 0000000..377c6d2
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableIntermediateVarAggregateDescriptor
+        extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableIntermediateVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_INTERMEDIATE_VAR;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableIntermediateVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateFunction.java
new file mode 100644
index 0000000..dab221e
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateFunction.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableIntermediateVarAggregateFunction
+        extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+    private final boolean isPop;
+
+    public SerializableIntermediateVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+            boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+        super(args, context, sourceLoc);
+        this.isPop = isPop;
+    }
+
+    @Override
+    public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+        processPartialResults(tuple, state, start, len);
+    }
+
+    @Override
+    public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishPartialResults(state, start, len, result);
+    }
+
+    @Override
+    public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+        finishPartialResults(state, start, len, result);
+    }
+
+    @Override
+    protected void processNull(byte[] state, int start) {
+        state[start + AGG_TYPE_OFFSET] = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+    }
+
+    @Override
+    protected boolean skipStep(byte[] state, int start) {
+        ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
+        return aggType == ATypeTag.NULL;
+    }
+
+    @Override
+    protected FunctionIdentifier getFunctionIdentifier() {
+        if (isPop) {
+            return BuiltinFunctions.VAR_POP;
+        } else {
+            return BuiltinFunctions.VAR;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..787d54a
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarPopAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableIntermediateVarPopAggregateDescriptor
+        extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableIntermediateVarPopAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_INTERMEDIATE_VAR_POP;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableIntermediateVarAggregateFunction(args, ctx, true, sourceLoc);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..2b0c565
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableLocalSqlVarAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new SerializableLocalSqlVarAggregateDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.SERIAL_LOCAL_SQL_VAR;
+    }
+
+    @Override
+    public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+            final IScalarEvaluatorFactory[] args) {
+        return new ISerializedAggregateEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+                    throws HyracksDataException {
+                return new SerializableLocalSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+            }
+        };
+    }
+
+}


[06/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var/scalar_var.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var/scalar_var.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var/scalar_var.3.ast
new file mode 100644
index 0000000..71b0a16
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var/scalar_var.3.ast
@@ -0,0 +1,222 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      Let Variable [ Name=$i8 ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i16 ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i32 ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i64 ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$f ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$d ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      SELECT ELEMENT [
+      Variable [ Name=$i ]
+      ]
+      FROM [        OrderedListConstructor [
+          Variable [ Name=$i8 ]
+          Variable [ Name=$i16 ]
+          Variable [ Name=$i32 ]
+          Variable [ Name=$i64 ]
+          Variable [ Name=$f ]
+          Variable [ Name=$d ]
+        ]
+        AS Variable [ Name=$i ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      Let Variable [ Name=$i8 ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i16 ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i32 ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i64 ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$f ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$d ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      SELECT ELEMENT [
+      Variable [ Name=$i ]
+      ]
+      FROM [        OrderedListConstructor [
+          Variable [ Name=$i8 ]
+          Variable [ Name=$i16 ]
+          Variable [ Name=$i32 ]
+          Variable [ Name=$i64 ]
+          Variable [ Name=$f ]
+          Variable [ Name=$d ]
+        ]
+        AS Variable [ Name=$i ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.3.ast
new file mode 100644
index 0000000..a4126bb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.3.ast
@@ -0,0 +1,27 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var@1[
+        OrderedListConstructor [
+        ]
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var_pop@1[
+        OrderedListConstructor [
+        ]
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.3.ast
new file mode 100644
index 0000000..22e3104
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.3.ast
@@ -0,0 +1,234 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      Let Variable [ Name=$i8 ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i16 ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i32 ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i64 ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$f ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$d ]
+        :=
+        FunctionCall asterix.sql-var@1[
+          OrderedListConstructor [
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      SELECT ELEMENT [
+      Variable [ Name=$i ]
+      ]
+      FROM [        OrderedListConstructor [
+          Variable [ Name=$i8 ]
+          Variable [ Name=$i16 ]
+          Variable [ Name=$i32 ]
+          Variable [ Name=$i64 ]
+          Variable [ Name=$f ]
+          Variable [ Name=$d ]
+        ]
+        AS Variable [ Name=$i ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      Let Variable [ Name=$i8 ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i16 ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i32 ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i64 ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$f ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$d ]
+        :=
+        FunctionCall asterix.sql-var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      SELECT ELEMENT [
+      Variable [ Name=$i ]
+      ]
+      FROM [        OrderedListConstructor [
+          Variable [ Name=$i8 ]
+          Variable [ Name=$i16 ]
+          Variable [ Name=$i32 ]
+          Variable [ Name=$i64 ]
+          Variable [ Name=$f ]
+          Variable [ Name=$d ]
+        ]
+        AS Variable [ Name=$i ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.3.ast
new file mode 100644
index 0000000..91b3b2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double/serial_var_double.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.3.ast
new file mode 100644
index 0000000..a5e419b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.3.ast
new file mode 100644
index 0000000..91b3b2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.1.ast
new file mode 100644
index 0000000..9af248f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : float
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.3.ast
new file mode 100644
index 0000000..91b3b2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float/serial_var_float.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.1.ast
new file mode 100644
index 0000000..9af248f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : float
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.3.ast
new file mode 100644
index 0000000..a5e419b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_float_null/serial_var_float_null.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.1.ast
new file mode 100644
index 0000000..16d25a8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : smallint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.3.ast
new file mode 100644
index 0000000..91b3b2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16/serial_var_int16.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.ast
new file mode 100644
index 0000000..16d25a8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : smallint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.3.ast
new file mode 100644
index 0000000..a5e419b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int16_null/serial_var_int16_null.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.1.ast
new file mode 100644
index 0000000..6eaf31a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : integer
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.3.ast
new file mode 100644
index 0000000..91b3b2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32/serial_var_int32.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.ast
new file mode 100644
index 0000000..6eaf31a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : integer
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.3.ast
new file mode 100644
index 0000000..a5e419b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int32_null/serial_var_int32_null.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.1.ast
new file mode 100644
index 0000000..7911712
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : bigint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.3.ast
new file mode 100644
index 0000000..91b3b2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64/serial_var_int64.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.ast
new file mode 100644
index 0000000..7911712
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : bigint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.3.ast
new file mode 100644
index 0000000..a5e419b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int64_null/serial_var_int64_null.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.1.ast
new file mode 100644
index 0000000..44c9cde
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : tinyint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.3.ast
new file mode 100644
index 0000000..91b3b2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8/serial_var_int8.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.ast
new file mode 100644
index 0000000..44c9cde
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : tinyint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.3.ast
new file mode 100644
index 0000000..a5e419b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_int8_null/serial_var_int8_null.3.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#2 ]
+    ]
+  )
+]
+var
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=#3 ]
+        Field=t
+      ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS Variable [ Name=#3 ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=#1 ]
+  (
+    t:=Variable [ Name=$t ]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.3.ast
new file mode 100644
index 0000000..5ed5c3a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_mixed/serial_var_int64_null.3.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.3.ast
new file mode 100644
index 0000000..fff6e1a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/serial_var_pop_mixed/serial_var_pop_int64_null.3.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double/var_double.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double/var_double.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double/var_double.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double/var_double.1.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double/var_double.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double/var_double.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double/var_double.3.ast
new file mode 100644
index 0000000..9037555
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double/var_double.3.ast
@@ -0,0 +1,51 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [DOUBLE] [1.0]
+              LiteralExpr [DOUBLE] [2.0]
+              FunctionCall null.double@1[
+                LiteralExpr [STRING] [3.0]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [DOUBLE] [1.0]
+              LiteralExpr [DOUBLE] [2.0]
+              FunctionCall null.double@1[
+                LiteralExpr [STRING] [3.0]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double_null/var_double_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double_null/var_double_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double_null/var_double_null.1.ast
new file mode 100644
index 0000000..2b387f8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double_null/var_double_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : integer,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double_null/var_double_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double_null/var_double_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double_null/var_double_null.3.ast
new file mode 100644
index 0000000..0060c07
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_double_null/var_double_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.sql-var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=doubleField
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=doubleField
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_01/var_empty_01.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_01/var_empty_01.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_01/var_empty_01.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_01/var_empty_01.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_01/var_empty_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_01/var_empty_01.3.ast
new file mode 100644
index 0000000..c724d18
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_01/var_empty_01.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [LONG] [1]
+              LiteralExpr [LONG] [2]
+              LiteralExpr [LONG] [3]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+          Where
+            OperatorExpr [
+              Variable [ Name=$x ]
+              >
+              LiteralExpr [LONG] [10]
+            ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [LONG] [1]
+              LiteralExpr [LONG] [2]
+              LiteralExpr [LONG] [3]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+          Where
+            OperatorExpr [
+              Variable [ Name=$x ]
+              >
+              LiteralExpr [LONG] [10]
+            ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_02/var_empty_02.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_02/var_empty_02.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_02/var_empty_02.1.ast
new file mode 100644
index 0000000..baf977e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_02/var_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_02/var_empty_02.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_02/var_empty_02.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_02/var_empty_02.3.ast
new file mode 100644
index 0000000..1705103
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_empty_02/var_empty_02.3.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=$x ]
+            Field=val
+          ]
+          ]
+          FROM [            FunctionCall asterix.dataset@1[
+              LiteralExpr [STRING] [test.Test]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var_pop@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=$x ]
+            Field=val
+          ]
+          ]
+          FROM [            FunctionCall asterix.dataset@1[
+              LiteralExpr [STRING] [test.Test]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float/var_float.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float/var_float.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float/var_float.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float/var_float.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float/var_float.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float/var_float.3.ast
new file mode 100644
index 0000000..592907d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float/var_float.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float_null/var_float_nu.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float_null/var_float_nu.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float_null/var_float_nu.1.ast
new file mode 100644
index 0000000..b01283e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float_null/var_float_nu.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : bigint,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float_null/var_float_nu.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float_null/var_float_nu.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float_null/var_float_nu.3.ast
new file mode 100644
index 0000000..0587de5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_float_null/var_float_nu.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.sql-var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=floatField
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=floatField
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16/var_int16.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16/var_int16.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16/var_int16.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16/var_int16.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16/var_int16.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16/var_int16.3.ast
new file mode 100644
index 0000000..f741ad6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16/var_int16.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16_null/var_int16_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16_null/var_int16_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16_null/var_int16_null.1.ast
new file mode 100644
index 0000000..b01283e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16_null/var_int16_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : bigint,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16_null/var_int16_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16_null/var_int16_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16_null/var_int16_null.3.ast
new file mode 100644
index 0000000..1d41f05
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int16_null/var_int16_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.sql-var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int16Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int16Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32/var_int32.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32/var_int32.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32/var_int32.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32/var_int32.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32/var_int32.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32/var_int32.3.ast
new file mode 100644
index 0000000..d7dd2a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32/var_int32.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int32@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int32@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int32@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int32@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int32@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int32@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]


[08/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.3.query.sqlpp
new file mode 100644
index 0000000..7116737
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.valplus from g)) as var,
+   strict_var_pop((select value g.valplus from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..07312bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : integer
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.2.update.sqlpp
new file mode 100644
index 0000000..a248a0f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':integer('4'),'valplus':integer('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':integer('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':integer('6'),'valplus':integer('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':integer('4'),'valplus':integer('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':integer('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.3.query.sqlpp
new file mode 100644
index 0000000..23e33cc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32/serial_var_int32.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.val from g)) as var,
+   strict_var_pop((select value g.val from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..07312bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : integer
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.2.update.sqlpp
new file mode 100644
index 0000000..a248a0f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':integer('4'),'valplus':integer('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':integer('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':integer('6'),'valplus':integer('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':integer('4'),'valplus':integer('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':integer('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.3.query.sqlpp
new file mode 100644
index 0000000..7116737
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.valplus from g)) as var,
+   strict_var_pop((select value g.valplus from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..5e9972c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : bigint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.2.update.sqlpp
new file mode 100644
index 0000000..b460af2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':bigint('4'),'valplus':bigint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':bigint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':bigint('6'),'valplus':bigint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':bigint('4'),'valplus':bigint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':bigint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.3.query.sqlpp
new file mode 100644
index 0000000..23e33cc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64/serial_var_int64.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.val from g)) as var,
+   strict_var_pop((select value g.val from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..5e9972c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : bigint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.2.update.sqlpp
new file mode 100644
index 0000000..b460af2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':bigint('4'),'valplus':bigint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':bigint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':bigint('6'),'valplus':bigint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':bigint('4'),'valplus':bigint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':bigint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.3.query.sqlpp
new file mode 100644
index 0000000..7116737
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.valplus from g)) as var,
+   strict_var_pop((select value g.valplus from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..c45dbfe
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : tinyint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.2.update.sqlpp
new file mode 100644
index 0000000..5a65a20
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':tinyint('4'),'valplus':tinyint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':tinyint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':tinyint('6'),'valplus':tinyint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':tinyint('4'),'valplus':tinyint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':tinyint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.3.query.sqlpp
new file mode 100644
index 0000000..23e33cc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8/serial_var_int8.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.val from g)) as var,
+   strict_var_pop((select value g.val from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..c45dbfe
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : tinyint
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.2.update.sqlpp
new file mode 100644
index 0000000..5a65a20
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':tinyint('4'),'valplus':tinyint('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':tinyint('5')};
+insert into Test
+select element {'id':2,'gid':1,'val':tinyint('6'),'valplus':tinyint('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':tinyint('4'),'valplus':tinyint('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':tinyint('4'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.3.query.sqlpp
new file mode 100644
index 0000000..7116737
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, strict_var((select value g.valplus from g)) as var,
+   strict_var_pop((select value g.valplus from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.2.update.sqlpp
new file mode 100644
index 0000000..1b4eac9
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':double(4.32),'valplus':float('2.0')};
+insert into Test
+select element {'id':1,'gid':1,'val':double(5.32),'valplus':float('1.0')};
+insert into Test
+select element {'id':2,'gid':1,'val':double(6.32),'valplus':'hello world'};
+insert into Test
+select element {'id':3,'gid':1,'val':double(4.32),'valplus':double('3.0')};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.3.query.sqlpp
new file mode 100644
index 0000000..4f7a31f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ /*
+ * Description  : Run serial-var over an multiset with mixed types
+ * Expected Res : Failure
+ * Date         : March 5th 2018
+ */
+
+use test;
+
+select gid, strict_var((select value g.valplus from g)) as var
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.2.update.sqlpp
new file mode 100644
index 0000000..1b4eac9
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':double(4.32),'valplus':float('2.0')};
+insert into Test
+select element {'id':1,'gid':1,'val':double(5.32),'valplus':float('1.0')};
+insert into Test
+select element {'id':2,'gid':1,'val':double(6.32),'valplus':'hello world'};
+insert into Test
+select element {'id':3,'gid':1,'val':double(4.32),'valplus':double('3.0')};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.3.query.sqlpp
new file mode 100644
index 0000000..91f66d8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ /*
+ * Description  : Run serial-var_pop over an multiset with mixed types
+ * Expected Res : Failure
+ * Date         : March 5th 2018
+ */
+
+use test;
+
+select gid, strict_var_pop((select value g.valplus from g)) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_mixed/stddev_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_mixed/stddev_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_mixed/stddev_mixed.3.query.sqlpp
index d57619d..ebdc53b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_mixed/stddev_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_mixed/stddev_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 /*
-* Description  : Run stddev over an ordered list with mixed types
+* Description  : Run stddev over an multiset with mixed types
 * Expected Res : Failure
 * Date         : March 5th 2018
 */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp
index d068bb2..0b0a32d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/stddev_pop_mixed/stddev_pop_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 /*
-* Description  : Run stddev_pop over an ordered list with mixed types
+* Description  : Run stddev_pop over an multiset with mixed types
 * Expected Res : Failure
 * Date         : Jun 2nd 2013
 */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.3.query.sqlpp
index 175fcee..3c20a2c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 /*
-* Description  : Run sum over an ordered list with mixed types
+* Description  : Run sum over an multiset with mixed types
 * Expected Res : Failure
 * Date         : Jun 2nd 2013
 */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_distinct/var_distinct.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_distinct/var_distinct.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_distinct/var_distinct.1.query.sqlpp
new file mode 100644
index 0000000..1a6c6ef
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_distinct/var_distinct.1.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ {
+   't1': to_bigint(strict_var(distinct [10,20,30,10,20,30,10])),
+   't2': to_bigint(strict_var(distinct [null,missing,null,missing])),
+   't3': to_bigint(strict_var(distinct [40,null,missing,50,40,null,missing,50,40])),
+   't4': to_bigint(strict_var(distinct [])),
+   't5': to_bigint(strict_var_pop(distinct [10,20,30,10,20,30,10])),
+   't6': to_bigint(strict_var_pop(distinct [null,missing,null,missing])),
+   't7': to_bigint(strict_var_pop(distinct [40,null,missing,50,40,null,missing,50,40])),
+   't8': to_bigint(strict_var_pop(distinct []))
+ };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double/var_double.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double/var_double.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double/var_double.1.ddl.sqlpp
new file mode 100644
index 0000000..ad97753
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double/var_double.1.ddl.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double/var_double.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double/var_double.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double/var_double.3.query.sqlpp
new file mode 100644
index 0000000..c86f158
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double/var_double.3.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+{'var':(select element strict_var((
+    select element x
+    from  [1.0,2.0,double('3.0')] as x
+))), 'var_pop': (select element strict_var_pop((
+    select element x
+    from  [1.0,2.0,double('3.0')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double_null/var_double_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double_null/var_double_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double_null/var_double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..3f2c5bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double_null/var_double_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : integer,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double_null/var_double_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double_null/var_double_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double_null/var_double_null.3.query.sqlpp
new file mode 100644
index 0000000..028f030
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_double_null/var_double_null.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+{'var':test.strict_var((
+    select element x.doubleField
+    from  Numeric as x
+)), 'var_pop':test.strict_var_pop((
+    select element x.doubleField
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_01/var_empty_01.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_01/var_empty_01.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_01/var_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..5f589a8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_01/var_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that var aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_01/var_empty_01.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_01/var_empty_01.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_01/var_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..3dc4380
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_01/var_empty_01.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that var aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+{'var': (select element test.strict_var((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+))), 'var_pop': (select element test.strict_var_pop((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_02/var_empty_02.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_02/var_empty_02.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_02/var_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..c218aa2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_02/var_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that var aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : integer,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_02/var_empty_02.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_02/var_empty_02.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_02/var_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..986f49c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_empty_02/var_empty_02.3.query.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that var aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+{'var': (select element test.strict_var((
+    select element x.val
+    from  Test as x
+))), 'var_pop': (select element test.strict_var_pop((
+    select element x.val
+    from  Test as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float/var_float.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float/var_float.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float/var_float.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float/var_float.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float/var_float.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float/var_float.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float/var_float.3.query.sqlpp
new file mode 100644
index 0000000..79e8f24
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float/var_float.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.strict_var((
+    select element x
+    from  [test.float('1'),test.float('2'),test.float('3')] as x
+))), 'var_pop': (select element test.strict_var_pop((
+    select element x
+    from  [test.float('1'),test.float('2'),test.float('3')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float_null/var_float_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float_null/var_float_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float_null/var_float_null.1.ddl.sqlpp
new file mode 100644
index 0000000..3f2c5bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float_null/var_float_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : integer,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float_null/var_float_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float_null/var_float_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float_null/var_float_null.3.query.sqlpp
new file mode 100644
index 0000000..72005cc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_float_null/var_float_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.strict_var((
+    select element x.floatField
+    from  Numeric as x
+)), 'var_pop':test.strict_var_pop((
+    select element x.floatField
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16/var_int16.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16/var_int16.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16/var_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16/var_int16.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16/var_int16.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16/var_int16.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16/var_int16.3.query.sqlpp
new file mode 100644
index 0000000..396c430
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16/var_int16.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.strict_var((
+    select element x
+    from  [test.smallint('1'),test.smallint('2'),test.smallint('3')] as x
+))), 'var_pop': (select element test.strict_var_pop((
+    select element x
+    from  [test.smallint('1'),test.smallint('2'),test.smallint('3')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16_null/var_int16_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16_null/var_int16_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16_null/var_int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..3f2c5bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16_null/var_int16_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : integer,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16_null/var_int16_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16_null/var_int16_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16_null/var_int16_null.3.query.sqlpp
new file mode 100644
index 0000000..2db7bb1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int16_null/var_int16_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.strict_var((
+    select element x.int16Field
+    from  Numeric as x
+)), 'var_pop':test.strict_var_pop((
+    select element x.int16Field
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32/var_int32.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32/var_int32.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32/var_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32/var_int32.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32/var_int32.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32/var_int32.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32/var_int32.3.query.sqlpp
new file mode 100644
index 0000000..e04dd4c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32/var_int32.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.strict_var((
+    select element x
+    from  [1,2,3] as x
+))), 'var_pop': (select element test.strict_var_pop((
+    select element x
+    from  [1,2,3] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32_null/var_int32_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32_null/var_int32_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32_null/var_int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..3f2c5bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32_null/var_int32_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : integer,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32_null/var_int32_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32_null/var_int32_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32_null/var_int32_null.3.query.sqlpp
new file mode 100644
index 0000000..2a6ccf7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int32_null/var_int32_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.strict_var((
+    select element x.int32Field
+    from  Numeric as x
+)), 'var_pop':test.strict_var_pop((
+    select element x.int32Field
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64/var_int64.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64/var_int64.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64/var_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64/var_int64.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+


[05/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32_null/var_int32_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32_null/var_int32_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32_null/var_int32_null.1.ast
new file mode 100644
index 0000000..b01283e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32_null/var_int32_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : bigint,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32_null/var_int32_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32_null/var_int32_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32_null/var_int32_null.3.ast
new file mode 100644
index 0000000..8e87e8a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int32_null/var_int32_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.sql-var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int32Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int32Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64/var_int64.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64/var_int64.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64/var_int64.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64/var_int64.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64/var_int64.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64/var_int64.3.ast
new file mode 100644
index 0000000..dd6556e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64/var_int64.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64_null/var_int64_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64_null/var_int64_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64_null/var_int64_null.1.ast
new file mode 100644
index 0000000..b01283e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64_null/var_int64_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : bigint,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64_null/var_int64_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64_null/var_int64_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64_null/var_int64_null.3.ast
new file mode 100644
index 0000000..86920ae
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int64_null/var_int64_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.sql-var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int64Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int64Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8/var_int8.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8/var_int8.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8/var_int8.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8/var_int8.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8/var_int8.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8/var_int8.3.ast
new file mode 100644
index 0000000..3a0c710
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8/var_int8.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.sql-var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8_null/var_int8_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8_null/var_int8_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8_null/var_int8_null.1.ast
new file mode 100644
index 0000000..b01283e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8_null/var_int8_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : bigint,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8_null/var_int8_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8_null/var_int8_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8_null/var_int8_null.3.ast
new file mode 100644
index 0000000..46434d3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_int8_null/var_int8_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.sql-var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int8Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int8Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_mixed/var_mixed.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_mixed/var_mixed.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_mixed/var_mixed.3.ast
new file mode 100644
index 0000000..ce71370
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_mixed/var_mixed.3.ast
@@ -0,0 +1,22 @@
+Query:
+SELECT ELEMENT [
+FunctionCall asterix.sql-var@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=$x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS Variable [ Name=$x ]
+    ]
+  )
+]
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_pop_mixed/var_pop_mixed.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_pop_mixed/var_pop_mixed.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_pop_mixed/var_pop_mixed.3.ast
new file mode 100644
index 0000000..0727aad
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/var_pop_mixed/var_pop_mixed.3.ast
@@ -0,0 +1,22 @@
+Query:
+SELECT ELEMENT [
+FunctionCall asterix.sql-var_pop@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=$x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS Variable [ Name=$x ]
+    ]
+  )
+]
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.3.ast
index 53b7249..001001e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.3.ast
@@ -64,6 +64,24 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [var1]
+    :
+    FunctionCall asterix.var@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop1]
+    :
+    FunctionCall asterix.var_pop@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
     LiteralExpr [STRING] [count2]
     :
     FunctionCall asterix.count@1[
@@ -133,4 +151,24 @@ RecordConstructor [
       ]
     ]
   )
+  (
+    LiteralExpr [STRING] [var2]
+    :
+    FunctionCall asterix.var@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop2]
+    :
+    FunctionCall asterix.var_pop@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
 ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.ast
index d92c399..3995d9f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.ast
@@ -134,4 +134,42 @@ RecordConstructor [
       )
     ]
   )
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Test]
+          ]
+          AS Variable [ Name=$t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Test]
+          ]
+          AS Variable [ Name=$t ]
+        ]
+      )
+    ]
+  )
 ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.ast
index 5d11b6e..87a6de0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.ast
@@ -173,5 +173,56 @@ RecordConstructor [
       )
     ]
   )
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$i ]
+          Field=val
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=$t ]
+            ]
+            FROM [              FunctionCall asterix.dataset@1[
+                LiteralExpr [STRING] [test.Test]
+              ]
+              AS Variable [ Name=$t ]
+            ]
+          )
+          AS Variable [ Name=$i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$i ]
+          Field=val
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=$t ]
+            ]
+            FROM [              FunctionCall asterix.dataset@1[
+                LiteralExpr [STRING] [test.Test]
+              ]
+              AS Variable [ Name=$t ]
+            ]
+          )
+          AS Variable [ Name=$i ]
+        ]
+      )
+    ]
+  )
 ]
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.3.ast
index 59c27d9..7df9903 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.3.ast
@@ -113,6 +113,38 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [var1]
+    :
+    FunctionCall asterix.var@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop1]
+    :
+    FunctionCall asterix.var_pop@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
     LiteralExpr [STRING] [count2]
     :
     FunctionCall asterix.count@1[
@@ -224,4 +256,36 @@ RecordConstructor [
       ]
     ]
   )
+  (
+    LiteralExpr [STRING] [var2]
+    :
+    FunctionCall asterix.var@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop2]
+    :
+    FunctionCall asterix.var_pop@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
 ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.ast
index d92c399..3995d9f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.ast
@@ -134,4 +134,42 @@ RecordConstructor [
       )
     ]
   )
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Test]
+          ]
+          AS Variable [ Name=$t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Test]
+          ]
+          AS Variable [ Name=$t ]
+        ]
+      )
+    ]
+  )
 ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var/scalar_var.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var/scalar_var.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var/scalar_var.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var/scalar_var.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var/scalar_var.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var/scalar_var.3.ast
new file mode 100644
index 0000000..0fbda2c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var/scalar_var.3.ast
@@ -0,0 +1,222 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      Let Variable [ Name=$i8 ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i16 ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i32 ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i64 ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$f ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$d ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      SELECT ELEMENT [
+      Variable [ Name=$i ]
+      ]
+      FROM [        OrderedListConstructor [
+          Variable [ Name=$i8 ]
+          Variable [ Name=$i16 ]
+          Variable [ Name=$i32 ]
+          Variable [ Name=$i64 ]
+          Variable [ Name=$f ]
+          Variable [ Name=$d ]
+        ]
+        AS Variable [ Name=$i ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      Let Variable [ Name=$i8 ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i16 ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i32 ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$i64 ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$f ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      Let Variable [ Name=$d ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [3]
+            ]
+          ]
+        ]
+      SELECT ELEMENT [
+      Variable [ Name=$i ]
+      ]
+      FROM [        OrderedListConstructor [
+          Variable [ Name=$i8 ]
+          Variable [ Name=$i16 ]
+          Variable [ Name=$i32 ]
+          Variable [ Name=$i64 ]
+          Variable [ Name=$f ]
+          Variable [ Name=$d ]
+        ]
+        AS Variable [ Name=$i ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.3.ast
new file mode 100644
index 0000000..7186fb5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_empty/scalar_var_empty.3.ast
@@ -0,0 +1,27 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var@1[
+        OrderedListConstructor [
+        ]
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var_pop@1[
+        OrderedListConstructor [
+        ]
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_null/scalar_var_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_null/scalar_var_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_null/scalar_var_null.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_null/scalar_var_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_null/scalar_var_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_null/scalar_var_null.3.ast
new file mode 100644
index 0000000..2ade7e0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_var_null/scalar_var_null.3.ast
@@ -0,0 +1,234 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      Let Variable [ Name=$i8 ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i16 ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i32 ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i64 ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$f ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$d ]
+        :=
+        FunctionCall asterix.var@1[
+          OrderedListConstructor [
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      SELECT ELEMENT [
+      Variable [ Name=$i ]
+      ]
+      FROM [        OrderedListConstructor [
+          Variable [ Name=$i8 ]
+          Variable [ Name=$i16 ]
+          Variable [ Name=$i32 ]
+          Variable [ Name=$i64 ]
+          Variable [ Name=$f ]
+          Variable [ Name=$d ]
+        ]
+        AS Variable [ Name=$i ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      Let Variable [ Name=$i8 ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int8@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i16 ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int16@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i32 ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int32@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$i64 ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.int64@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$f ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.float@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      Let Variable [ Name=$d ]
+        :=
+        FunctionCall asterix.var_pop@1[
+          OrderedListConstructor [
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [1]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [2]
+            ]
+            FunctionCall test.double@1[
+              LiteralExpr [STRING] [3]
+            ]
+            LiteralExpr [NULL]
+          ]
+        ]
+      SELECT ELEMENT [
+      Variable [ Name=$i ]
+      ]
+      FROM [        OrderedListConstructor [
+          Variable [ Name=$i8 ]
+          Variable [ Name=$i16 ]
+          Variable [ Name=$i32 ]
+          Variable [ Name=$i64 ]
+          Variable [ Name=$f ]
+          Variable [ Name=$d ]
+        ]
+        AS Variable [ Name=$i ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.3.ast
new file mode 100644
index 0000000..44c30e7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double/serial_var_double.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    val:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [val]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.3.ast
new file mode 100644
index 0000000..5dc2f39
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_double_null/serial_var_double_null.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_empty/serial_var_empty.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_empty/serial_var_empty.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_empty/serial_var_empty.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_empty/serial_var_empty.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_empty/serial_var_empty.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_empty/serial_var_empty.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_empty/serial_var_empty.3.ast
new file mode 100644
index 0000000..44c30e7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_empty/serial_var_empty.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    val:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [val]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.1.ast
new file mode 100644
index 0000000..9af248f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : float
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.3.ast
new file mode 100644
index 0000000..44c30e7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float/serial_var_float.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    val:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [val]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.1.ast
new file mode 100644
index 0000000..9af248f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : float
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.3.ast
new file mode 100644
index 0000000..5dc2f39
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_float_null/serial_var_float_null.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.1.ast
new file mode 100644
index 0000000..16d25a8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : smallint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.3.ast
new file mode 100644
index 0000000..44c30e7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16/serial_var_int16.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    val:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [val]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.1.ast
new file mode 100644
index 0000000..16d25a8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : smallint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.3.ast
new file mode 100644
index 0000000..5dc2f39
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int16_null/serial_var_int16_null.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.1.ast
new file mode 100644
index 0000000..6eaf31a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : integer
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.3.ast
new file mode 100644
index 0000000..44c30e7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32/serial_var_int32.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    val:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [val]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.1.ast
new file mode 100644
index 0000000..6eaf31a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : integer
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.3.ast
new file mode 100644
index 0000000..5dc2f39
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int32_null/serial_var_int32_null.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.1.ast
new file mode 100644
index 0000000..7911712
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : bigint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.3.ast
new file mode 100644
index 0000000..44c30e7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64/serial_var_int64.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    val:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [val]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.1.ast
new file mode 100644
index 0000000..7911712
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : bigint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.3.ast
new file mode 100644
index 0000000..5dc2f39
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int64_null/serial_var_int64_null.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.1.ast
new file mode 100644
index 0000000..44c9cde
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : tinyint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.3.ast
new file mode 100644
index 0000000..44c30e7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8/serial_var_int8.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=val
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    val:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [val]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.1.ast
new file mode 100644
index 0000000..44c9cde
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : tinyint
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.3.ast
new file mode 100644
index 0000000..5dc2f39
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_int8_null/serial_var_int8_null.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.3.ast
new file mode 100644
index 0000000..a42c0cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_mixed/serial_var_mixed.3.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.ast
new file mode 100644
index 0000000..a61c9df
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : bigint,
+    gid : bigint,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.2.ast
@@ -0,0 +1 @@
+DataverseUse test

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.3.ast
new file mode 100644
index 0000000..8c99192
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.3.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+Query:
+SELECT [
+Variable [ Name=$gid ]
+gid
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=$g ]
+      Field=valplus
+    ]
+    ]
+    FROM [      Variable [ Name=$g ]
+      AS Variable [ Name=$g ]
+    ]
+  )
+]
+var_pop
+]
+FROM [  FunctionCall asterix.dataset@1[
+    LiteralExpr [STRING] [test.Test]
+  ]
+  AS Variable [ Name=$t ]
+]
+Groupby
+  Variable [ Name=$gid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=$t ]
+    Field=gid
+  ]
+  GROUP AS Variable [ Name=$g ]
+  (
+    valplus:=FunctionCall asterix.field-access-by-name@2[
+  Variable [ Name=$t ]
+  LiteralExpr [STRING] [valplus]
+]
+  )
+


[11/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
[ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

- user model changes: yes
- storage format changes: no
- interface changes: no

Details:
1. Add variance and variance population aggregation function and test cases
2. Add var() and var_pop() distinct functions
3. Add documentation for var() and var_pop()
4. Removed some empty tests cases from parser tests

Change-Id: If736c94146f1d6ee4dfa46a67737b1abd29c8e2d
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3004
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Dmitry Lychagin <dm...@couchbase.com>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/2a42da45
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/2a42da45
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/2a42da45

Branch: refs/heads/master
Commit: 2a42da456ca8f1da1122f5dc43425e46e993b64d
Parents: 776e1c2
Author: James Fang <jf...@ucr.edu>
Authored: Thu Oct 25 11:43:39 2018 -0700
Committer: Dmitry Lychagin <dm...@couchbase.com>
Committed: Thu Oct 25 14:31:44 2018 -0700

----------------------------------------------------------------------
 .../aggregate-sql/agg_null/agg_null.3.query.aql |   2 +-
 .../agg_null_rec/agg_null_rec.3.query.aql       |   2 +-
 .../agg_null_rec_1/agg_null_rec_1.3.query.aql   |   7 +-
 .../agg_number/agg_number.3.query.aql           |   4 +-
 .../agg_number_rec/agg_number_rec.3.query.aql   |   2 +-
 .../aggregate/agg_null/agg_null.3.query.aql     |   2 +-
 .../agg_null_rec/agg_null_rec.3.query.aql       |   2 +-
 .../agg_null_rec_1/agg_null_rec_1.3.query.aql   |   7 +-
 .../aggregate/agg_number/agg_number.3.query.aql |   4 +-
 .../agg_number_rec/agg_number_rec.3.query.aql   |   2 +-
 .../agg_null/agg_null.3.query.sqlpp             |   2 +-
 .../agg_null_rec/agg_null_rec.3.query.sqlpp     |   6 +
 .../agg_null_rec_1/agg_null_rec_1.3.query.sqlpp |  12 +
 .../agg_number/agg_number.3.query.sqlpp         |   2 +-
 .../agg_number_rec/agg_number_rec.3.query.sqlpp |   6 +
 .../avg_mixed/avg_mixed.3.query.sqlpp           |   2 +-
 .../scalar_var/scalar_var.1.ddl.sqlpp           |  26 ++
 .../scalar_var/scalar_var.3.query.sqlpp         |  42 ++
 .../scalar_var_empty.1.ddl.sqlpp                |  26 ++
 .../scalar_var_empty.3.query.sqlpp              |  25 ++
 .../scalar_var_null/scalar_var_null.1.ddl.sqlpp |  26 ++
 .../scalar_var_null.3.query.sqlpp               |  42 ++
 .../serial_stddev_mixed.3.query.sqlpp           |   2 +-
 .../serial_stddev_pop_mixed.3.query.sqlpp       |   2 +-
 .../serial_var_double.1.ddl.sqlpp               |  33 ++
 .../serial_var_double.2.update.sqlpp            |  31 ++
 .../serial_var_double.3.query.sqlpp             |  25 ++
 .../serial_var_double_null.1.ddl.sqlpp          |  33 ++
 .../serial_var_double_null.2.update.sqlpp       |  31 ++
 .../serial_var_double_null.3.query.sqlpp        |  25 ++
 .../serial_var_empty.1.ddl.sqlpp                |  33 ++
 .../serial_var_empty.3.query.sqlpp              |  25 ++
 .../serial_var_float.1.ddl.sqlpp                |  33 ++
 .../serial_var_float.2.update.sqlpp             |  31 ++
 .../serial_var_float.3.query.sqlpp              |  25 ++
 .../serial_var_float_null.1.ddl.sqlpp           |  33 ++
 .../serial_var_float_null.2.update.sqlpp        |  31 ++
 .../serial_var_float_null.3.query.sqlpp         |  25 ++
 .../serial_var_int16.1.ddl.sqlpp                |  33 ++
 .../serial_var_int16.2.update.sqlpp             |  31 ++
 .../serial_var_int16.3.query.sqlpp              |  25 ++
 .../serial_var_int16_null.1.ddl.sqlpp           |  33 ++
 .../serial_var_int16_null.2.update.sqlpp        |  31 ++
 .../serial_var_int16_null.3.query.sqlpp         |  25 ++
 .../serial_var_int32.1.ddl.sqlpp                |  33 ++
 .../serial_var_int32.2.update.sqlpp             |  31 ++
 .../serial_var_int32.3.query.sqlpp              |  25 ++
 .../serial_var_int32_null.1.ddl.sqlpp           |  33 ++
 .../serial_var_int32_null.2.update.sqlpp        |  31 ++
 .../serial_var_int32_null.3.query.sqlpp         |  25 ++
 .../serial_var_int64.1.ddl.sqlpp                |  33 ++
 .../serial_var_int64.2.update.sqlpp             |  31 ++
 .../serial_var_int64.3.query.sqlpp              |  25 ++
 .../serial_var_int64_null.1.ddl.sqlpp           |  33 ++
 .../serial_var_int64_null.2.update.sqlpp        |  31 ++
 .../serial_var_int64_null.3.query.sqlpp         |  25 ++
 .../serial_var_int8/serial_var_int8.1.ddl.sqlpp |  33 ++
 .../serial_var_int8.2.update.sqlpp              |  31 ++
 .../serial_var_int8.3.query.sqlpp               |  25 ++
 .../serial_var_int8_null.1.ddl.sqlpp            |  33 ++
 .../serial_var_int8_null.2.update.sqlpp         |  31 ++
 .../serial_var_int8_null.3.query.sqlpp          |  25 ++
 .../serial_var_mixed.1.ddl.sqlpp                |  33 ++
 .../serial_var_mixed.2.update.sqlpp             |  29 ++
 .../serial_var_mixed.3.query.sqlpp              |  30 ++
 .../serial_var_pop_mixed.1.ddl.sqlpp            |  33 ++
 .../serial_var_pop_mixed.2.update.sqlpp         |  29 ++
 .../serial_var_pop_mixed.3.query.sqlpp          |  30 ++
 .../stddev_mixed/stddev_mixed.3.query.sqlpp     |   2 +-
 .../stddev_pop_mixed.3.query.sqlpp              |   2 +-
 .../sum_mixed/sum_mixed.3.query.sqlpp           |   2 +-
 .../var_distinct/var_distinct.1.query.sqlpp     |  28 ++
 .../var_double/var_double.1.ddl.sqlpp           |  25 ++
 .../var_double/var_double.3.query.sqlpp         |  26 ++
 .../var_double_null/var_double_null.1.ddl.sqlpp |  38 ++
 .../var_double_null.3.query.sqlpp               |  29 ++
 .../var_empty_01/var_empty_01.1.ddl.sqlpp       |  27 ++
 .../var_empty_01/var_empty_01.3.query.sqlpp     |  36 ++
 .../var_empty_02/var_empty_02.1.ddl.sqlpp       |  38 ++
 .../var_empty_02/var_empty_02.3.query.sqlpp     |  34 ++
 .../var_float/var_float.1.ddl.sqlpp             |  22 +
 .../var_float/var_float.3.query.sqlpp           |  29 ++
 .../var_float_null/var_float_nu.1.ddl.sqlpp     |  38 ++
 .../var_float_null/var_float_nu.3.query.sqlpp   |  29 ++
 .../var_int16/var_int16.1.ddl.sqlpp             |  22 +
 .../var_int16/var_int16.3.query.sqlpp           |  29 ++
 .../var_int16_null/var_int16_null.1.ddl.sqlpp   |  38 ++
 .../var_int16_null/var_int16_null.3.query.sqlpp |  29 ++
 .../var_int32/var_int32.1.ddl.sqlpp             |  22 +
 .../var_int32/var_int32.3.query.sqlpp           |  29 ++
 .../var_int32_null/var_int32_null.1.ddl.sqlpp   |  38 ++
 .../var_int32_null/var_int32_null.3.query.sqlpp |  29 ++
 .../var_int64/var_int64.1.ddl.sqlpp             |  22 +
 .../var_int64/var_int64.3.query.sqlpp           |  29 ++
 .../var_int64_null/var_int64_null.1.ddl.sqlpp   |  38 ++
 .../var_int64_null/var_int64_null.3.query.sqlpp |  29 ++
 .../aggregate-sql/var_int8/var_int8.1.ddl.sqlpp |  22 +
 .../var_int8/var_int8.3.query.sqlpp             |  29 ++
 .../var_int8_null/var_int8_null.1.ddl.sqlpp     |  38 ++
 .../var_int8_null/var_int8_null.3.query.sqlpp   |  29 ++
 .../var_mixed/var_mixed.3.query.sqlpp           |  28 ++
 .../var_pop_mixed/var_pop_mixed.3.query.sqlpp   |  28 ++
 .../aggregate/agg_null/agg_null.3.query.sqlpp   |   2 +-
 .../agg_null_rec/agg_null_rec.3.query.sqlpp     |   6 +
 .../agg_null_rec_1/agg_null_rec_1.3.query.sqlpp |  12 +
 .../agg_number/agg_number.3.query.sqlpp         |   2 +-
 .../agg_number_rec/agg_number_rec.3.query.sqlpp |   6 +
 .../aggregate/avg_mixed/avg_mixed.3.query.sqlpp |   2 +-
 .../aggregate/scalar_var/scalar_var.1.ddl.sqlpp |  26 ++
 .../scalar_var/scalar_var.3.query.sqlpp         |  42 ++
 .../scalar_var_empty.1.ddl.sqlpp                |  26 ++
 .../scalar_var_empty.3.query.sqlpp              |  25 ++
 .../scalar_var_null/scalar_var_null.1.ddl.sqlpp |  26 ++
 .../scalar_var_null.3.query.sqlpp               |  42 ++
 .../serial_stddev_mixed.3.query.sqlpp           |   2 +-
 .../serial_stddev_pop_mixed.3.query.sqlpp       |   2 +-
 .../serial_var_double.1.ddl.sqlpp               |  33 ++
 .../serial_var_double.2.update.sqlpp            |  31 ++
 .../serial_var_double.3.query.sqlpp             |  26 ++
 .../serial_var_double_null.1.ddl.sqlpp          |  33 ++
 .../serial_var_double_null.2.update.sqlpp       |  31 ++
 .../serial_var_double_null.3.query.sqlpp        |  26 ++
 .../serial_var_empty.1.ddl.sqlpp                |  33 ++
 .../serial_var_empty.3.query.sqlpp              |  26 ++
 .../serial_var_float.1.ddl.sqlpp                |  33 ++
 .../serial_var_float.2.update.sqlpp             |  31 ++
 .../serial_var_float.3.query.sqlpp              |  26 ++
 .../serial_var_float_null.1.ddl.sqlpp           |  33 ++
 .../serial_var_float_null.2.update.sqlpp        |  31 ++
 .../serial_var_float_null.3.query.sqlpp         |  26 ++
 .../serial_var_int16.1.ddl.sqlpp                |  33 ++
 .../serial_var_int16.2.update.sqlpp             |  31 ++
 .../serial_var_int16.3.query.sqlpp              |  26 ++
 .../serial_var_int16_null.1.ddl.sqlpp           |  33 ++
 .../serial_var_int16_null.2.update.sqlpp        |  31 ++
 .../serial_var_int16_null.3.query.sqlpp         |  26 ++
 .../serial_var_int32.1.ddl.sqlpp                |  33 ++
 .../serial_var_int32.2.update.sqlpp             |  31 ++
 .../serial_var_int32.3.query.sqlpp              |  26 ++
 .../serial_var_int32_null.1.ddl.sqlpp           |  33 ++
 .../serial_var_int32_null.2.update.sqlpp        |  31 ++
 .../serial_var_int32_null.3.query.sqlpp         |  26 ++
 .../serial_var_int64.1.ddl.sqlpp                |  33 ++
 .../serial_var_int64.2.update.sqlpp             |  31 ++
 .../serial_var_int64.3.query.sqlpp              |  26 ++
 .../serial_var_int64_null.1.ddl.sqlpp           |  33 ++
 .../serial_var_int64_null.2.update.sqlpp        |  31 ++
 .../serial_var_int64_null.3.query.sqlpp         |  26 ++
 .../serial_var_int8/serial_var_int8.1.ddl.sqlpp |  33 ++
 .../serial_var_int8.2.update.sqlpp              |  31 ++
 .../serial_var_int8.3.query.sqlpp               |  26 ++
 .../serial_var_int8_null.1.ddl.sqlpp            |  33 ++
 .../serial_var_int8_null.2.update.sqlpp         |  31 ++
 .../serial_var_int8_null.3.query.sqlpp          |  26 ++
 .../serial_var_mixed.1.ddl.sqlpp                |  33 ++
 .../serial_var_mixed.2.update.sqlpp             |  29 ++
 .../serial_var_mixed.3.query.sqlpp              |  30 ++
 .../serial_var_pop_mixed.1.ddl.sqlpp            |  33 ++
 .../serial_var_pop_mixed.2.update.sqlpp         |  29 ++
 .../serial_var_pop_mixed.3.query.sqlpp          |  30 ++
 .../stddev_mixed/stddev_mixed.3.query.sqlpp     |   2 +-
 .../stddev_pop_mixed.3.query.sqlpp              |   2 +-
 .../aggregate/sum_mixed/sum_mixed.3.query.sqlpp |   2 +-
 .../var_distinct/var_distinct.1.query.sqlpp     |  28 ++
 .../aggregate/var_double/var_double.1.ddl.sqlpp |  25 ++
 .../var_double/var_double.3.query.sqlpp         |  26 ++
 .../var_double_null/var_double_null.1.ddl.sqlpp |  38 ++
 .../var_double_null.3.query.sqlpp               |  28 ++
 .../var_empty_01/var_empty_01.1.ddl.sqlpp       |  27 ++
 .../var_empty_01/var_empty_01.3.query.sqlpp     |  35 ++
 .../var_empty_02/var_empty_02.1.ddl.sqlpp       |  38 ++
 .../var_empty_02/var_empty_02.3.query.sqlpp     |  33 ++
 .../aggregate/var_float/var_float.1.ddl.sqlpp   |  22 +
 .../aggregate/var_float/var_float.3.query.sqlpp |  29 ++
 .../var_float_null/var_float_null.1.ddl.sqlpp   |  38 ++
 .../var_float_null/var_float_null.3.query.sqlpp |  29 ++
 .../aggregate/var_int16/var_int16.1.ddl.sqlpp   |  22 +
 .../aggregate/var_int16/var_int16.3.query.sqlpp |  29 ++
 .../var_int16_null/var_int16_null.1.ddl.sqlpp   |  38 ++
 .../var_int16_null/var_int16_null.3.query.sqlpp |  29 ++
 .../aggregate/var_int32/var_int32.1.ddl.sqlpp   |  22 +
 .../aggregate/var_int32/var_int32.3.query.sqlpp |  29 ++
 .../var_int32_null/var_int32_null.1.ddl.sqlpp   |  38 ++
 .../var_int32_null/var_int32_null.3.query.sqlpp |  29 ++
 .../aggregate/var_int64/var_int64.1.ddl.sqlpp   |  22 +
 .../aggregate/var_int64/var_int64.3.query.sqlpp |  29 ++
 .../var_int64_null/var_int64_null.1.ddl.sqlpp   |  38 ++
 .../var_int64_null/var_int64_null.3.query.sqlpp |  29 ++
 .../aggregate/var_int8/var_int8.1.ddl.sqlpp     |  22 +
 .../aggregate/var_int8/var_int8.3.query.sqlpp   |  29 ++
 .../var_int8_null/var_int8_null.1.ddl.sqlpp     |  38 ++
 .../var_int8_null/var_int8_null.3.query.sqlpp   |  29 ++
 .../aggregate/var_mixed/var_mixed.3.query.sqlpp |  28 ++
 .../var_pop_mixed/var_pop_mixed.3.query.sqlpp   |  28 ++
 .../aggregate-sql/agg_null/agg_null.1.adm       |   2 +-
 .../agg_null_rec/agg_null_rec.1.adm             |   2 +-
 .../agg_null_rec_1/agg_null_rec.1.adm           |   2 +-
 .../aggregate-sql/agg_number/agg_number.1.adm   |   2 +-
 .../agg_number_rec/agg_number_rec.1.adm         |   2 +-
 .../aggregate-sql/scalar_var/scalar_var.1.adm   |   1 +
 .../scalar_var_empty/scalar_var_empty.1.adm     |   1 +
 .../scalar_var_null/scalar_var_null.1.adm       |   1 +
 .../serial_var_double/serial_var_double.1.adm   |   1 +
 .../serial_var_double_null.1.adm                |   1 +
 .../serial_var_empty/serial_var_empty.1.adm     |   0
 .../serial_var_float/serial_var_float.1.adm     |   1 +
 .../serial_var_float_null.1.adm                 |   1 +
 .../serial_var_int16/serial_var_int16.1.adm     |   1 +
 .../serial_var_int16_null.1.adm                 |   1 +
 .../serial_var_int32/serial_var_int32.1.adm     |   1 +
 .../serial_var_int32_null.1.adm                 |   1 +
 .../serial_var_int64/serial_var_int64.1.adm     |   1 +
 .../serial_var_int64_null.1.adm                 |   1 +
 .../serial_var_int8/serial_var_int8.1.adm       |   1 +
 .../serial_var_int8_null.1.adm                  |   1 +
 .../serial_var_mixed/serial_var_mixed.1.adm     |   1 +
 .../serial_var_pop_mixed.1.adm                  |   1 +
 .../var_distinct/var_distinct.1.adm             |   1 +
 .../aggregate-sql/var_double/var_double.1.adm   |   1 +
 .../var_double_null/var_double_null.1.adm       |   1 +
 .../var_empty_01/var_empty_01.1.adm             |   1 +
 .../var_empty_02/var_empty_02.1.adm             |   1 +
 .../aggregate-sql/var_float/var_float.1.adm     |   1 +
 .../var_float_null/var_float_null.1.adm         |   1 +
 .../aggregate-sql/var_int16/var_int16.1.adm     |   1 +
 .../var_int16_null/var_int16_null.1.adm         |   1 +
 .../aggregate-sql/var_int32/var_int32.1.adm     |   1 +
 .../var_int32_null/var_int32_null.1.adm         |   1 +
 .../aggregate-sql/var_int64/var_int64.1.adm     |   1 +
 .../var_int64_null/var_int64_null.1.adm         |   1 +
 .../aggregate-sql/var_int8/var_int8.1.adm       |   1 +
 .../var_int8_null/var_int8_null.1.adm           |   1 +
 .../aggregate-sql/var_mixed/var_mixed.1.adm     |   1 +
 .../var_pop_mixed/var_pop_mixed.1.adm           |   1 +
 .../results/aggregate/agg_null/agg_null.1.adm   |   2 +-
 .../aggregate/agg_null_rec/agg_null_rec.1.adm   |   2 +-
 .../aggregate/agg_null_rec_1/agg_null_rec.1.adm |   2 +-
 .../aggregate/agg_number/agg_number.1.adm       |   2 +-
 .../agg_number_rec/agg_number_rec.1.adm         |   2 +-
 .../aggregate/scalar_var/scalar_var.1.adm       |   1 +
 .../scalar_var_empty/scalar_var_empty.1.adm     |   1 +
 .../scalar_var_null/scalar_var_null.1.adm       |   1 +
 .../serial_var_double/serial_var_double.1.adm   |   1 +
 .../serial_var_double_null.1.adm                |   1 +
 .../serial_var_empty/serial_var_empty.1.adm     |   0
 .../serial_var_float/serial_var_float.1.adm     |   1 +
 .../serial_var_float_null.1.adm                 |   1 +
 .../serial_var_int16/serial_var_int16.1.adm     |   1 +
 .../serial_var_int16_null.1.adm                 |   1 +
 .../serial_var_int32/serial_var_int32.1.adm     |   1 +
 .../serial_var_int32_null.1.adm                 |   1 +
 .../serial_var_int64/serial_var_int64.1.adm     |   1 +
 .../serial_var_int64_null.1.adm                 |   1 +
 .../serial_var_int8/serial_var_int8.1.adm       |   1 +
 .../serial_var_int8_null.1.adm                  |   1 +
 .../serial_var_mixed/serial_var_mixed.1.adm     |   1 +
 .../serial_var_pop_mixed.1.adm                  |   1 +
 .../aggregate/var_distinct/var_distinct.1.adm   |   1 +
 .../aggregate/var_double/var_double.1.adm       |   1 +
 .../var_double_null/var_double_null.1.adm       |   1 +
 .../aggregate/var_empty_01/var_empty_01.1.adm   |   1 +
 .../aggregate/var_empty_02/var_empty_02.1.adm   |   1 +
 .../results/aggregate/var_float/var_float.1.adm |   1 +
 .../var_float_null/var_float_null.1.adm         |   1 +
 .../results/aggregate/var_int16/var_int16.1.adm |   1 +
 .../var_int16_null/var_int16_null.1.adm         |   1 +
 .../results/aggregate/var_int32/var_int32.1.adm |   1 +
 .../var_int32_null/var_int32_null.1.adm         |   1 +
 .../results/aggregate/var_int64/var_int64.1.adm |   1 +
 .../var_int64_null/var_int64_null.1.adm         |   1 +
 .../results/aggregate/var_int8/var_int8.1.adm   |   1 +
 .../aggregate/var_int8_null/var_int8_null.1.adm |   1 +
 .../results/aggregate/var_mixed/var_mixed.1.adm |   1 +
 .../aggregate/var_pop_mixed/var_pop_mixed.1.adm |   1 +
 .../aggregate-sql/agg_null/agg_null.3.ast       |  38 ++
 .../agg_null_rec/agg_null_rec.3.ast             |  38 ++
 .../agg_null_rec_1/agg_null_rec_1.3.ast         |  52 +++
 .../aggregate-sql/agg_number/agg_number.3.ast   |  64 +++
 .../agg_number_rec/agg_number_rec.3.ast         |  38 ++
 .../aggregate-sql/scalar_var/scalar_var.1.ast   |   0
 .../aggregate-sql/scalar_var/scalar_var.3.ast   | 222 ++++++++++
 .../scalar_var_empty/scalar_var_empty.1.ast     |   0
 .../scalar_var_empty/scalar_var_empty.3.ast     |  27 ++
 .../scalar_var_null/scalar_var_null.1.ast       |   0
 .../scalar_var_null/scalar_var_null.3.ast       | 234 +++++++++++
 .../serial_var_double/serial_var_double.1.ast   |   9 +
 .../serial_var_double/serial_var_double.2.ast   |   1 +
 .../serial_var_double/serial_var_double.3.ast   |  57 +++
 .../serial_var_double_null.1.ast                |   9 +
 .../serial_var_double_null.2.ast                |   1 +
 .../serial_var_double_null.3.ast                |  57 +++
 .../serial_var_empty/serial_var_empty.1.ast     |   9 +
 .../serial_var_empty/serial_var_empty.3.ast     |  57 +++
 .../serial_var_float/serial_var_float.1.ast     |   9 +
 .../serial_var_float/serial_var_float.2.ast     |   1 +
 .../serial_var_float/serial_var_float.3.ast     |  57 +++
 .../serial_var_float_null.1.ast                 |   9 +
 .../serial_var_float_null.2.ast                 |   1 +
 .../serial_var_float_null.3.ast                 |  57 +++
 .../serial_var_int16/serial_var_int16.1.ast     |   9 +
 .../serial_var_int16/serial_var_int16.2.ast     |   1 +
 .../serial_var_int16/serial_var_int16.3.ast     |  57 +++
 .../serial_var_int16_null.1.ast                 |   9 +
 .../serial_var_int16_null.2.ast                 |   1 +
 .../serial_var_int16_null.3.ast                 |  57 +++
 .../serial_var_int32/serial_var_int32.1.ast     |   9 +
 .../serial_var_int32/serial_var_int32.2.ast     |   1 +
 .../serial_var_int32/serial_var_int32.3.ast     |  57 +++
 .../serial_var_int32_null.1.ast                 |   9 +
 .../serial_var_int32_null.2.ast                 |   1 +
 .../serial_var_int32_null.3.ast                 |  57 +++
 .../serial_var_int64/serial_var_int64.1.ast     |   9 +
 .../serial_var_int64/serial_var_int64.2.ast     |   1 +
 .../serial_var_int64/serial_var_int64.3.ast     |  57 +++
 .../serial_var_int64_null.1.ast                 |   9 +
 .../serial_var_int64_null.2.ast                 |   1 +
 .../serial_var_int64_null.3.ast                 |  57 +++
 .../serial_var_int8/serial_var_int8.1.ast       |   9 +
 .../serial_var_int8/serial_var_int8.2.ast       |   1 +
 .../serial_var_int8/serial_var_int8.3.ast       |  57 +++
 .../serial_var_int8_null.1.ast                  |   9 +
 .../serial_var_int8_null.2.ast                  |   1 +
 .../serial_var_int8_null.3.ast                  |  57 +++
 .../serial_var_int64_null.1.ast                 |   9 +
 .../serial_var_int64_null.2.ast                 |   1 +
 .../serial_var_int64_null.3.ast                 |  40 ++
 .../serial_var_pop_int64_null.1.ast             |   9 +
 .../serial_var_pop_int64_null.2.ast             |   1 +
 .../serial_var_pop_int64_null.3.ast             |  40 ++
 .../aggregate-sql/var_double/var_double.1.ast   |   1 +
 .../aggregate-sql/var_double/var_double.3.ast   |  51 +++
 .../var_double_null/var_double_null.1.ast       |  13 +
 .../var_double_null/var_double_null.3.ast       |  42 ++
 .../var_empty_01/var_empty_01.1.ast             |   0
 .../var_empty_01/var_empty_01.3.ast             |  60 +++
 .../var_empty_02/var_empty_02.1.ast             |   8 +
 .../var_empty_02/var_empty_02.3.ast             |  50 +++
 .../aggregate-sql/var_float/var_float.1.ast     |   0
 .../aggregate-sql/var_float/var_float.3.ast     |  60 +++
 .../var_float_null/var_float_nu.1.ast           |  13 +
 .../var_float_null/var_float_nu.3.ast           |  42 ++
 .../aggregate-sql/var_int16/var_int16.1.ast     |   0
 .../aggregate-sql/var_int16/var_int16.3.ast     |  60 +++
 .../var_int16_null/var_int16_null.1.ast         |  13 +
 .../var_int16_null/var_int16_null.3.ast         |  42 ++
 .../aggregate-sql/var_int32/var_int32.1.ast     |   0
 .../aggregate-sql/var_int32/var_int32.3.ast     |  60 +++
 .../var_int32_null/var_int32_null.1.ast         |  13 +
 .../var_int32_null/var_int32_null.3.ast         |  42 ++
 .../aggregate-sql/var_int64/var_int64.1.ast     |   0
 .../aggregate-sql/var_int64/var_int64.3.ast     |  60 +++
 .../var_int64_null/var_int64_null.1.ast         |  13 +
 .../var_int64_null/var_int64_null.3.ast         |  42 ++
 .../aggregate-sql/var_int8/var_int8.1.ast       |   0
 .../aggregate-sql/var_int8/var_int8.3.ast       |  60 +++
 .../var_int8_null/var_int8_null.1.ast           |  13 +
 .../var_int8_null/var_int8_null.3.ast           |  42 ++
 .../aggregate-sql/var_mixed/var_mixed.3.ast     |  22 +
 .../var_pop_mixed/var_pop_mixed.3.ast           |  22 +
 .../aggregate/agg_null/agg_null.3.ast           |  38 ++
 .../aggregate/agg_null_rec/agg_null_rec.3.ast   |  38 ++
 .../agg_null_rec_1/agg_null_rec_1.3.ast         |  53 ++-
 .../aggregate/agg_number/agg_number.3.ast       |  64 +++
 .../agg_number_rec/agg_number_rec.3.ast         |  38 ++
 .../aggregate/scalar_var/scalar_var.1.ast       |   0
 .../aggregate/scalar_var/scalar_var.3.ast       | 222 ++++++++++
 .../scalar_var_empty/scalar_var_empty.1.ast     |   0
 .../scalar_var_empty/scalar_var_empty.3.ast     |  27 ++
 .../scalar_var_null/scalar_var_null.1.ast       |   0
 .../scalar_var_null/scalar_var_null.3.ast       | 234 +++++++++++
 .../serial_var_double/serial_var_double.1.ast   |   9 +
 .../serial_var_double/serial_var_double.2.ast   |   1 +
 .../serial_var_double/serial_var_double.3.ast   |  54 +++
 .../serial_var_double_null.1.ast                |   9 +
 .../serial_var_double_null.2.ast                |   1 +
 .../serial_var_double_null.3.ast                |  54 +++
 .../serial_var_empty/serial_var_empty.1.ast     |   9 +
 .../serial_var_empty/serial_var_empty.3.ast     |  54 +++
 .../serial_var_float/serial_var_float.1.ast     |   9 +
 .../serial_var_float/serial_var_float.2.ast     |   1 +
 .../serial_var_float/serial_var_float.3.ast     |  54 +++
 .../serial_var_float_null.1.ast                 |   9 +
 .../serial_var_float_null.2.ast                 |   1 +
 .../serial_var_float_null.3.ast                 |  54 +++
 .../serial_var_int16/serial_var_int16.1.ast     |   9 +
 .../serial_var_int16/serial_var_int16.2.ast     |   1 +
 .../serial_var_int16/serial_var_int16.3.ast     |  54 +++
 .../serial_var_int16_null.1.ast                 |   9 +
 .../serial_var_int16_null.2.ast                 |   1 +
 .../serial_var_int16_null.3.ast                 |  54 +++
 .../serial_var_int32/serial_var_int32.1.ast     |   9 +
 .../serial_var_int32/serial_var_int32.2.ast     |   1 +
 .../serial_var_int32/serial_var_int32.3.ast     |  54 +++
 .../serial_var_int32_null.1.ast                 |   9 +
 .../serial_var_int32_null.2.ast                 |   1 +
 .../serial_var_int32_null.3.ast                 |  54 +++
 .../serial_var_int64/serial_var_int64.1.ast     |   9 +
 .../serial_var_int64/serial_var_int64.2.ast     |   1 +
 .../serial_var_int64/serial_var_int64.3.ast     |  54 +++
 .../serial_var_int64_null.1.ast                 |   9 +
 .../serial_var_int64_null.2.ast                 |   1 +
 .../serial_var_int64_null.3.ast                 |  54 +++
 .../serial_var_int8/serial_var_int8.1.ast       |   9 +
 .../serial_var_int8/serial_var_int8.2.ast       |   1 +
 .../serial_var_int8/serial_var_int8.3.ast       |  54 +++
 .../serial_var_int8_null.1.ast                  |   9 +
 .../serial_var_int8_null.2.ast                  |   1 +
 .../serial_var_int8_null.3.ast                  |  54 +++
 .../serial_var_mixed/serial_var_mixed.1.ast     |   9 +
 .../serial_var_mixed/serial_var_mixed.2.ast     |   1 +
 .../serial_var_mixed/serial_var_mixed.3.ast     |  40 ++
 .../serial_var_pop_mixed.1.ast                  |   9 +
 .../serial_var_pop_mixed.2.ast                  |   1 +
 .../serial_var_pop_mixed.3.ast                  |  40 ++
 .../aggregate/var_double/var_double.1.ast       |   2 +
 .../aggregate/var_double/var_double.3.ast       |  51 +++
 .../var_double_null/var_double_null.1.ast       |  13 +
 .../var_double_null/var_double_null.3.ast       |  42 ++
 .../aggregate/var_empty_01/var_empty_01.1.ast   |   0
 .../aggregate/var_empty_01/var_empty_01.3.ast   |  60 +++
 .../aggregate/var_empty_02/var_empty_02.1.ast   |   8 +
 .../aggregate/var_empty_02/var_empty_02.3.ast   |  50 +++
 .../aggregate/var_float/var_float.1.ast         |   0
 .../aggregate/var_float/var_float.3.ast         |  60 +++
 .../aggregate/var_float_null/var_float_nu.1.ast |  13 +
 .../aggregate/var_float_null/var_float_nu.3.ast |  42 ++
 .../aggregate/var_int16/var_int16.1.ast         |   0
 .../aggregate/var_int16/var_int16.3.ast         |  60 +++
 .../var_int16_null/var_int16_null.1.ast         |  13 +
 .../var_int16_null/var_int16_null.3.ast         |  42 ++
 .../aggregate/var_int32/var_int32.1.ast         |   0
 .../aggregate/var_int32/var_int32.3.ast         |  48 +++
 .../var_int32_null/var_int32_null.1.ast         |  13 +
 .../var_int32_null/var_int32_null.3.ast         |  42 ++
 .../aggregate/var_int64/var_int64.1.ast         |   0
 .../aggregate/var_int64/var_int64.3.ast         |  60 +++
 .../var_int64_null/var_int64_null.1.ast         |  13 +
 .../var_int64_null/var_int64_null.3.ast         |  42 ++
 .../aggregate/var_int8/var_int8.1.ast           |   0
 .../aggregate/var_int8/var_int8.3.ast           |  60 +++
 .../aggregate/var_int8_null/var_int8_null.1.ast |  13 +
 .../aggregate/var_int8_null/var_int8_null.3.ast |  42 ++
 .../aggregate/var_mixed/var_mixed.3.ast         |  22 +
 .../aggregate/var_pop_mixed/var_pop_mixed.3.ast |  22 +
 .../resources/runtimets/testsuite_sqlpp.xml     | 358 ++++++++++++++++
 .../runtimets/testsuite_sqlpp_parser.xml        | 412 +++++++++++++------
 .../main/markdown/builtins/9_aggregate_sql.md   | 121 +++++-
 .../asterix/om/functions/BuiltinFunctions.java  | 284 +++++++++++++
 .../scalar/ScalarSqlVarAggregateDescriptor.java |  48 +++
 .../ScalarSqlVarPopAggregateDescriptor.java     |  49 +++
 .../scalar/ScalarVarAggregateDescriptor.java    |  48 +++
 .../scalar/ScalarVarPopAggregateDescriptor.java |  48 +++
 ...ngleVariableStatisticsAggregateFunction.java |  17 +
 ...alizableGlobalSqlVarAggregateDescriptor.java |  63 +++
 ...rializableGlobalSqlVarAggregateFunction.java |  77 ++++
 ...zableGlobalSqlVarPopAggregateDescriptor.java |  63 +++
 ...erializableGlobalVarAggregateDescriptor.java |  62 +++
 .../SerializableGlobalVarAggregateFunction.java |  86 ++++
 ...alizableGlobalVarPopAggregateDescriptor.java |  63 +++
 ...leIntermediateSqlVarAggregateDescriptor.java |  63 +++
 ...ableIntermediateSqlVarAggregateFunction.java |  70 ++++
 ...ntermediateSqlVarPopAggregateDescriptor.java |  63 +++
 ...zableIntermediateVarAggregateDescriptor.java |  63 +++
 ...lizableIntermediateVarAggregateFunction.java |  80 ++++
 ...leIntermediateVarPopAggregateDescriptor.java |  63 +++
 ...ializableLocalSqlVarAggregateDescriptor.java |  62 +++
 ...erializableLocalSqlVarAggregateFunction.java |  70 ++++
 ...izableLocalSqlVarPopAggregateDescriptor.java |  63 +++
 ...SerializableLocalVarAggregateDescriptor.java |  62 +++
 .../SerializableLocalVarAggregateFunction.java  |  79 ++++
 ...ializableLocalVarPopAggregateDescriptor.java |  62 +++
 .../SerializableSqlVarAggregateDescriptor.java  |  60 +++
 .../SerializableSqlVarAggregateFunction.java    |  75 ++++
 ...erializableSqlVarPopAggregateDescriptor.java |  60 +++
 .../std/SerializableVarAggregateDescriptor.java |  62 +++
 .../std/SerializableVarAggregateFunction.java   |  84 ++++
 .../SerializableVarPopAggregateDescriptor.java  |  62 +++
 ...actSingleVarStatisticsAggregateFunction.java |  15 +
 .../std/GlobalSqlVarAggregateDescriptor.java    |  62 +++
 .../std/GlobalSqlVarAggregateFunction.java      |  75 ++++
 .../std/GlobalSqlVarPopAggregateDescriptor.java |  62 +++
 .../std/GlobalVarAggregateDescriptor.java       |  62 +++
 .../std/GlobalVarAggregateFunction.java         |  82 ++++
 .../std/GlobalVarPopAggregateDescriptor.java    |  62 +++
 .../IntermediateSqlVarAggregateDescriptor.java  |  61 +++
 .../IntermediateSqlVarAggregateFunction.java    |  68 +++
 ...ntermediateSqlVarPopAggregateDescriptor.java |  61 +++
 .../std/IntermediateVarAggregateDescriptor.java |  62 +++
 .../std/IntermediateVarAggregateFunction.java   |  76 ++++
 .../IntermediateVarPopAggregateDescriptor.java  |  62 +++
 .../std/LocalSqlVarAggregateDescriptor.java     |  60 +++
 .../std/LocalSqlVarAggregateFunction.java       |  68 +++
 .../std/LocalSqlVarPopAggregateDescriptor.java  |  60 +++
 .../std/LocalVarAggregateDescriptor.java        |  60 +++
 .../std/LocalVarAggregateFunction.java          |  76 ++++
 .../std/LocalVarPopAggregateDescriptor.java     |  60 +++
 .../std/SqlVarAggregateDescriptor.java          |  61 +++
 .../aggregates/std/SqlVarAggregateFunction.java |  74 ++++
 .../std/SqlVarPopAggregateDescriptor.java       |  61 +++
 .../aggregates/std/VarAggregateDescriptor.java  |  61 +++
 .../aggregates/std/VarAggregateFunction.java    |  82 ++++
 .../std/VarPopAggregateDescriptor.java          |  61 +++
 .../runtime/functions/FunctionCollection.java   |  72 ++++
 503 files changed, 14547 insertions(+), 186 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null/agg_null.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null/agg_null.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null/agg_null.3.query.aql
index 51d6069..d48b222 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null/agg_null.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null/agg_null.3.query.aql
@@ -24,4 +24,4 @@
 
 let $l1 := [null]
 let $l2 := {{null, null}}
-return { "sql-count1": sql-count($l1), "average1": sql-avg($l1), "sql-sum1": sql-sum($l1), "sql-min1": sql-min($l1), "sql-max1": sql-max($l1), "sql-stddev1": sql-stddev($l1), "sql-stddev_pop1": sql-stddev_pop($l1), "sql-count2": sql-count($l2), "average2": sql-avg($l2), "sql-sum2": sql-sum($l2), "sql-min2": sql-min($l2), "sql-max2": sql-max($l2),  "sql-stddev2": sql-stddev($l2), "sql-stddev_pop2": sql-stddev_pop($l2) }
+return { "sql-count1": sql-count($l1), "average1": sql-avg($l1), "sql-sum1": sql-sum($l1), "sql-min1": sql-min($l1), "sql-max1": sql-max($l1), "sql-stddev1": sql-stddev($l1), "sql-stddev_pop1": sql-stddev_pop($l1), "sql-var1": sql-var($l1), "sql-var_pop1": sql-var_pop($l1), "sql-count2": sql-count($l2), "average2": sql-avg($l2), "sql-sum2": sql-sum($l2), "sql-min2": sql-min($l2), "sql-max2": sql-max($l2),  "sql-stddev2": sql-stddev($l2), "sql-stddev_pop2": sql-stddev_pop($l2), "sql-var2": sql-var($l2), "sql-var_pop2": sql-var_pop($l2) }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec/agg_null_rec.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec/agg_null_rec.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec/agg_null_rec.3.query.aql
index 6fcde5c..e3f9193 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec/agg_null_rec.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec/agg_null_rec.3.query.aql
@@ -25,4 +25,4 @@
 use dataverse test;
 
 let $l := for $t in dataset Test return $t.valplus
-return { "sql-count": sql-count($l), "average": sql-avg($l), "sql-stddev": sql-stddev($l), "sql-stddev_pop": sql-stddev_pop($l), "sql-sum": sql-sum($l), "sql-min": sql-min($l), "sql-max": sql-max($l) }
+return { "sql-count": sql-count($l), "average": sql-avg($l), "sql-sum": sql-sum($l), "sql-min": sql-min($l), "sql-max": sql-max($l), "sql-stddev": sql-stddev($l), "sql-stddev_pop": sql-stddev_pop($l), "sql-var": sql-var($l), "sql-var_pop": sql-var_pop($l) }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.aql
index fbdaa58..844edd2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.aql
@@ -26,6 +26,7 @@ use dataverse test;
 
 let $l := for $t in dataset Test return $t
 return { "sql-count": sql-count($l), "average": sql-avg(for $i in $l return $i.val), "sql-sum":
-sql-sum(for $i in $l return $i.val), "sql-stddev": sql-stddev(for $i in $l return $i.valplus),
-"sql-stddev_pop": sql-stddev_pop(for $i in $l return $i.valplus), "sql-min": sql-min(for $i in $l return $i.valplus),
-"sql-max": sql-max(for $i in $l return $i.valplus) }
+sql-sum(for $i in $l return $i.val),  "sql-min": sql-min(for $i in $l return $i.valplus),
+"sql-max": sql-max(for $i in $l return $i.valplus), "sql-stddev": sql-stddev(for $i in $l return $i.valplus),
+"sql-stddev_pop": sql-stddev_pop(for $i in $l return $i.valplus), "sql-var": sql-var(for $i in $l return $i.valplus),
+"sql-var_pop": sql-var_pop(for $i in $l return $i.valplus) }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number/agg_number.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number/agg_number.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number/agg_number.3.query.aql
index eeab6ad..4ebb67f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number/agg_number.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number/agg_number.3.query.aql
@@ -31,5 +31,7 @@ let $a4 := sql-min($l2)
 let $a5 := sql-max($l2)
 let $a6 := sql-stddev($l2)
 let $a7 := sql-stddev_pop($l2)
-return { "sql-count1": sql-count($l1), "average1": sql-avg($l1), "sql-stddev1": sql-stddev($l1), "sql-stddev_pop1": sql-stddev_pop($l1), "sql-sum1": sql-sum($l1), "sql-min1": sql-min($l1), "sql-max1": sql-max($l1), "sql-count2": $a1, "average2": $a2, "sql-stddev2": $a6, "sql-stddev_pop2": $a7, "sql-sum2": $a3, "sql-min2": $a4, "sql-max2": $a5 }
+let $a8 := sql-var($l2)
+let $a9 := sql-var_pop($l2)
+return { "sql-count1": sql-count($l1), "average1": sql-avg($l1), "sql-sum1": sql-sum($l1), "sql-min1": sql-min($l1), "sql-max1": sql-max($l1), "sql-stddev1": sql-stddev($l1), "sql-stddev_pop1": sql-stddev_pop($l1), "sql-var1": sql-var($l1), "sql-var_pop1": sql-var_pop($l1), "sql-count2": $a1, "average2": $a2, "sql-sum2": $a3, "sql-min2": $a4, "sql-max2": $a5, "sql-stddev2": $a6, "sql-stddev_pop2": $a7, "sql-var2": $a8, "sql-var_pop2": $a9 }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number_rec/agg_number_rec.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number_rec/agg_number_rec.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number_rec/agg_number_rec.3.query.aql
index cd93b51..e5700d5 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number_rec/agg_number_rec.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate-sql/agg_number_rec/agg_number_rec.3.query.aql
@@ -25,4 +25,4 @@
 use dataverse test;
 
 let $l := for $t in dataset Test return $t.valplus
-return { "sql-count": sql-count($l), "average": sql-avg($l), "sql-stddev": sql-stddev($l), "sql-stddev_pop": sql-stddev_pop($l), "sql-sum": sql-sum($l), "sql-min": sql-min($l), "sql-max": sql-max($l) }
+return { "sql-count": sql-count($l), "average": sql-avg($l), "sql-sum": sql-sum($l), "sql-min": sql-min($l), "sql-max": sql-max($l), "sql-stddev": sql-stddev($l), "sql-stddev_pop": sql-stddev_pop($l), "sql-var": sql-var($l), "sql-var_pop": sql-var_pop($l) }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.3.query.aql
index 92fc08f..f2e57e6 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.3.query.aql
@@ -24,4 +24,4 @@
 
 let $l1 := [null]
 let $l2 := {{null, null}}
-return { "count1": count($l1), "average1": avg($l1), "sum1": sum($l1), "min1": min($l1), "max1": max($l1),"stddev1": stddev($l1), "stddev_pop1": stddev_pop($l1), "count2": count($l2), "average2": avg($l2), "sum2": sum($l2), "min2": min($l2), "max2": max($l2), "stddev2": stddev($l2), "stddev_pop2": stddev_pop($l2) }
+return { "count1": count($l1), "average1": avg($l1), "sum1": sum($l1), "min1": min($l1), "max1": max($l1), "stddev1": stddev($l1), "stddev_pop1": stddev_pop($l1), "var1": var($l1), "var_pop1": var_pop($l1), "count2": count($l2), "average2": avg($l2), "sum2": sum($l2), "min2": min($l2), "max2": max($l2), "stddev2": stddev($l2), "stddev_pop2": stddev_pop($l2), "var2": var($l2), "var_pop2": var_pop($l2) }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.3.query.aql
index 238fb4e..3fb4168 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.3.query.aql
@@ -25,4 +25,4 @@
 use dataverse test;
 
 let $l := for $t in dataset Test return $t.valplus
-return { "count": count($l), "average": avg($l), "stddev": stddev($l), "stddev_pop": stddev_pop($l), "sum": sum($l), "min": min($l), "max": max($l) }
+return { "count": count($l), "average": avg($l), "sum": sum($l), "min": min($l), "max": max($l), "stddev": stddev($l), "stddev_pop": stddev_pop($l), "var": var($l), "var_pop": var_pop($l) }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.aql
index 1e2dcd2..c846213 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.aql
@@ -26,6 +26,7 @@ use dataverse test;
 
 let $l := for $t in dataset Test return $t
 return { "count": count($l), "average": avg(for $i in $l return $i.val), "sum":
-sum(for $i in $l return $i.val), "stddev": stddev(for $i in $l return $i.val),
-"stddev_pop": stddev_pop(for $i in $l return $i.val), "min": min(for $i in $l return $i.valplus),
-"max": max(for $i in $l return $i.valplus) }
+sum(for $i in $l return $i.val), "min": min(for $i in $l return $i.valplus),
+"max": max(for $i in $l return $i.valplus), "stddev": stddev(for $i in $l return $i.val),
+ "stddev_pop": stddev_pop(for $i in $l return $i.val), "var": var(for $i in $l return $i.val),
+ "var_pop": var_pop(for $i in $l return $i.val) }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.3.query.aql
index 98e996e..b5bcf22 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.3.query.aql
@@ -31,5 +31,7 @@ let $a4 := min($l2)
 let $a5 := max($l2)
 let $a6 := stddev($l2)
 let $a7 := stddev_pop($l2)
-return { "count1": count($l1), "average1": avg($l1), "stddev1": stddev($l1), "stddev_pop1": stddev_pop($l1), "sum1": sum($l1), "min1": min($l1), "max1": max($l1), "count2": $a1, "average2": $a2, "stddev2": $a6, "stddev_pop2": $a7, "sum2": $a3, "min2": $a4, "max2": $a5 }
+let $a8 := var($l2)
+let $a9 := var_pop($l2)
+return { "count1": count($l1), "average1": avg($l1), "sum1": sum($l1), "min1": min($l1), "max1": max($l1), "stddev1": stddev($l1), "stddev_pop1": stddev_pop($l1), "var1": var($l1), "var_pop1": var_pop($l1), "count2": $a1, "average2": $a2, "sum2": $a3, "min2": $a4, "max2": $a5, "stddev2": $a6, "stddev_pop2": $a7, "var2": $a8, "var_pop2": $a9 }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.3.query.aql
index 8dbb4d3..1c715df 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.3.query.aql
@@ -25,4 +25,4 @@
 use dataverse test;
 
 let $l := for $t in dataset Test return $t.valplus
-return { "count": count($l), "average": avg($l), "stddev": stddev($l), "stddev_pop": stddev_pop($l), "sum": sum($l), "min": min($l), "max": max($l) }
+return { "count": count($l), "average": avg($l), "sum": sum($l), "min": min($l), "max": max($l), "stddev": stddev($l), "stddev_pop": stddev_pop($l), "var": var($l), "var_pop": var_pop($l) }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.3.query.sqlpp
index 547b555..bb5957a 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.3.query.sqlpp
@@ -22,4 +22,4 @@
 * Date         : Feb 7th 2014
 */
 
-{'sql-count1':array_count([null]),'average1':array_avg([null]),'sql-sum1':array_sum([null]),'sql-min1':array_min([null]),'sql-max1':array_max([null]),'sql-stddev1':array_stddev([null]),'sql-stddev_pop1':array_stddev_pop([null]),'sql-count2':array_count({{null,null}}),'average2':array_avg({{null,null}}),'sql-sum2':array_sum({{null,null}}),'sql-min2':array_min({{null,null}}),'sql-max2':array_max({{null,null}}),'sql-stddev2':array_stddev({{null,null}}),'sql-stddev_pop2':array_stddev_pop({{null,null}})};
+{'sql-count1':array_count([null]),'average1':array_avg([null]),'sql-sum1':array_sum([null]),'sql-min1':array_min([null]),'sql-max1':array_max([null]),'sql-stddev1':array_stddev([null]),'sql-stddev_pop1':array_stddev_pop([null]),'sql-var1':array_var([null]),'sql-var_pop1':array_var_pop([null]),'sql-count2':array_count({{null,null}}),'average2':array_avg({{null,null}}),'sql-sum2':array_sum({{null,null}}),'sql-min2':array_min({{null,null}}),'sql-max2':array_max({{null,null}}),'sql-stddev2':array_stddev({{null,null}}),'sql-stddev_pop2':array_stddev_pop({{null,null}}),'sql-var2':array_var({{null,null}}),'sql-var_pop2':array_var_pop({{null,null}})};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.query.sqlpp
index 1831367..126209d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.query.sqlpp
@@ -46,4 +46,10 @@ use test;
 )),'sql-stddev_pop':test.array_stddev_pop((
     select element t.valplus
     from  Test as t
+)),'sql-var':test.array_var((
+    select element t.valplus
+    from  Test as t
+)),'sql-var_pop':test.array_var_pop((
+    select element t.valplus
+    from  Test as t
 ))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
index 9a56d93..47df03f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
@@ -64,4 +64,16 @@ use test;
         select element t
         from  Test as t
     ) as i
+)),'sql-var':test.array_var((
+    select element i.valplus
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+)),'sql-var_pop':test.array_var_pop((
+    select element i.valplus
+    from  (
+        select element t
+        from  Test as t
+    ) as i
 ))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.3.query.sqlpp
index f76f7d6..775e103 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.3.query.sqlpp
@@ -22,4 +22,4 @@
 * Date         : Feb 7th 2014
 */
 
-{'sql-count1':array_count([float('2.0'),double('3.0'),93847382783847382,1]),'average1':array_avg([float('2.0'),double('3.0'),93847382783847382,1]),'sql-sum1':array_sum([float('2.0'),double('3.0'),93847382783847382,1]),'sql-min1':array_min([float('2.0'),double('3.0'),93847382783847382,1]),'sql-max1':array_max([float('2.0'),double('3.0'),93847382783847382,1]),'sql-stddev1':array_stddev([float('2.0'),double('3.0'),93847382783847382,1]),'sql-stddev_pop1':array_stddev_pop([float('2.0'),double('3.0'),93847382783847382,1]),'sql-count2':array_count({{float('2.0'),double('3.0'),93847382783847382,1}}),'average2':array_avg({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-sum2':array_sum({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-min2':array_min({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-max2':array_max({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-stddev2':array_stddev({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-stddev_pop2':array_std
 dev_pop({{float('2.0'),double('3.0'),93847382783847382,1}})};
+{'sql-count1':array_count([float('2.0'),double('3.0'),93847382783847382,1]),'average1':array_avg([float('2.0'),double('3.0'),93847382783847382,1]),'sql-sum1':array_sum([float('2.0'),double('3.0'),93847382783847382,1]),'sql-min1':array_min([float('2.0'),double('3.0'),93847382783847382,1]),'sql-max1':array_max([float('2.0'),double('3.0'),93847382783847382,1]),'sql-stddev1':array_stddev([float('2.0'),double('3.0'),93847382783847382,1]),'sql-stddev_pop1':array_stddev_pop([float('2.0'),double('3.0'),93847382783847382,1]),'sql-var1':array_var([float('2.0'),double('3.0'),93847382783847382,1]),'sql-var_pop1':array_var_pop([float('2.0'),double('3.0'),93847382783847382,1]),'sql-count2':array_count({{float('2.0'),double('3.0'),93847382783847382,1}}),'average2':array_avg({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-sum2':array_sum({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-min2':array_min({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-max2':array_max({{float(
 '2.0'),double('3.0'),93847382783847382,1}}),'sql-stddev2':array_stddev({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-stddev_pop2':array_stddev_pop({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-var2':array_var({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-var_pop2':array_var_pop({{float('2.0'),double('3.0'),93847382783847382,1}})};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.query.sqlpp
index 790e567..d08777d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.query.sqlpp
@@ -46,4 +46,10 @@ use test;
 )),'sql-stddev_pop':test.array_stddev_pop((
     select element t.valplus
     from  Test as t
+)),'sql-var':test.array_var((
+    select element t.valplus
+    from  Test as t
+)),'sql-var_pop':test.array_var_pop((
+    select element t.valplus
+    from  Test as t
 ))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.query.sqlpp
index 8df1b09..ff0badd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 /*
-* Description  : Run array_avg over an ordered list with mixed types
+* Description  : Run array_avg over an multiset with mixed types
 * Expected Res : Failure
 * Date         : Feb 7th 2014
 */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var/scalar_var.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var/scalar_var.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var/scalar_var.1.ddl.sqlpp
new file mode 100644
index 0000000..3a3a45c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var/scalar_var.1.ddl.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop without nulls.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var/scalar_var.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var/scalar_var.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var/scalar_var.3.query.sqlpp
new file mode 100644
index 0000000..25e0906
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var/scalar_var.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+{'var': (with  i8 as test.array_var([test.tinyint('1'),test.tinyint('2'),test.tinyint('3')]),
+      i16 as test.array_var([test.smallint('1'),test.smallint('2'),test.smallint('3')]),
+      i32 as test.array_var([test.integer('1'),test.integer('2'),test.integer('3')]),
+      i64 as test.array_var([test.bigint('1'),test.bigint('2'),test.bigint('3')]),
+      f as test.array_var([test.float('1'),test.float('2'),test.float('3')]),
+      d as test.array_var([test.double('1'),test.double('2'),test.double('3')])
+select element i
+from  [i8,i16,i32,i64,f,d] as i),
+'var_pop': (with  i8 as test.array_var_pop([test.tinyint('1'),test.tinyint('2'),test.tinyint('3')]),
+      i16 as test.array_var_pop([test.smallint('1'),test.smallint('2'),test.smallint('3')]),
+      i32 as test.array_var_pop([test.integer('1'),test.integer('2'),test.integer('3')]),
+      i64 as test.array_var_pop([test.bigint('1'),test.bigint('2'),test.bigint('3')]),
+      f as test.array_var_pop([test.float('1'),test.float('2'),test.float('3')]),
+      d as test.array_var_pop([test.double('1'),test.double('2'),test.double('3')])
+select element i
+from  [i8,i16,i32,i64,f,d] as i)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..aceb0a1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.1.ddl.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop with an empty list.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.3.query.sqlpp
new file mode 100644
index 0000000..a9534b7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_empty/scalar_var_empty.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop with an empty list.
+ * Success        : Yes
+ */
+
+{'var': (select element array_var([])),
+'var_pop': (select element array_var_pop([]))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.1.ddl.sqlpp
new file mode 100644
index 0000000..4e53c2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.1.ddl.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop with nulls.
+ * Success        : Yes
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.3.query.sqlpp
new file mode 100644
index 0000000..6ed05fa
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_var_null/scalar_var_null.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests the scalar version of var and var_pop with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+{'var': (with  i8 as test.array_var([test.tinyint('1'),test.tinyint('2'),test.tinyint('3'),null]),
+      i16 as test.array_var([test.smallint('1'),test.smallint('2'),test.smallint('3'),null]),
+      i32 as test.array_var([test.integer('1'),test.integer('2'),test.integer('3'),null]),
+      i64 as test.array_var([test.bigint('1'),test.bigint('2'),test.bigint('3'),null]),
+      f as test.array_var([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test.array_var([test.double('1'),test.double('2'),test.double('3'),null])
+select element i
+from  [i8,i16,i32,i64,f,d] as i),
+'var_pop': (with  i8 as test.array_var_pop([test.tinyint('1'),test.tinyint('2'),test.tinyint('3'),null]),
+      i16 as test.array_var_pop([test.smallint('1'),test.smallint('2'),test.smallint('3'),null]),
+      i32 as test.array_var_pop([test.integer('1'),test.integer('2'),test.integer('3'),null]),
+      i64 as test.array_var_pop([test.bigint('1'),test.bigint('2'),test.bigint('3'),null]),
+      f as test.array_var_pop([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test.array_var_pop([test.double('1'),test.double('2'),test.double('3'),null])
+select element i
+from  [i8,i16,i32,i64,f,d] as i)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp
index 0c6a8a8..b0c5f68 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_mixed/serial_stddev_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
  /*
- * Description  : Run serial-stddev over an ordered list with mixed types
+ * Description  : Run serial-stddev over an multiset with mixed types
  * Expected Res : Failure
  * Date         : March 5th 2018
  */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp
index 207b139..92d729f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_stddev_pop_mixed/serial_stddev_pop_mixed.3.query.sqlpp
@@ -17,7 +17,7 @@
  * under the License.
  */
  /*
- * Description  : Run serial-stddev over an ordered list with mixed types
+ * Description  : Run serial-stddev over an multiset with mixed types
  * Expected Res : Failure
  * Date         : March 5th 2018
  */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.2.update.sqlpp
new file mode 100644
index 0000000..88d820c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':double(4.32),'valplus':double(473847.0)};
+insert into Test
+select element {'id':1,'gid':1,'val':double(5.32)};
+insert into Test
+select element {'id':2,'gid':1,'val':double(6.32),'valplus':double(38473827484738239.0)};
+insert into Test
+select element {'id':3,'gid':1,'val':double(4.32),'valplus':double(678900.0)};
+insert into Test
+select element {'id':4,'gid':1,'val':double(4.32),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.3.query.sqlpp
new file mode 100644
index 0000000..48a30f1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double/serial_var_double.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.val) as var, var_pop(t.val) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.2.update.sqlpp
new file mode 100644
index 0000000..88d820c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':double(4.32),'valplus':double(473847.0)};
+insert into Test
+select element {'id':1,'gid':1,'val':double(5.32)};
+insert into Test
+select element {'id':2,'gid':1,'val':double(6.32),'valplus':double(38473827484738239.0)};
+insert into Test
+select element {'id':3,'gid':1,'val':double(4.32),'valplus':double(678900.0)};
+insert into Test
+select element {'id':4,'gid':1,'val':double(4.32),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.3.query.sqlpp
new file mode 100644
index 0000000..abd0d49
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_double_null/serial_var_double_null.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.valplus) as var, var_pop(t.valplus) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..da0bd7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.3.query.sqlpp
new file mode 100644
index 0000000..48a30f1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_empty/serial_var_empty.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.val) as var, var_pop(t.val) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.1.ddl.sqlpp
new file mode 100644
index 0000000..ddac6a0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : bigint,
+  gid : bigint,
+  val : float
+};
+
+create  dataset Test(TestType) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.2.update.sqlpp
new file mode 100644
index 0000000..40641b5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':float('4.32'),'valplus':float('1')};
+insert into Test
+select element {'id':1,'gid':1,'val':float('5.32')};
+insert into Test
+select element {'id':2,'gid':1,'val':float('6.32'),'valplus':float('2')};
+insert into Test
+select element {'id':3,'gid':1,'val':float('4.32'),'valplus':float('3')};
+insert into Test
+select element {'id':4,'gid':1,'val':float('4.32'),'valplus':null};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.3.query.sqlpp
new file mode 100644
index 0000000..48a30f1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_var_float/serial_var_float.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+select gid, var(t.val) as var, var_pop(t.val) as var_pop
+from Test as t
+/* +hash */
+group by t.gid as gid;


[07/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64/var_int64.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64/var_int64.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64/var_int64.3.query.sqlpp
new file mode 100644
index 0000000..082552a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64/var_int64.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.strict_var((
+    select element x
+    from  [test.bigint('1'),test.bigint('2'),test.bigint('3')] as x
+))), 'var_pop': (select element test.strict_var_pop((
+    select element x
+    from  [test.bigint('1'),test.bigint('2'),test.bigint('3')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64_null/var_int64_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64_null/var_int64_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64_null/var_int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..3f2c5bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64_null/var_int64_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : integer,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64_null/var_int64_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64_null/var_int64_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64_null/var_int64_null.3.query.sqlpp
new file mode 100644
index 0000000..0d988c6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int64_null/var_int64_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.strict_var((
+    select element x.int64Field
+    from  Numeric as x
+)), 'var_pop':test.strict_var_pop((
+    select element x.int64Field
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8/var_int8.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8/var_int8.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8/var_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..21479a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8/var_int8.1.ddl.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8/var_int8.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8/var_int8.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8/var_int8.3.query.sqlpp
new file mode 100644
index 0000000..6965f4e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8/var_int8.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var': (select element test.strict_var((
+    select element x
+    from  [test.tinyint('1'),test.tinyint('2'),test.tinyint('3')] as x
+))), 'var_pop': (select element test.strict_var_pop((
+    select element x
+    from  [test.tinyint('1'),test.tinyint('2'),test.tinyint('3')] as x
+)))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8_null/var_int8_null.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8_null/var_int8_null.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8_null/var_int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..3f2c5bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8_null/var_int8_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : integer,
+  int8Field : tinyint?,
+  int16Field : smallint?,
+  int32Field : integer?,
+  int64Field : bigint?,
+  floatField : float?,
+  doubleField : double?
+};
+
+create external  dataset Numeric(NumericType) using localfs((`path`=`asterix_nc1://data/nontagged/numericData.json`),(`format`=`adm`));
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8_null/var_int8_null.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8_null/var_int8_null.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8_null/var_int8_null.3.query.sqlpp
new file mode 100644
index 0000000..d661a87
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_int8_null/var_int8_null.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'var':test.strict_var((
+    select element x.int8Field
+    from  Numeric as x
+)), 'var_pop':test.strict_var_pop((
+    select element x.int8Field
+    from  Numeric as x
+))};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_mixed/var_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_mixed/var_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_mixed/var_mixed.3.query.sqlpp
new file mode 100644
index 0000000..761a4d2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_mixed/var_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run var over an multiset with mixed types
+* Expected Res : Failure
+* Date         : March 5th 2018
+*/
+
+select element strict_var((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_pop_mixed/var_pop_mixed.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_pop_mixed/var_pop_mixed.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_pop_mixed/var_pop_mixed.3.query.sqlpp
new file mode 100644
index 0000000..9169d41
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/var_pop_mixed/var_pop_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run var_pop over an multiset with mixed types
+* Expected Res : Failure
+* Date         : Jun 2nd 2013
+*/
+
+select element strict_var_pop((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null/agg_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null/agg_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null/agg_null.1.adm
index a8c918b..f99998e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null/agg_null.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null/agg_null.1.adm
@@ -1 +1 @@
-{ "sql-count1": 0, "average1": null, "sql-sum1": null, "sql-min1": null, "sql-max1": null, "sql-stddev1": null, "sql-stddev_pop1": null, "sql-count2": 0, "average2": null, "sql-sum2": null, "sql-min2": null, "sql-max2": null, "sql-stddev2": null, "sql-stddev_pop2": null }
+{ "sql-count1": 0, "average1": null, "sql-sum1": null, "sql-min1": null, "sql-max1": null, "sql-stddev1": null, "sql-stddev_pop1": null, "sql-var1": null, "sql-var_pop1": null, "sql-count2": 0, "average2": null, "sql-sum2": null, "sql-min2": null, "sql-max2": null, "sql-stddev2": null, "sql-stddev_pop2": null, "sql-var2": null, "sql-var_pop2": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec/agg_null_rec.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec/agg_null_rec.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec/agg_null_rec.1.adm
index 99d052a..7041077 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec/agg_null_rec.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec/agg_null_rec.1.adm
@@ -1 +1 @@
-{ "sql-count": 2, "average": 26.0, "sql-stddev": 7.0710678118654755, "sql-stddev_pop": 5.0, "sql-sum": 52, "sql-min": 21, "sql-max": 31 }
+{ "sql-count": 2, "average": 26.0, "sql-stddev": 7.0710678118654755, "sql-stddev_pop": 5.0, "sql-var": 50.0, "sql-var_pop": 25.0, "sql-sum": 52, "sql-min": 21, "sql-max": 31 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec_1/agg_null_rec.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec_1/agg_null_rec.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec_1/agg_null_rec.1.adm
index 988d2e4..d0fa295 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec_1/agg_null_rec.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_null_rec_1/agg_null_rec.1.adm
@@ -1 +1 @@
-{ "sql-count": 3, "average": 5.32, "sql-sum": 15.96, "sql-stddev": 2.720510431232472E16, "sql-stddev_pop": 1.9236913742132196E16, "sql-min": 473847, "sql-max": 38473827484738239 }
+{ "sql-count": 3, "average": 5.32, "sql-sum": 15.96, "sql-stddev": 2.720510431232472E16, "sql-stddev_pop": 1.9236913742132196E16, "sql-var": 7.40117700644469E32, "sql-var_pop": 3.700588503222345E32, "sql-min": 473847, "sql-max": 38473827484738239 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number/agg_number.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number/agg_number.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number/agg_number.1.adm
index 37f109c..08843c5 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number/agg_number.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number/agg_number.1.adm
@@ -1 +1 @@
-{ "sql-count1": 4, "average1": 2.3461845695961844E16, "sql-stddev1": 4.6923691391923688E16, "sql-stddev_pop1": 4.0637108784747104E16, "sql-count2": 4, "average2": 2.3461845695961844E16, "sql-stddev2": 4.6923691391923688E16, "sql-stddev_pop2": 4.0637108784747104E16, "sql-sum1": 9.3847382783847376E16, "sql-min1": 1.0, "sql-max1": 9.3847382783847376E16, "sql-sum2": 9.3847382783847376E16, "sql-min2": 1.0, "sql-max2": 9.3847382783847376E16 }
+{ "sql-count1": 4, "average1": 2.3461845695961844E16, "sql-stddev1": 4.6923691391923688E16, "sql-stddev_pop1": 4.0637108784747104E16, "sql-var1": 2.2018328138444933E33, "sql-var_pop1": 1.65137461038337E33, "sql-count2": 4, "average2": 2.3461845695961844E16, "sql-stddev2": 4.6923691391923688E16, "sql-stddev_pop2": 4.0637108784747104E16, "sql-var2": 2.2018328138444933E33, "sql-var_pop2": 1.65137461038337E33, "sql-sum1": 9.3847382783847376E16, "sql-min1": 1.0, "sql-max1": 9.3847382783847376E16, "sql-sum2": 9.3847382783847376E16, "sql-min2": 1.0, "sql-max2": 9.3847382783847376E16 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number_rec/agg_number_rec.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number_rec/agg_number_rec.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number_rec/agg_number_rec.1.adm
index 19f61fd..0a8fb2f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number_rec/agg_number_rec.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/agg_number_rec/agg_number_rec.1.adm
@@ -1 +1 @@
-{ "sql-count": 3, "average": 1.2824609161579424E16, "sql-stddev": 2.2212874655068836E16, "sql-stddev_pop": 1.8136736208439848E16, "sql-sum": 3.8473827484738272E16, "sql-min": 2.0, "sql-max": 3.847382748473824E16 }
+{ "sql-count": 3, "average": 1.2824609161579424E16, "sql-stddev": 2.2212874655068836E16, "sql-stddev_pop": 1.8136736208439848E16, "sql-var": 4.934118004417994E32, "sql-var_pop": 3.28941200294533E32, "sql-sum": 3.8473827484738272E16, "sql-min": 2.0, "sql-max": 3.847382748473824E16 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var/scalar_var.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var/scalar_var.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var/scalar_var.1.adm
new file mode 100644
index 0000000..8b66369
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var/scalar_var.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ], "var_pop": [ 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var_empty/scalar_var_empty.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var_empty/scalar_var_empty.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var_empty/scalar_var_empty.1.adm
new file mode 100644
index 0000000..abf4b45
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var_empty/scalar_var_empty.1.adm
@@ -0,0 +1 @@
+{ "var": [ null ], "var_pop": [ null ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var_null/scalar_var_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var_null/scalar_var_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var_null/scalar_var_null.1.adm
new file mode 100644
index 0000000..8b66369
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_var_null/scalar_var_null.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ], "var_pop": [ 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_double/serial_var_double.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_double/serial_var_double.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_double/serial_var_double.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_double/serial_var_double.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_double_null/serial_var_double_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_double_null/serial_var_double_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_double_null/serial_var_double_null.1.adm
new file mode 100644
index 0000000..1d1b2a6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_double_null/serial_var_double_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 4.934118004270163E32, "var_pop": 3.289412002846775E32 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_empty/serial_var_empty.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_empty/serial_var_empty.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_empty/serial_var_empty.1.adm
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_float/serial_var_float.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_float/serial_var_float.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_float/serial_var_float.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_float/serial_var_float.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_float_null/serial_var_float_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_float_null/serial_var_float_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_float_null/serial_var_float_null.1.adm
new file mode 100644
index 0000000..2335482
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_float_null/serial_var_float_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 1.0, "var_pop": 0.6666666666666666 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int16/serial_var_int16.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int16/serial_var_int16.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int16/serial_var_int16.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int16/serial_var_int16.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.adm
new file mode 100644
index 0000000..2335482
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int16_null/serial_var_int16_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 1.0, "var_pop": 0.6666666666666666 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int32/serial_var_int32.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int32/serial_var_int32.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int32/serial_var_int32.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int32/serial_var_int32.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.adm
new file mode 100644
index 0000000..2335482
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int32_null/serial_var_int32_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 1.0, "var_pop": 0.6666666666666666 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int64/serial_var_int64.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int64/serial_var_int64.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int64/serial_var_int64.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int64/serial_var_int64.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.adm
new file mode 100644
index 0000000..2335482
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int64_null/serial_var_int64_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 1.0, "var_pop": 0.6666666666666666 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int8/serial_var_int8.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int8/serial_var_int8.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int8/serial_var_int8.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int8/serial_var_int8.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.adm
new file mode 100644
index 0000000..2335482
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_int8_null/serial_var_int8_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 1.0, "var_pop": 0.6666666666666666 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_mixed/serial_var_mixed.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_mixed/serial_var_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_mixed/serial_var_mixed.1.adm
new file mode 100644
index 0000000..e3b97f5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_mixed/serial_var_mixed.1.adm
@@ -0,0 +1 @@
+[  ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.1.adm
new file mode 100644
index 0000000..e3b97f5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_var_pop_mixed/serial_var_pop_mixed.1.adm
@@ -0,0 +1 @@
+[  ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_distinct/var_distinct.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_distinct/var_distinct.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_distinct/var_distinct.1.adm
new file mode 100644
index 0000000..f2ed238
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_distinct/var_distinct.1.adm
@@ -0,0 +1 @@
+{ "t1": 100, "t2": null, "t3": 50, "t4": null, "t5": 66, "t6": null, "t7": 25, "t8": null }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_double/var_double.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_double/var_double.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_double/var_double.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_double/var_double.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_double_null/var_double_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_double_null/var_double_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_double_null/var_double_null.1.adm
new file mode 100644
index 0000000..99c6acf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_double_null/var_double_null.1.adm
@@ -0,0 +1 @@
+{ "var": 0.0, "var_pop": 0.0 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_empty_01/var_empty_01.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_empty_01/var_empty_01.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_empty_01/var_empty_01.1.adm
new file mode 100644
index 0000000..abf4b45
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_empty_01/var_empty_01.1.adm
@@ -0,0 +1 @@
+{ "var": [ null ], "var_pop": [ null ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_empty_02/var_empty_02.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_empty_02/var_empty_02.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_empty_02/var_empty_02.1.adm
new file mode 100644
index 0000000..abf4b45
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_empty_02/var_empty_02.1.adm
@@ -0,0 +1 @@
+{ "var": [ null ], "var_pop": [ null ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_float/var_float.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_float/var_float.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_float/var_float.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_float/var_float.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_float_null/var_float_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_float_null/var_float_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_float_null/var_float_null.1.adm
new file mode 100644
index 0000000..99c6acf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_float_null/var_float_null.1.adm
@@ -0,0 +1 @@
+{ "var": 0.0, "var_pop": 0.0 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int16/var_int16.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int16/var_int16.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int16/var_int16.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int16/var_int16.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int16_null/var_int16_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int16_null/var_int16_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int16_null/var_int16_null.1.adm
new file mode 100644
index 0000000..99c6acf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int16_null/var_int16_null.1.adm
@@ -0,0 +1 @@
+{ "var": 0.0, "var_pop": 0.0 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int32/var_int32.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int32/var_int32.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int32/var_int32.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int32/var_int32.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int32_null/var_int32_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int32_null/var_int32_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int32_null/var_int32_null.1.adm
new file mode 100644
index 0000000..99c6acf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int32_null/var_int32_null.1.adm
@@ -0,0 +1 @@
+{ "var": 0.0, "var_pop": 0.0 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int64/var_int64.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int64/var_int64.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int64/var_int64.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int64/var_int64.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int64_null/var_int64_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int64_null/var_int64_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int64_null/var_int64_null.1.adm
new file mode 100644
index 0000000..99c6acf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int64_null/var_int64_null.1.adm
@@ -0,0 +1 @@
+{ "var": 0.0, "var_pop": 0.0 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int8/var_int8.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int8/var_int8.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int8/var_int8.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int8/var_int8.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int8_null/var_int8_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int8_null/var_int8_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int8_null/var_int8_null.1.adm
new file mode 100644
index 0000000..f02f9f2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_int8_null/var_int8_null.1.adm
@@ -0,0 +1 @@
+{ "var": 676.0, "var_pop": 450.6666666666667 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_mixed/var_mixed.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_mixed/var_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_mixed/var_mixed.1.adm
new file mode 100644
index 0000000..e3b97f5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_mixed/var_mixed.1.adm
@@ -0,0 +1 @@
+[  ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_pop_mixed/var_pop_mixed.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_pop_mixed/var_pop_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_pop_mixed/var_pop_mixed.1.adm
new file mode 100644
index 0000000..e3b97f5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/var_pop_mixed/var_pop_mixed.1.adm
@@ -0,0 +1 @@
+[  ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null/agg_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null/agg_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null/agg_null.1.adm
index 78a89a3..8977277 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null/agg_null.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null/agg_null.1.adm
@@ -1 +1 @@
-{ "count1": 1, "average1": null, "sum1": null, "min1": null, "max1": null, "stddev1": null, "stddev_pop1": null, "count2": 2, "average2": null, "sum2": null, "min2": null, "max2": null, "stddev2": null, "stddev_pop2": null }
+{ "count1": 1, "average1": null, "sum1": null, "min1": null, "max1": null, "stddev1": null, "stddev_pop1": null, "var1": null, "var_pop1": null, "count2": 2, "average2": null, "sum2": null, "min2": null, "max2": null, "stddev2": null, "stddev_pop2": null, "var2": null, "var_pop2": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec/agg_null_rec.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec/agg_null_rec.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec/agg_null_rec.1.adm
index 054e601..d38c950 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec/agg_null_rec.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec/agg_null_rec.1.adm
@@ -1 +1 @@
-{ "count": 3, "average": null, "stddev": null, "stddev_pop": null, "sum": null, "min": null, "max": null }
+{ "count": 3, "average": null, "stddev": null, "stddev_pop": null, "var": null, "var_pop": null, "sum": null, "min": null, "max": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec_1/agg_null_rec.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec_1/agg_null_rec.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec_1/agg_null_rec.1.adm
index 4be73ca..1127706 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec_1/agg_null_rec.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec_1/agg_null_rec.1.adm
@@ -1 +1 @@
-{ "count": 3, "average": 5.32, "sum": 15.96, "stddev": 1.0, "stddev_pop": 0.816496580927726, "min": null, "max": null }
+{ "count": 3, "average": 5.32, "sum": 15.96, "stddev": 1.0, "stddev_pop": 0.816496580927726, "var": 1.0, "var_pop": 0.6666666666666666, "min": null, "max": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm
index d6c4363..760b06c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm
@@ -1 +1 @@
-{ "count1": 4, "average1": 2.3461845695961844E16, "stddev1": 4.6923691391923688E16, "stddev_pop1": 4.0637108784747104E16, "count2": 4, "average2": 2.3461845695961844E16, "stddev2": 4.6923691391923688E16, "stddev_pop2": 4.0637108784747104E16, "sum1": 9.3847382783847376E16, "min1": 1.0, "max1": 9.3847382783847376E16, "sum2": 9.3847382783847376E16, "min2": 1.0, "max2": 9.3847382783847376E16 }
+{ "count1": 4, "average1": 2.3461845695961844E16, "stddev1": 4.6923691391923688E16, "stddev_pop1": 4.0637108784747104E16, "var1": 2.2018328138444933E33, "var_pop1": 1.65137461038337E33, "count2": 4, "average2": 2.3461845695961844E16, "stddev2": 4.6923691391923688E16, "stddev_pop2": 4.0637108784747104E16, "var2": 2.2018328138444933E33, "var_pop2": 1.65137461038337E33, "sum1": 9.3847382783847376E16, "min1": 1.0, "max1": 9.3847382783847376E16, "sum2": 9.3847382783847376E16, "min2": 1.0, "max2": 9.3847382783847376E16 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number_rec/agg_number_rec.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number_rec/agg_number_rec.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number_rec/agg_number_rec.1.adm
index 633b714..525ae14 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number_rec/agg_number_rec.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number_rec/agg_number_rec.1.adm
@@ -1 +1 @@
-{ "count": 3, "average": 1.2824609161579424E16, "stddev": 2.2212874655068836E16, "stddev_pop": 1.8136736208439848E16, "sum": 3.8473827484738272E16, "min": 2.0, "max": 3.847382748473824E16 }
+{ "count": 3, "average": 1.2824609161579424E16, "stddev": 2.2212874655068836E16, "stddev_pop": 1.8136736208439848E16, "var": 4.934118004417994E32, "var_pop": 3.28941200294533E32, "sum": 3.8473827484738272E16, "min": 2.0, "max": 3.847382748473824E16 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var/scalar_var.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var/scalar_var.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var/scalar_var.1.adm
new file mode 100644
index 0000000..8b66369
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var/scalar_var.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ], "var_pop": [ 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var_empty/scalar_var_empty.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var_empty/scalar_var_empty.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var_empty/scalar_var_empty.1.adm
new file mode 100644
index 0000000..abf4b45
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var_empty/scalar_var_empty.1.adm
@@ -0,0 +1 @@
+{ "var": [ null ], "var_pop": [ null ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var_null/scalar_var_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var_null/scalar_var_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var_null/scalar_var_null.1.adm
new file mode 100644
index 0000000..8bb7869
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/scalar_var_null/scalar_var_null.1.adm
@@ -0,0 +1 @@
+{ "var": [ null, null, null, null, null, null ], "var_pop": [ null, null, null, null, null, null ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_double/serial_var_double.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_double/serial_var_double.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_double/serial_var_double.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_double/serial_var_double.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_double_null/serial_var_double_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_double_null/serial_var_double_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_double_null/serial_var_double_null.1.adm
new file mode 100644
index 0000000..6341e9f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_double_null/serial_var_double_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_empty/serial_var_empty.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_empty/serial_var_empty.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_empty/serial_var_empty.1.adm
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_float/serial_var_float.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_float/serial_var_float.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_float/serial_var_float.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_float/serial_var_float.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_float_null/serial_var_float_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_float_null/serial_var_float_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_float_null/serial_var_float_null.1.adm
new file mode 100644
index 0000000..6341e9f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_float_null/serial_var_float_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int16/serial_var_int16.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int16/serial_var_int16.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int16/serial_var_int16.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int16/serial_var_int16.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int16_null/serial_var_int16_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int16_null/serial_var_int16_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int16_null/serial_var_int16_null.1.adm
new file mode 100644
index 0000000..6341e9f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int16_null/serial_var_int16_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int32/serial_var_int32.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int32/serial_var_int32.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int32/serial_var_int32.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int32/serial_var_int32.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int32_null/serial_var_int32_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int32_null/serial_var_int32_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int32_null/serial_var_int32_null.1.adm
new file mode 100644
index 0000000..6341e9f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int32_null/serial_var_int32_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int64/serial_var_int64.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int64/serial_var_int64.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int64/serial_var_int64.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int64/serial_var_int64.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int64_null/serial_var_int64_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int64_null/serial_var_int64_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int64_null/serial_var_int64_null.1.adm
new file mode 100644
index 0000000..6341e9f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int64_null/serial_var_int64_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int8/serial_var_int8.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int8/serial_var_int8.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int8/serial_var_int8.1.adm
new file mode 100644
index 0000000..b2f05cb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int8/serial_var_int8.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": 0.8, "var_pop": 0.64 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int8_null/serial_var_int8_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int8_null/serial_var_int8_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int8_null/serial_var_int8_null.1.adm
new file mode 100644
index 0000000..6341e9f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_int8_null/serial_var_int8_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_mixed/serial_var_mixed.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_mixed/serial_var_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_mixed/serial_var_mixed.1.adm
new file mode 100644
index 0000000..ae7dd85
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_mixed/serial_var_mixed.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.adm
new file mode 100644
index 0000000..be46433
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_var_pop_mixed/serial_var_pop_mixed.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_distinct/var_distinct.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_distinct/var_distinct.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_distinct/var_distinct.1.adm
new file mode 100644
index 0000000..886e024
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_distinct/var_distinct.1.adm
@@ -0,0 +1 @@
+{ "t1": 100, "t2": null, "t3": null, "t4": null, "t5": 66, "t6": null, "t7": null, "t8": null }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_double/var_double.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_double/var_double.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_double/var_double.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_double/var_double.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_double_null/var_double_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_double_null/var_double_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_double_null/var_double_null.1.adm
new file mode 100644
index 0000000..0a34eda
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_double_null/var_double_null.1.adm
@@ -0,0 +1 @@
+{ "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_empty_01/var_empty_01.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_empty_01/var_empty_01.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_empty_01/var_empty_01.1.adm
new file mode 100644
index 0000000..abf4b45
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_empty_01/var_empty_01.1.adm
@@ -0,0 +1 @@
+{ "var": [ null ], "var_pop": [ null ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_empty_02/var_empty_02.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_empty_02/var_empty_02.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_empty_02/var_empty_02.1.adm
new file mode 100644
index 0000000..abf4b45
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_empty_02/var_empty_02.1.adm
@@ -0,0 +1 @@
+{ "var": [ null ], "var_pop": [ null ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_float/var_float.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_float/var_float.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_float/var_float.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_float/var_float.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_float_null/var_float_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_float_null/var_float_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_float_null/var_float_null.1.adm
new file mode 100644
index 0000000..0a34eda
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_float_null/var_float_null.1.adm
@@ -0,0 +1 @@
+{ "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int16/var_int16.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int16/var_int16.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int16/var_int16.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int16/var_int16.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int16_null/var_int16_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int16_null/var_int16_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int16_null/var_int16_null.1.adm
new file mode 100644
index 0000000..0a34eda
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int16_null/var_int16_null.1.adm
@@ -0,0 +1 @@
+{ "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int32/var_int32.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int32/var_int32.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int32/var_int32.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int32/var_int32.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int32_null/var_int32_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int32_null/var_int32_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int32_null/var_int32_null.1.adm
new file mode 100644
index 0000000..0a34eda
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int32_null/var_int32_null.1.adm
@@ -0,0 +1 @@
+{ "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int64/var_int64.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int64/var_int64.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int64/var_int64.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int64/var_int64.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int64_null/var_int64_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int64_null/var_int64_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int64_null/var_int64_null.1.adm
new file mode 100644
index 0000000..0a34eda
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int64_null/var_int64_null.1.adm
@@ -0,0 +1 @@
+{ "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int8/var_int8.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int8/var_int8.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int8/var_int8.1.adm
new file mode 100644
index 0000000..b6c4979
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int8/var_int8.1.adm
@@ -0,0 +1 @@
+{ "var": [ 1.0 ], "var_pop": [ 0.6666666666666666 ] }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int8_null/var_int8_null.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int8_null/var_int8_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int8_null/var_int8_null.1.adm
new file mode 100644
index 0000000..0a34eda
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_int8_null/var_int8_null.1.adm
@@ -0,0 +1 @@
+{ "var": null, "var_pop": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_mixed/var_mixed.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_mixed/var_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_mixed/var_mixed.1.adm
new file mode 100644
index 0000000..e3b97f5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_mixed/var_mixed.1.adm
@@ -0,0 +1 @@
+[  ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_pop_mixed/var_pop_mixed.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_pop_mixed/var_pop_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_pop_mixed/var_pop_mixed.1.adm
new file mode 100644
index 0000000..e3b97f5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/var_pop_mixed/var_pop_mixed.1.adm
@@ -0,0 +1 @@
+[  ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.3.ast
index 0e8f3ea..f370f90 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.3.ast
@@ -64,6 +64,24 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [sql-var1]
+    :
+    FunctionCall asterix.sql-var@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-var_pop1]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
     LiteralExpr [STRING] [sql-count2]
     :
     FunctionCall asterix.sql-count@1[
@@ -133,4 +151,24 @@ RecordConstructor [
       ]
     ]
   )
+  (
+    LiteralExpr [STRING] [sql-var2]
+    :
+    FunctionCall asterix.sql-var@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-var_pop2]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
 ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.ast
index 96cbb48..110949e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.ast
@@ -134,4 +134,42 @@ RecordConstructor [
       )
     ]
   )
+  (
+    LiteralExpr [STRING] [sql-var]
+    :
+    FunctionCall asterix.sql-var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Test]
+          ]
+          AS Variable [ Name=$t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-var_pop]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Test]
+          ]
+          AS Variable [ Name=$t ]
+        ]
+      )
+    ]
+  )
 ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.ast
index c411817..f10192b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.ast
@@ -173,4 +173,56 @@ RecordConstructor [
       )
     ]
   )
+  (
+    LiteralExpr [STRING] [sql-var]
+    :
+    FunctionCall asterix.sql-var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$i ]
+          Field=valplus
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=$t ]
+            ]
+            FROM [              FunctionCall asterix.dataset@1[
+                LiteralExpr [STRING] [test.Test]
+              ]
+              AS Variable [ Name=$t ]
+            ]
+          )
+          AS Variable [ Name=$i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-var_pop]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$i ]
+          Field=valplus
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=$t ]
+            ]
+            FROM [              FunctionCall asterix.dataset@1[
+                LiteralExpr [STRING] [test.Test]
+              ]
+              AS Variable [ Name=$t ]
+            ]
+          )
+          AS Variable [ Name=$i ]
+        ]
+      )
+    ]
+  )
 ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.3.ast
index cbaebaa..bcc764d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.3.ast
@@ -113,6 +113,38 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [sql-var1]
+    :
+    FunctionCall asterix.sql-var@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-var_pop1]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
     LiteralExpr [STRING] [sql-count2]
     :
     FunctionCall asterix.sql-count@1[
@@ -224,4 +256,36 @@ RecordConstructor [
       ]
     ]
   )
+  (
+    LiteralExpr [STRING] [sql-var2]
+    :
+    FunctionCall asterix.sql-var@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-var_pop2]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
 ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.ast
index 96cbb48..110949e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.ast
@@ -134,4 +134,42 @@ RecordConstructor [
       )
     ]
   )
+  (
+    LiteralExpr [STRING] [sql-var]
+    :
+    FunctionCall asterix.sql-var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Test]
+          ]
+          AS Variable [ Name=$t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-var_pop]
+    :
+    FunctionCall asterix.sql-var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Test]
+          ]
+          AS Variable [ Name=$t ]
+        ]
+      )
+    ]
+  )
 ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var/scalar_var.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var/scalar_var.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_var/scalar_var.1.ast
new file mode 100644
index 0000000..e69de29


[04/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and var_pop() aggregate function

Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double/var_double.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double/var_double.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double/var_double.1.ast
new file mode 100644
index 0000000..086bc5f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double/var_double.1.ast
@@ -0,0 +1,2 @@
+DataverseUse test
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double/var_double.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double/var_double.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double/var_double.3.ast
new file mode 100644
index 0000000..3c8e43d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double/var_double.3.ast
@@ -0,0 +1,51 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [DOUBLE] [1.0]
+              LiteralExpr [DOUBLE] [2.0]
+              FunctionCall null.double@1[
+                LiteralExpr [STRING] [3.0]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [DOUBLE] [1.0]
+              LiteralExpr [DOUBLE] [2.0]
+              FunctionCall null.double@1[
+                LiteralExpr [STRING] [3.0]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double_null/var_double_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double_null/var_double_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double_null/var_double_null.1.ast
new file mode 100644
index 0000000..2b387f8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double_null/var_double_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : integer,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double_null/var_double_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double_null/var_double_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double_null/var_double_null.3.ast
new file mode 100644
index 0000000..6ae7dac
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_double_null/var_double_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=doubleField
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=doubleField
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_01/var_empty_01.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_01/var_empty_01.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_01/var_empty_01.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_01/var_empty_01.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_01/var_empty_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_01/var_empty_01.3.ast
new file mode 100644
index 0000000..1deb3da
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_01/var_empty_01.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [LONG] [1]
+              LiteralExpr [LONG] [2]
+              LiteralExpr [LONG] [3]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+          Where
+            OperatorExpr [
+              Variable [ Name=$x ]
+              >
+              LiteralExpr [LONG] [10]
+            ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [LONG] [1]
+              LiteralExpr [LONG] [2]
+              LiteralExpr [LONG] [3]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+          Where
+            OperatorExpr [
+              Variable [ Name=$x ]
+              >
+              LiteralExpr [LONG] [10]
+            ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_02/var_empty_02.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_02/var_empty_02.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_02/var_empty_02.1.ast
new file mode 100644
index 0000000..babcce4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_02/var_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : integer,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_02/var_empty_02.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_02/var_empty_02.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_02/var_empty_02.3.ast
new file mode 100644
index 0000000..2bafb81
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_empty_02/var_empty_02.3.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=$x ]
+            Field=val
+          ]
+          ]
+          FROM [            FunctionCall asterix.dataset@1[
+              LiteralExpr [STRING] [test.Test]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var_pop@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=$x ]
+            Field=val
+          ]
+          ]
+          FROM [            FunctionCall asterix.dataset@1[
+              LiteralExpr [STRING] [test.Test]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float/var_float.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float/var_float.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float/var_float.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float/var_float.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float/var_float.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float/var_float.3.ast
new file mode 100644
index 0000000..b83c96c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float/var_float.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.float@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float_null/var_float_nu.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float_null/var_float_nu.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float_null/var_float_nu.1.ast
new file mode 100644
index 0000000..2b387f8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float_null/var_float_nu.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : integer,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float_null/var_float_nu.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float_null/var_float_nu.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float_null/var_float_nu.3.ast
new file mode 100644
index 0000000..e057b6f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_float_null/var_float_nu.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=floatField
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=floatField
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16/var_int16.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16/var_int16.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16/var_int16.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16/var_int16.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16/var_int16.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16/var_int16.3.ast
new file mode 100644
index 0000000..79bcb4a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16/var_int16.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int16@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16_null/var_int16_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16_null/var_int16_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16_null/var_int16_null.1.ast
new file mode 100644
index 0000000..2b387f8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16_null/var_int16_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : integer,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16_null/var_int16_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16_null/var_int16_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16_null/var_int16_null.3.ast
new file mode 100644
index 0000000..9b566f4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int16_null/var_int16_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int16Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int16Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32/var_int32.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32/var_int32.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32/var_int32.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32/var_int32.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32/var_int32.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32/var_int32.3.ast
new file mode 100644
index 0000000..154538e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32/var_int32.3.ast
@@ -0,0 +1,48 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [LONG] [1]
+              LiteralExpr [LONG] [2]
+              LiteralExpr [LONG] [3]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              LiteralExpr [LONG] [1]
+              LiteralExpr [LONG] [2]
+              LiteralExpr [LONG] [3]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32_null/var_int32_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32_null/var_int32_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32_null/var_int32_null.1.ast
new file mode 100644
index 0000000..2b387f8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32_null/var_int32_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : integer,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32_null/var_int32_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32_null/var_int32_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32_null/var_int32_null.3.ast
new file mode 100644
index 0000000..054780c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int32_null/var_int32_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int32Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int32Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64/var_int64.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64/var_int64.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64/var_int64.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64/var_int64.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64/var_int64.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64/var_int64.3.ast
new file mode 100644
index 0000000..afbe240
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64/var_int64.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int64@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64_null/var_int64_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64_null/var_int64_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64_null/var_int64_null.1.ast
new file mode 100644
index 0000000..2b387f8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64_null/var_int64_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : integer,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64_null/var_int64_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64_null/var_int64_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64_null/var_int64_null.3.ast
new file mode 100644
index 0000000..98b7ca7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int64_null/var_int64_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int64Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int64Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8/var_int8.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8/var_int8.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8/var_int8.1.ast
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8/var_int8.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8/var_int8.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8/var_int8.3.ast
new file mode 100644
index 0000000..f51aeee
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8/var_int8.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    (
+      SELECT ELEMENT [
+      FunctionCall asterix.var_pop@1[
+        (
+          SELECT ELEMENT [
+          Variable [ Name=$x ]
+          ]
+          FROM [            OrderedListConstructor [
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [1]
+              ]
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [2]
+              ]
+              FunctionCall test.int8@1[
+                LiteralExpr [STRING] [3]
+              ]
+            ]
+            AS Variable [ Name=$x ]
+          ]
+        )
+      ]
+      ]
+    )
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8_null/var_int8_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8_null/var_int8_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8_null/var_int8_null.1.ast
new file mode 100644
index 0000000..2b387f8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8_null/var_int8_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : integer,
+    int8Field : tinyint?,
+    int16Field : smallint?,
+    int32Field : integer?,
+    int64Field : bigint?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8_null/var_int8_null.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8_null/var_int8_null.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8_null/var_int8_null.3.ast
new file mode 100644
index 0000000..40ae288
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_int8_null/var_int8_null.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [var]
+    :
+    FunctionCall asterix.var@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int8Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [var_pop]
+    :
+    FunctionCall asterix.var_pop@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=$x ]
+          Field=int8Field
+        ]
+        ]
+        FROM [          FunctionCall asterix.dataset@1[
+            LiteralExpr [STRING] [test.Numeric]
+          ]
+          AS Variable [ Name=$x ]
+        ]
+      )
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_mixed/var_mixed.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_mixed/var_mixed.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_mixed/var_mixed.3.ast
new file mode 100644
index 0000000..ae1dddb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_mixed/var_mixed.3.ast
@@ -0,0 +1,22 @@
+Query:
+SELECT ELEMENT [
+FunctionCall asterix.var@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=$x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS Variable [ Name=$x ]
+    ]
+  )
+]
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_pop_mixed/var_pop_mixed.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_pop_mixed/var_pop_mixed.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_pop_mixed/var_pop_mixed.3.ast
new file mode 100644
index 0000000..0756ce7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/var_pop_mixed/var_pop_mixed.3.ast
@@ -0,0 +1,22 @@
+Query:
+SELECT ELEMENT [
+FunctionCall asterix.var_pop@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=$x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS Variable [ Name=$x ]
+    ]
+  )
+]
+]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 2016ea4..1a9c7dd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -230,6 +230,30 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
+      <compilation-unit name="var_mixed">
+        <output-dir compare="Text">var_mixed</output-dir>
+        <expected-error>Type incompatibility: function agg-var gets incompatible input values: string and float</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_mixed">
+        <output-dir compare="Text">serial_var_mixed</output-dir>
+        <expected-error>Type incompatibility: function agg-var gets incompatible input values: string and float</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_pop_mixed">
+        <output-dir compare="Text">var_pop_mixed</output-dir>
+        <expected-error>Type incompatibility: function agg-var_pop gets incompatible input values: string and float</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_pop_mixed">
+        <output-dir compare="Text">serial_var_pop_mixed</output-dir>
+        <expected-error>Type incompatibility: function agg-var_pop gets incompatible input values: string and float</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
       <compilation-unit name="agg_number">
         <output-dir compare="Text">agg_number</output-dir>
       </compilation-unit>
@@ -566,6 +590,21 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
+      <compilation-unit name="scalar_var">
+        <output-dir compare="Text">scalar_var</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="scalar_var_empty">
+        <output-dir compare="Text">scalar_var_empty</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="scalar_var_null">
+        <output-dir compare="Text">scalar_var_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
       <compilation-unit name="scalar_sum_empty">
         <output-dir compare="Text">scalar_sum_empty</output-dir>
       </compilation-unit>
@@ -641,6 +680,71 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_double">
+        <output-dir compare="Text">serial_var_double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_double_null">
+        <output-dir compare="Text">serial_var_double_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_empty">
+        <output-dir compare="Text">serial_var_empty</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_float">
+        <output-dir compare="Text">serial_var_float</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_float_null">
+        <output-dir compare="Text">serial_var_float_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int16">
+        <output-dir compare="Text">serial_var_int16</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int16_null">
+        <output-dir compare="Text">serial_var_int16_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int32">
+        <output-dir compare="Text">serial_var_int32</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int32_null">
+        <output-dir compare="Text">serial_var_int32_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int64">
+        <output-dir compare="Text">serial_var_int64</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int64_null">
+        <output-dir compare="Text">serial_var_int64_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int8">
+        <output-dir compare="Text">serial_var_int8</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int8_null">
+        <output-dir compare="Text">serial_var_int8_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
       <compilation-unit name="stddev_double">
         <output-dir compare="Text">stddev_double</output-dir>
       </compilation-unit>
@@ -800,6 +904,81 @@
         <output-dir compare="Text">sum_distinct</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_double">
+        <output-dir compare="Text">var_double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_double_null">
+        <output-dir compare="Text">var_double_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_empty_01">
+        <output-dir compare="Text">var_empty_01</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_empty_02">
+        <output-dir compare="Text">var_empty_02</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_float">
+        <output-dir compare="Text">var_float</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_float_null">
+        <output-dir compare="Text">var_float_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int16">
+        <output-dir compare="Text">var_int16</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int16_null">
+        <output-dir compare="Text">var_int16_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int32">
+        <output-dir compare="Text">var_int32</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int32_null">
+        <output-dir compare="Text">var_int32_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int64">
+        <output-dir compare="Text">var_int64</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int64_null">
+        <output-dir compare="Text">var_int64_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int8">
+        <output-dir compare="Text">var_int8</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int8_null">
+        <output-dir compare="Text">var_int8_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_distinct">
+        <output-dir compare="Text">var_distinct</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="aggregate-sql">
     <test-case FilePath="aggregate-sql">
@@ -870,6 +1049,30 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_mixed">
+        <output-dir compare="Text">serial_var_mixed</output-dir>
+        <expected-error>Invalid item type: function agg-var cannot process item type string in an input array (or multiset)</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_mixed">
+        <output-dir compare="Text">var_mixed</output-dir>
+        <expected-error>Type incompatibility: function agg-var gets incompatible input values: string and float</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_pop_mixed">
+        <output-dir compare="Text">serial_var_pop_mixed</output-dir>
+        <expected-error>Invalid item type: function agg-var_pop cannot process item type string in an input array (or multiset)</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_pop_mixed">
+        <output-dir compare="Text">var_pop_mixed</output-dir>
+        <expected-error>Type incompatibility: function agg-var_pop gets incompatible input values: string and float</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
       <compilation-unit name="agg_number">
         <output-dir compare="Text">agg_number</output-dir>
       </compilation-unit>
@@ -1145,6 +1348,21 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
+      <compilation-unit name="scalar_var">
+        <output-dir compare="Text">scalar_var</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="scalar_var_empty">
+        <output-dir compare="Text">scalar_var_empty</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="scalar_var_null">
+        <output-dir compare="Text">scalar_var_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
       <compilation-unit name="serial_stddev_double">
         <output-dir compare="Text">serial_stddev_double</output-dir>
       </compilation-unit>
@@ -1210,6 +1428,71 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_double">
+        <output-dir compare="Text">serial_var_double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_double_null">
+        <output-dir compare="Text">serial_var_double_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_empty">
+        <output-dir compare="Text">serial_var_empty</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_float">
+        <output-dir compare="Text">serial_var_float</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_float_null">
+        <output-dir compare="Text">serial_var_float_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_int16">
+        <output-dir compare="Text">serial_var_int16</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_int16_null">
+        <output-dir compare="Text">serial_var_int16_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_int32">
+        <output-dir compare="Text">serial_var_int32</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_int32_null">
+        <output-dir compare="Text">serial_var_int32_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_int64">
+        <output-dir compare="Text">serial_var_int64</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_int64_null">
+        <output-dir compare="Text">serial_var_int64_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_int8">
+        <output-dir compare="Text">serial_var_int8</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_int8_null">
+        <output-dir compare="Text">serial_var_int8_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
       <compilation-unit name="stddev_double">
         <output-dir compare="Text">stddev_double</output-dir>
       </compilation-unit>
@@ -1369,6 +1652,81 @@
         <output-dir compare="Text">sum_distinct</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_double">
+        <output-dir compare="Text">var_double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_double_null">
+        <output-dir compare="Text">var_double_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_empty_01">
+        <output-dir compare="Text">var_empty_01</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_empty_02">
+        <output-dir compare="Text">var_empty_02</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_float">
+        <output-dir compare="Text">var_float</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_float_null">
+        <output-dir compare="Text">var_float_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_int16">
+        <output-dir compare="Text">var_int16</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_int16_null">
+        <output-dir compare="Text">var_int16_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_int32">
+        <output-dir compare="Text">var_int32</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_int32_null">
+        <output-dir compare="Text">var_int32_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_int64">
+        <output-dir compare="Text">var_int64</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_int64_null">
+        <output-dir compare="Text">var_int64_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_int8">
+        <output-dir compare="Text">var_int8</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_int8_null">
+        <output-dir compare="Text">var_int8_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_distinct">
+        <output-dir compare="Text">var_distinct</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="array_fun">
     <test-case FilePath="array_fun">

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
index cd77828..48a9553 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
@@ -146,6 +146,30 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
+      <compilation-unit name="var_mixed">
+        <output-dir compare="AST">var_mixed</output-dir>
+        <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_mixed">
+        <output-dir compare="AST">serial_var_mixed</output-dir>
+        <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_pop_mixed">
+        <output-dir compare="AST">var_pop_mixed</output-dir>
+        <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_pop_mixed">
+        <output-dir compare="AST">serial_var_pop_mixed</output-dir>
+        <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
       <compilation-unit name="agg_number">
         <output-dir compare="AST">agg_number</output-dir>
       </compilation-unit>
@@ -472,6 +496,21 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
+      <compilation-unit name="scalar_var">
+        <output-dir compare="AST">scalar_var</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="scalar_var_empty">
+        <output-dir compare="AST">scalar_var_empty</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="scalar_var_null">
+        <output-dir compare="AST">scalar_var_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
       <compilation-unit name="serial_stddev_int8_null">
         <output-dir compare="AST">serial_stddev_int8_null</output-dir>
       </compilation-unit>
@@ -542,6 +581,76 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int8_null">
+        <output-dir compare="AST">serial_var_int8_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_double">
+        <output-dir compare="AST">serial_var_double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_double_null">
+        <output-dir compare="AST">serial_var_double_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_empty">
+        <output-dir compare="AST">serial_var_empty</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_float">
+        <output-dir compare="AST">serial_var_float</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_float_null">
+        <output-dir compare="AST">serial_var_float_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int16">
+        <output-dir compare="AST">serial_var_int16</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int16_null">
+        <output-dir compare="AST">serial_var_int16_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int32">
+        <output-dir compare="AST">serial_var_int32</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int32_null">
+        <output-dir compare="AST">serial_var_int32_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int64">
+        <output-dir compare="AST">serial_var_int64</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int64_null">
+        <output-dir compare="AST">serial_var_int64_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int8">
+        <output-dir compare="AST">serial_var_int8</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_var_int8_null">
+        <output-dir compare="AST">serial_var_int8_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
       <compilation-unit name="stddev_double">
         <output-dir compare="AST">stddev_double</output-dir>
       </compilation-unit>
@@ -691,6 +800,76 @@
         <output-dir compare="AST">sum_numeric_null</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_double">
+        <output-dir compare="AST">var_double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_double_null">
+        <output-dir compare="AST">var_double_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_empty_01">
+        <output-dir compare="AST">var_empty_01</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_empty_02">
+        <output-dir compare="AST">var_empty_02</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_float">
+        <output-dir compare="AST">var_float</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_float_null">
+        <output-dir compare="AST">var_float_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int16">
+        <output-dir compare="AST">var_int16</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int16_null">
+        <output-dir compare="AST">var_int16_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int32">
+        <output-dir compare="AST">var_int32</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int32_null">
+        <output-dir compare="AST">var_int32_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int64">
+        <output-dir compare="AST">var_int64</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int64_null">
+        <output-dir compare="AST">var_int64_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int8">
+        <output-dir compare="AST">var_int8</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="var_int8_null">
+        <output-dir compare="AST">var_int8_null</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="aggregate-sql">
     <test-case FilePath="aggregate-sql">
@@ -761,6 +940,30 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_mixed">
+        <output-dir compare="AST">serial_var_mixed</output-dir>
+        <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_mixed">
+        <output-dir compare="AST">var_mixed</output-dir>
+        <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_var_pop_mixed">
+        <output-dir compare="AST">serial_var_pop_mixed</output-dir>
+        <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="var_pop_mixed">
+        <output-dir compare="AST">var_pop_mixed</output-dir>
+        <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
       <compilation-unit name="agg_number">
         <output-dir compare="AST">agg_number</output-dir>
       </compilation-unit>
@@ -991,33 +1194,33 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="scalar_stddev_pop">
-        <output-dir compare="AST">scalar_stddev_pop</output-dir>
+      <compilation-unit name="scalar_sum">
+        <output-dir compare="AST">scalar_sum</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="scalar_stddev_pop_empty">
-        <output-dir compare="AST">scalar_stddev_pop_empty</output-dir>
+      <compilation-unit name="scalar_sum_empty">
+        <output-dir compare="AST">scalar_sum_empty</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="scalar_stddev_pop_null">
-        <output-dir compare="AST">scalar_stddev_pop_null</output-dir>
+      <compilation-unit name="scalar_sum_null">
+        <output-dir compare="AST">scalar_sum_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="scalar_sum">
-        <output-dir compare="AST">scalar_sum</output-dir>
+      <compilation-unit name="scalar_var">
+        <output-dir compare="AST">scalar_var</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="scalar_sum_empty">
-        <output-dir compare="AST">scalar_sum_empty</output-dir>
+      <compilation-unit name="scalar_var_empty">
+        <output-dir compare="AST">scalar_var_empty</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="scalar_sum_null">
-        <output-dir compare="AST">scalar_sum_null</output-dir>
+      <compilation-unit name="scalar_var_null">
+        <output-dir compare="AST">scalar_var_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
@@ -1086,71 +1289,6 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_double">
-        <output-dir compare="AST">serial_stddev_pop_double</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_double_null">
-        <output-dir compare="AST">serial_stddev_pop_double_null</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_empty">
-        <output-dir compare="AST">serial_stddev_pop_empty</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_float">
-        <output-dir compare="AST">serial_stddev_pop_float</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_float_null">
-        <output-dir compare="AST">serial_stddev_pop_float_null</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_int16">
-        <output-dir compare="AST">serial_stddev_pop_int16</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_int16_null">
-        <output-dir compare="AST">serial_stddev_pop_int16_null</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_int32">
-        <output-dir compare="AST">serial_stddev_pop_int32</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_int32_null">
-        <output-dir compare="AST">serial_stddev_pop_int32_null</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_int64">
-        <output-dir compare="AST">serial_stddev_pop_int64</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_int64_null">
-        <output-dir compare="AST">serial_stddev_pop_int64_null</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_int8">
-        <output-dir compare="AST">serial_stddev_pop_int8</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
-      <compilation-unit name="serial_stddev_pop_int8_null">
-        <output-dir compare="AST">serial_stddev_pop_int8_null</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="aggregate-sql">
       <compilation-unit name="stddev_double">
         <output-dir compare="AST">stddev_double</output-dir>
       </compilation-unit>
@@ -1221,153 +1359,153 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_double">
-        <output-dir compare="AST">stddev_pop_double</output-dir>
+      <compilation-unit name="sum_double">
+        <output-dir compare="AST">sum_double</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_double_null">
-        <output-dir compare="AST">stddev_pop_double_null</output-dir>
+      <compilation-unit name="sum_double_null">
+        <output-dir compare="AST">sum_double_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_empty_01">
-        <output-dir compare="AST">stddev_pop_empty_01</output-dir>
+      <compilation-unit name="sum_empty_01">
+        <output-dir compare="AST">sum_empty_01</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_empty_02">
-        <output-dir compare="AST">stddev_pop_empty_02</output-dir>
+      <compilation-unit name="sum_empty_02">
+        <output-dir compare="AST">sum_empty_02</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_float">
-        <output-dir compare="AST">stddev_pop_float</output-dir>
+      <compilation-unit name="sum_float">
+        <output-dir compare="AST">sum_float</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_float_null">
-        <output-dir compare="AST">stddev_pop_float_null</output-dir>
+      <compilation-unit name="sum_float_null">
+        <output-dir compare="AST">sum_float_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_int16">
-        <output-dir compare="AST">stddev_pop_int16</output-dir>
+      <compilation-unit name="sum_int16">
+        <output-dir compare="AST">sum_int16</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_int16_null">
-        <output-dir compare="AST">stddev_pop_int16_null</output-dir>
+      <compilation-unit name="sum_int16_null">
+        <output-dir compare="AST">sum_int16_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_int32">
-        <output-dir compare="AST">stddev_pop_int32</output-dir>
+      <compilation-unit name="sum_int32">
+        <output-dir compare="AST">sum_int32</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_int32_null">
-        <output-dir compare="AST">stddev_pop_int32_null</output-dir>
+      <compilation-unit name="sum_int32_null">
+        <output-dir compare="AST">sum_int32_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_int64">
-        <output-dir compare="AST">stddev_pop_int64</output-dir>
+      <compilation-unit name="sum_int64">
+        <output-dir compare="AST">sum_int64</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_int64_null">
-        <output-dir compare="AST">stddev_pop_int64_null</output-dir>
+      <compilation-unit name="sum_int64_null">
+        <output-dir compare="AST">sum_int64_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_int8">
-        <output-dir compare="AST">stddev_pop_int8</output-dir>
+      <compilation-unit name="sum_int8">
+        <output-dir compare="AST">sum_int8</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="stddev_pop_int8_null">
-        <output-dir compare="AST">stddev_pop_int8_null</output-dir>
+      <compilation-unit name="sum_int8_null">
+        <output-dir compare="AST">sum_int8_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_double">
-        <output-dir compare="AST">sum_double</output-dir>
+      <compilation-unit name="sum_null-with-pred">
+        <output-dir compare="AST">sum_null-with-pred</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_double_null">
-        <output-dir compare="AST">sum_double_null</output-dir>
+      <compilation-unit name="sum_numeric_null">
+        <output-dir compare="AST">sum_numeric_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_empty_01">
-        <output-dir compare="AST">sum_empty_01</output-dir>
+      <compilation-unit name="var_double">
+        <output-dir compare="AST">var_double</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_empty_02">
-        <output-dir compare="AST">sum_empty_02</output-dir>
+      <compilation-unit name="var_double_null">
+        <output-dir compare="AST">var_double_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_float">
-        <output-dir compare="AST">sum_float</output-dir>
+      <compilation-unit name="var_empty_01">
+        <output-dir compare="AST">var_empty_01</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_float_null">
-        <output-dir compare="AST">sum_float_null</output-dir>
+      <compilation-unit name="var_empty_02">
+        <output-dir compare="AST">var_empty_02</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_int16">
-        <output-dir compare="AST">sum_int16</output-dir>
+      <compilation-unit name="var_float">
+        <output-dir compare="AST">var_float</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_int16_null">
-        <output-dir compare="AST">sum_int16_null</output-dir>
+      <compilation-unit name="var_float_null">
+        <output-dir compare="AST">var_float_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_int32">
-        <output-dir compare="AST">sum_int32</output-dir>
+      <compilation-unit name="var_int16">
+        <output-dir compare="AST">var_int16</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_int32_null">
-        <output-dir compare="AST">sum_int32_null</output-dir>
+      <compilation-unit name="var_int16_null">
+        <output-dir compare="AST">var_int16_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_int64">
-        <output-dir compare="AST">sum_int64</output-dir>
+      <compilation-unit name="var_int32">
+        <output-dir compare="AST">var_int32</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_int64_null">
-        <output-dir compare="AST">sum_int64_null</output-dir>
+      <compilation-unit name="var_int32_null">
+        <output-dir compare="AST">var_int32_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_int8">
-        <output-dir compare="AST">sum_int8</output-dir>
+      <compilation-unit name="var_int64">
+        <output-dir compare="AST">var_int64</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_int8_null">
-        <output-dir compare="AST">sum_int8_null</output-dir>
+      <compilation-unit name="var_int64_null">
+        <output-dir compare="AST">var_int64_null</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_null-with-pred">
-        <output-dir compare="AST">sum_null-with-pred</output-dir>
+      <compilation-unit name="var_int8">
+        <output-dir compare="AST">var_int8</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
-      <compilation-unit name="sum_numeric_null">
-        <output-dir compare="AST">sum_numeric_null</output-dir>
+      <compilation-unit name="var_int8_null">
+        <output-dir compare="AST">var_int8_null</output-dir>
       </compilation-unit>
     </test-case>
   </test-group>

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-doc/src/main/markdown/builtins/9_aggregate_sql.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/9_aggregate_sql.md b/asterixdb/asterix-doc/src/main/markdown/builtins/9_aggregate_sql.md
index e9a5739..423edf1 100644
--- a/asterixdb/asterix-doc/src/main/markdown/builtins/9_aggregate_sql.md
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/9_aggregate_sql.md
@@ -174,14 +174,14 @@ SQL++ builtin aggregate functions (e.g., `ARRAY_MIN`, `ARRAY_MAX`,
 
         array_stddev(num_collection)
 
- * Gets the standard deviation value of the non-null and non-missing numeric items in the given collection.
+ * Gets the sample standard deviation value of the non-null and non-missing numeric items in the given collection.
  * Arguments:
     * `num_collection` could be:
         * an `array` or `multiset` containing numeric values, `null`s or `missing`s,
         * or, a `null` value,
         * or, a `missing` value.
  * Return Value:
-    * a `double` value representing the average of the non-null and non-missing numbers in the given collection,
+    * a `double` value representing the sample standard deviation of the non-null and non-missing numbers in the given collection,
     * `null` is returned if the input is `null` or `missing`,
     * `null` is returned if the given collection does not contain any non-null and non-missing items,
     * any other non-array and non-multiset input value will cause a type error,
@@ -201,14 +201,14 @@ SQL++ builtin aggregate functions (e.g., `ARRAY_MIN`, `ARRAY_MAX`,
 
         array_stddev_pop(num_collection)
 
- * Gets the standard deviation value of the non-null and non-missing numeric items in the given collection.
+ * Gets the population standard deviation value of the non-null and non-missing numeric items in the given collection.
  * Arguments:
     * `num_collection` could be:
         * an `array` or `multiset` containing numeric values, `null`s or `missing`s,
         * or, a `null` value,
         * or, a `missing` value.
  * Return Value:
-    * a `double` value representing the average of the non-null and non-missing numbers in the given collection,
+    * a `double` value representing the population standard deviation of the non-null and non-missing numbers in the given collection,
     * `null` is returned if the input is `null` or `missing`,
     * `null` is returned if the given collection does not contain any non-null and non-missing items,
     * any other non-array and non-multiset input value will cause a type error,
@@ -222,6 +222,61 @@ SQL++ builtin aggregate functions (e.g., `ARRAY_MIN`, `ARRAY_MAX`,
 
         1.2636751956100112
 
+### array_var ###
+
+ * Syntax:
+
+        array_var(num_collection)
+
+ * Gets the sample variance value of the non-null and non-missing numeric items in the given collection.
+ * Arguments:
+    * `num_collection` could be:
+        * an `array` or `multiset` containing numeric values, `null`s or `missing`s,
+        * or, a `null` value,
+        * or, a `missing` value.
+ * Return Value:
+    * a `double` value representing the sample variance of the non-null and non-missing numbers in the given collection,
+    * `null` is returned if the input is `null` or `missing`,
+    * `null` is returned if the given collection does not contain any non-null and non-missing items,
+    * any other non-array and non-multiset input value will cause a type error,
+    * any other non-numeric value in the input collection will cause a type error.
+
+ * Example:
+
+        array_var( [1.2, 2.3, 3.4, 0, null] );
+
+ * The expected result is:
+
+        2.1291666666666664
+
+### array_var_pop ###
+
+ * Syntax:
+
+        array_var_pop(num_collection)
+
+ * Gets the population variance value of the non-null and non-missing numeric items in the given collection.
+ * Arguments:
+    * `num_collection` could be:
+        * an `array` or `multiset` containing numeric values, `null`s or `missing`s,
+        * or, a `null` value,
+        * or, a `missing` value.
+ * Return Value:
+    * a `double` value representing the population variance of the non-null and non-missing numbers in the given collection,
+    * `null` is returned if the input is `null` or `missing`,
+    * `null` is returned if the given collection does not contain any non-null and non-missing items,
+    * any other non-array and non-multiset input value will cause a type error,
+    * any other non-numeric value in the input collection will cause a type error.
+
+ * Example:
+
+        array_var_pop( [1.2, 2.3, 3.4, 0, null] );
+
+ * The expected result is:
+
+        1.5968749999999998
+
+
 ### strict_count ###
  * Syntax:
 
@@ -359,14 +414,14 @@ SQL++ builtin aggregate functions (e.g., `ARRAY_MIN`, `ARRAY_MAX`,
 
         strict_stddev(num_collection)
 
- * Gets the standard deviation value of the numeric items in the given collection.
+ * Gets the sample standard deviation value of the numeric items in the given collection.
  * Arguments:
     * `num_collection` could be:
         * an `array` or `multiset` containing numeric values, `null`s or `missing`s,
         * or, a `null` value,
         * or, a `missing` value.
  * Return Value:
-    * a `double` value representing the average of the numbers in the given collection,
+    * a `double` value representing the sample standard deviation of the numbers in the given collection,
     * `null` is returned if the input is `null` or `missing`,
     * `null` is returned if there is a `null` or `missing` in the input collection,
     * any other non-numeric value in the input collection will cause a type error.
@@ -384,14 +439,14 @@ SQL++ builtin aggregate functions (e.g., `ARRAY_MIN`, `ARRAY_MAX`,
 
         strict_stddev_pop(num_collection)
 
- * Gets the standard deviation value of the numeric items in the given collection.
+ * Gets the population standard deviation value of the numeric items in the given collection.
  * Arguments:
     * `num_collection` could be:
         * an `array` or `multiset` containing numeric values, `null`s or `missing`s,
         * or, a `null` value,
         * or, a `missing` value.
  * Return Value:
-    * a `double` value representing the average of the numbers in the given collection,
+    * a `double` value representing the population standard deviation of the numbers in the given collection,
     * `null` is returned if the input is `null` or `missing`,
     * `null` is returned if there is a `null` or `missing` in the input collection,
     * any other non-numeric value in the input collection will cause a type error.
@@ -403,3 +458,53 @@ SQL++ builtin aggregate functions (e.g., `ARRAY_MIN`, `ARRAY_MAX`,
  * The expected result is:
 
         81.64965809277261
+
+### strict_var ###
+ * Syntax:
+
+        strict_var(num_collection)
+
+ * Gets the sample variance value of the numeric items in the given collection.
+ * Arguments:
+    * `num_collection` could be:
+        * an `array` or `multiset` containing numeric values, `null`s or `missing`s,
+        * or, a `null` value,
+        * or, a `missing` value.
+ * Return Value:
+    * a `double` value representing the sample variance of the numbers in the given collection,
+    * `null` is returned if the input is `null` or `missing`,
+    * `null` is returned if there is a `null` or `missing` in the input collection,
+    * any other non-numeric value in the input collection will cause a type error.
+
+ * Example:
+
+        strict_var( [100, 200, 300] );
+
+ * The expected result is:
+
+        10000.0
+
+### strict_var_pop ###
+ * Syntax:
+
+        strict_var_pop(num_collection)
+
+ * Gets the population variance value of the numeric items in the given collection.
+ * Arguments:
+    * `num_collection` could be:
+        * an `array` or `multiset` containing numeric values, `null`s or `missing`s,
+        * or, a `null` value,
+        * or, a `missing` value.
+ * Return Value:
+    * a `double` value representing the population variance of the numbers in the given collection,
+    * `null` is returned if the input is `null` or `missing`,
+    * `null` is returned if there is a `null` or `missing` in the input collection,
+    * any other non-numeric value in the input collection will cause a type error.
+
+ * Example:
+
+        strict_var_pop( [100, 200, 300] );
+
+ * The expected result is:
+
+        6666.666666666667