Merge branch 'mad-hatter'

Change-Id: Ida334df2ce4eb59e6c7752b1708d1d4254068c3a
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 ff0badd..03b82fe 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
@@ -21,8 +21,9 @@
 * Expected Res : Failure
 * Date         : Feb 7th 2014
 */
+-- param max-warnings:json=1000
 
 select element array_avg((
     select element x
-    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+    from  [float('2.0'),'hello world',10,date('2013-01-01')] as x
 ));
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double/serial_avg_double.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double/serial_avg_double.1.ddl.sqlpp
index 5dc84e2..da0bd7b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double/serial_avg_double.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double/serial_avg_double.2.update.sqlpp
similarity index 63%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double/serial_avg_double.2.update.sqlpp
index bd244d0..88d820c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double/serial_avg_double.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double/serial_avg_double.3.query.sqlpp
similarity index 89%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double/serial_avg_double.3.query.sqlpp
index bd244d0..c141c2b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double/serial_avg_double.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.val) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double_null/serial_avg_double_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double_null/serial_avg_double_null.1.ddl.sqlpp
index bd244d0..da0bd7b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double_null/serial_avg_double_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double_null/serial_avg_double_null.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double_null/serial_avg_double_null.2.update.sqlpp
index bd244d0..1cff84e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double_null/serial_avg_double_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * under the License.
  */
 
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':double(4.32),'valplus':double(100.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':"str"};
+insert into Test
+select element {'id':3,'gid':1,'val':double(4.32),'valplus':double(200.0)};
+insert into Test
+select element {'id':4,'gid':1,'val':double(4.32),'valplus':null};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double_null/serial_avg_double_null.3.query.sqlpp
similarity index 88%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double_null/serial_avg_double_null.3.query.sqlpp
index bd244d0..acbf607 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_double_null/serial_avg_double_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.valplus) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_empty/serial_avg_empty.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_empty/serial_avg_empty.1.ddl.sqlpp
index 5dc84e2..da0bd7b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_empty/serial_avg_empty.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_empty/serial_avg_empty.2.update.sqlpp
similarity index 99%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_empty/serial_avg_empty.2.update.sqlpp
index bd244d0..042f3ce 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_empty/serial_avg_empty.2.update.sqlpp
@@ -16,4 +16,3 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_empty/serial_avg_empty.3.query.sqlpp
similarity index 89%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_empty/serial_avg_empty.3.query.sqlpp
index bd244d0..c141c2b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_empty/serial_avg_empty.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.val) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float/serial_avg_float.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float/serial_avg_float.1.ddl.sqlpp
index 5dc84e2..ddac6a0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float/serial_avg_float.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float/serial_avg_float.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float/serial_avg_float.2.update.sqlpp
index bd244d0..40641b5 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float/serial_avg_float.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float/serial_avg_float.3.query.sqlpp
similarity index 89%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float/serial_avg_float.3.query.sqlpp
index bd244d0..c141c2b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float/serial_avg_float.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.val) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float_null/serial_avg_float_null.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float_null/serial_avg_float_null.1.ddl.sqlpp
index 5dc84e2..ddac6a0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float_null/serial_avg_float_null.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float_null/serial_avg_float_null.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float_null/serial_avg_float_null.2.update.sqlpp
index bd244d0..40641b5 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float_null/serial_avg_float_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float_null/serial_avg_float_null.3.query.sqlpp
similarity index 88%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float_null/serial_avg_float_null.3.query.sqlpp
index bd244d0..acbf607 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_float_null/serial_avg_float_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.valplus) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16/serial_avg_int16.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16/serial_avg_int16.1.ddl.sqlpp
index bd244d0..0c0bfee 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16/serial_avg_int16.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16/serial_avg_int16.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16/serial_avg_int16.2.update.sqlpp
index bd244d0..6210af4 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16/serial_avg_int16.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16/serial_avg_int16.3.query.sqlpp
similarity index 89%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16/serial_avg_int16.3.query.sqlpp
index bd244d0..c141c2b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16/serial_avg_int16.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.val) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.1.ddl.sqlpp
index bd244d0..0c0bfee 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.2.update.sqlpp
index bd244d0..6210af4 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.3.query.sqlpp
similarity index 88%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.3.query.sqlpp
index bd244d0..acbf607 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.valplus) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32/serial_avg_int32.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32/serial_avg_int32.1.ddl.sqlpp
index bd244d0..07312bf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32/serial_avg_int32.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32/serial_avg_int32.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32/serial_avg_int32.2.update.sqlpp
index bd244d0..a248a0f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32/serial_avg_int32.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32/serial_avg_int32.3.query.sqlpp
similarity index 89%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32/serial_avg_int32.3.query.sqlpp
index bd244d0..c141c2b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32/serial_avg_int32.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.val) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.1.ddl.sqlpp
index bd244d0..07312bf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.2.update.sqlpp
index bd244d0..a248a0f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.3.query.sqlpp
similarity index 88%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.3.query.sqlpp
index bd244d0..acbf607 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.valplus) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64/serial_avg_int64.1.ddl.sqlpp
similarity index 80%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64/serial_avg_int64.1.ddl.sqlpp
index 5dc84e2..5e9972c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64/serial_avg_int64.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64/serial_avg_int64.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64/serial_avg_int64.2.update.sqlpp
index bd244d0..b460af2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64/serial_avg_int64.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64/serial_avg_int64.3.query.sqlpp
similarity index 89%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64/serial_avg_int64.3.query.sqlpp
index bd244d0..c141c2b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64/serial_avg_int64.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.val) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.1.ddl.sqlpp
index bd244d0..5e9972c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.2.update.sqlpp
index bd244d0..b460af2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.3.query.sqlpp
similarity index 88%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.3.query.sqlpp
index bd244d0..acbf607 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.valplus) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8/serial_avg_int8.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8/serial_avg_int8.1.ddl.sqlpp
index bd244d0..c45dbfe 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8/serial_avg_int8.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8/serial_avg_int8.2.update.sqlpp
similarity index 63%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8/serial_avg_int8.2.update.sqlpp
index bd244d0..eb41173 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8/serial_avg_int8.2.update.sqlpp
@@ -17,3 +17,15 @@
  * under the License.
  */
 
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':tinyint('100'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':1,'gid':1,'val':tinyint('100')};
+insert into Test
+select element {'id':2,'gid':1,'val':tinyint('90'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':3,'gid':1,'val':tinyint('40'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':4,'gid':1,'val':tinyint('40'),'valplus':null};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8/serial_avg_int8.3.query.sqlpp
similarity index 89%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8/serial_avg_int8.3.query.sqlpp
index bd244d0..c141c2b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8/serial_avg_int8.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.val) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.1.ddl.sqlpp
index bd244d0..c45dbfe 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.2.update.sqlpp
similarity index 63%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.2.update.sqlpp
index bd244d0..eb41173 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * under the License.
  */
 
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':tinyint('100'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':1,'gid':1,'val':tinyint('100')};
+insert into Test
+select element {'id':2,'gid':1,'val':tinyint('90'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':3,'gid':1,'val':tinyint('40'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':4,'gid':1,'val':tinyint('40'),'valplus':null};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.3.query.sqlpp
similarity index 88%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.3.query.sqlpp
index bd244d0..acbf607 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, avg(t.valplus) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_mixed/serial_avg_mixed.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_mixed/serial_avg_mixed.1.ddl.sqlpp
index 5dc84e2..da0bd7b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_mixed/serial_avg_mixed.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_mixed/serial_avg_mixed.2.update.sqlpp
similarity index 69%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_mixed/serial_avg_mixed.2.update.sqlpp
index bd244d0..8c0b731 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_mixed/serial_avg_mixed.2.update.sqlpp
@@ -17,3 +17,13 @@
  * 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')};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_mixed/serial_avg_mixed.3.query.sqlpp
similarity index 70%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_mixed/serial_avg_mixed.3.query.sqlpp
index bd244d0..dcb6501 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/serial_avg_mixed/serial_avg_mixed.3.query.sqlpp
@@ -16,4 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+ /*
+ * Description  : Run serial-sum over an ordered list with mixed types
+ * Expected Res : Failure
+ * Date         : March 5th 2018
+ */
 
+-- param max-warnings:json=1000
+
+use test;
+
+select gid, array_avg((select value g.valplus from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid 
+group as g(valplus as valplus);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.1.ddl.sqlpp
deleted file mode 100644
index 095f14e..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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 avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Jun 2nd 2013
-*/
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.2.update.sqlpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
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 d07bdc8..5e6596c 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
@@ -21,6 +21,7 @@
 * Expected Res : Failure
 * Date         : Jun 2nd 2013
 */
+-- param max-warnings:json=1000
 
 select element strict_avg((
     select element x
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double/serial_avg_double.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double/serial_avg_double.1.ddl.sqlpp
index 5dc84e2..da0bd7b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double/serial_avg_double.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double/serial_avg_double.2.update.sqlpp
similarity index 63%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double/serial_avg_double.2.update.sqlpp
index bd244d0..88d820c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double/serial_avg_double.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double/serial_avg_double.3.query.sqlpp
similarity index 84%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double/serial_avg_double.3.query.sqlpp
index bd244d0..09c3106 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double/serial_avg_double.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.val from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double_null/serial_avg_double_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double_null/serial_avg_double_null.1.ddl.sqlpp
index bd244d0..da0bd7b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double_null/serial_avg_double_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double_null/serial_avg_double_null.2.update.sqlpp
similarity index 63%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double_null/serial_avg_double_null.2.update.sqlpp
index bd244d0..88d820c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double_null/serial_avg_double_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double_null/serial_avg_double_null.3.query.sqlpp
similarity index 83%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double_null/serial_avg_double_null.3.query.sqlpp
index bd244d0..35ff90f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_double_null/serial_avg_double_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.valplus from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_empty/serial_avg_empty.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_empty/serial_avg_empty.1.ddl.sqlpp
index 5dc84e2..da0bd7b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_empty/serial_avg_empty.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_empty/serial_avg_empty.2.update.sqlpp
similarity index 99%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_empty/serial_avg_empty.2.update.sqlpp
index bd244d0..042f3ce 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_empty/serial_avg_empty.2.update.sqlpp
@@ -16,4 +16,3 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_empty/serial_avg_empty.3.query.sqlpp
similarity index 84%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_empty/serial_avg_empty.3.query.sqlpp
index bd244d0..09c3106 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_empty/serial_avg_empty.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.val from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float/serial_avg_float.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float/serial_avg_float.1.ddl.sqlpp
index 5dc84e2..ddac6a0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float/serial_avg_float.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float/serial_avg_float.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float/serial_avg_float.2.update.sqlpp
index bd244d0..40641b5 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float/serial_avg_float.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float/serial_avg_float.3.query.sqlpp
similarity index 84%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float/serial_avg_float.3.query.sqlpp
index bd244d0..09c3106 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float/serial_avg_float.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.val from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float_null/serial_avg_float_null.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float_null/serial_avg_float_null.1.ddl.sqlpp
index 5dc84e2..ddac6a0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float_null/serial_avg_float_null.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float_null/serial_avg_float_null.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float_null/serial_avg_float_null.2.update.sqlpp
index bd244d0..40641b5 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float_null/serial_avg_float_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float_null/serial_avg_float_null.3.query.sqlpp
similarity index 83%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float_null/serial_avg_float_null.3.query.sqlpp
index bd244d0..35ff90f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_float_null/serial_avg_float_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.valplus from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16/serial_avg_int16.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16/serial_avg_int16.1.ddl.sqlpp
index bd244d0..0c0bfee 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16/serial_avg_int16.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16/serial_avg_int16.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16/serial_avg_int16.2.update.sqlpp
index bd244d0..6210af4 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16/serial_avg_int16.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16/serial_avg_int16.3.query.sqlpp
similarity index 84%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16/serial_avg_int16.3.query.sqlpp
index bd244d0..09c3106 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16/serial_avg_int16.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.val from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16_null/serial_avg_int16_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16_null/serial_avg_int16_null.1.ddl.sqlpp
index bd244d0..0c0bfee 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16_null/serial_avg_int16_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16_null/serial_avg_int16_null.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16_null/serial_avg_int16_null.2.update.sqlpp
index bd244d0..6210af4 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16_null/serial_avg_int16_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16_null/serial_avg_int16_null.3.query.sqlpp
similarity index 83%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16_null/serial_avg_int16_null.3.query.sqlpp
index bd244d0..35ff90f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int16_null/serial_avg_int16_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.valplus from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32/serial_avg_int32.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32/serial_avg_int32.1.ddl.sqlpp
index bd244d0..07312bf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32/serial_avg_int32.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32/serial_avg_int32.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32/serial_avg_int32.2.update.sqlpp
index bd244d0..a248a0f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32/serial_avg_int32.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32/serial_avg_int32.3.query.sqlpp
similarity index 84%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32/serial_avg_int32.3.query.sqlpp
index bd244d0..09c3106 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32/serial_avg_int32.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.val from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32_null/serial_avg_int32_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32_null/serial_avg_int32_null.1.ddl.sqlpp
index bd244d0..07312bf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32_null/serial_avg_int32_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32_null/serial_avg_int32_null.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32_null/serial_avg_int32_null.2.update.sqlpp
index bd244d0..a248a0f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32_null/serial_avg_int32_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32_null/serial_avg_int32_null.3.query.sqlpp
similarity index 83%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32_null/serial_avg_int32_null.3.query.sqlpp
index bd244d0..35ff90f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int32_null/serial_avg_int32_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.valplus from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64/serial_avg_int64.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64/serial_avg_int64.1.ddl.sqlpp
index 5dc84e2..5e9972c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64/serial_avg_int64.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64/serial_avg_int64.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64/serial_avg_int64.2.update.sqlpp
index bd244d0..b460af2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64/serial_avg_int64.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64/serial_avg_int64.3.query.sqlpp
similarity index 84%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64/serial_avg_int64.3.query.sqlpp
index bd244d0..09c3106 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64/serial_avg_int64.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.val from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64_null/serial_avg_int64_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64_null/serial_avg_int64_null.1.ddl.sqlpp
index bd244d0..5e9972c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64_null/serial_avg_int64_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64_null/serial_avg_int64_null.2.update.sqlpp
similarity index 64%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64_null/serial_avg_int64_null.2.update.sqlpp
index bd244d0..b460af2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64_null/serial_avg_int64_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * 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};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64_null/serial_avg_int64_null.3.query.sqlpp
similarity index 83%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64_null/serial_avg_int64_null.3.query.sqlpp
index bd244d0..35ff90f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int64_null/serial_avg_int64_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.valplus from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8/serial_avg_int8.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8/serial_avg_int8.1.ddl.sqlpp
index bd244d0..c45dbfe 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8/serial_avg_int8.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8/serial_avg_int8.2.update.sqlpp
similarity index 63%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8/serial_avg_int8.2.update.sqlpp
index bd244d0..eb41173 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8/serial_avg_int8.2.update.sqlpp
@@ -17,3 +17,15 @@
  * under the License.
  */
 
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':tinyint('100'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':1,'gid':1,'val':tinyint('100')};
+insert into Test
+select element {'id':2,'gid':1,'val':tinyint('90'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':3,'gid':1,'val':tinyint('40'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':4,'gid':1,'val':tinyint('40'),'valplus':null};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8/serial_avg_int8.3.query.sqlpp
similarity index 84%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8/serial_avg_int8.3.query.sqlpp
index bd244d0..09c3106 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8/serial_avg_int8.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.val from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(val as val);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8_null/serial_avg_int8_null.1.ddl.sqlpp
similarity index 79%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8_null/serial_avg_int8_null.1.ddl.sqlpp
index bd244d0..c45dbfe 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8_null/serial_avg_int8_null.1.ddl.sqlpp
@@ -17,3 +17,17 @@
  * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8_null/serial_avg_int8_null.2.update.sqlpp
similarity index 63%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8_null/serial_avg_int8_null.2.update.sqlpp
index bd244d0..eb41173 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8_null/serial_avg_int8_null.2.update.sqlpp
@@ -17,3 +17,15 @@
  * under the License.
  */
 
+use test;
+
+insert into Test
+select element {'id':0,'gid':1,'val':tinyint('100'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':1,'gid':1,'val':tinyint('100')};
+insert into Test
+select element {'id':2,'gid':1,'val':tinyint('90'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':3,'gid':1,'val':tinyint('40'),'valplus':tinyint('100')};
+insert into Test
+select element {'id':4,'gid':1,'val':tinyint('40'),'valplus':null};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8_null/serial_avg_int8_null.3.query.sqlpp
similarity index 83%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8_null/serial_avg_int8_null.3.query.sqlpp
index bd244d0..35ff90f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_int8_null/serial_avg_int8_null.3.query.sqlpp
@@ -17,3 +17,9 @@
  * under the License.
  */
 
+use test;
+
+select gid, strict_avg((select value g.valplus from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_mixed/serial_avg_mixed.1.ddl.sqlpp
similarity index 80%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_mixed/serial_avg_mixed.1.ddl.sqlpp
index 5dc84e2..da0bd7b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_mixed/serial_avg_mixed.1.ddl.sqlpp
@@ -16,9 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-/*
-* Description  : Run array_avg over an ordered list with mixed types
-* Expected Res : Failure
-* Date         : Feb 7th 2014
-*/
 
+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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_mixed/serial_avg_mixed.2.update.sqlpp
similarity index 67%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_mixed/serial_avg_mixed.2.update.sqlpp
index bd244d0..02788ca 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_mixed/serial_avg_mixed.2.update.sqlpp
@@ -17,3 +17,13 @@
  * 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':int32("15")};
+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')};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_mixed/serial_avg_mixed.3.query.sqlpp
similarity index 70%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_mixed/serial_avg_mixed.3.query.sqlpp
index bd244d0..e48d5b8 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/serial_avg_mixed/serial_avg_mixed.3.query.sqlpp
@@ -16,4 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+ /*
+ * Description  : Run serial-sum over an ordered list with mixed types
+ * Expected Res : Failure
+ * Date         : March 5th 2018
+ */
 
+-- param max-warnings:json=1000
+
+use test;
+
+select gid, strict_avg((select value g.valplus from g)) as avg
+from Test as t
+/* +hash */
+group by t.gid as gid group as g(valplus as valplus);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/avg_mixed/avg_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/avg_mixed/avg_mixed.1.adm
index e3b97f5..e0ea36f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/avg_mixed/avg_mixed.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/avg_mixed/avg_mixed.1.adm
@@ -1 +1 @@
-[  ]
+6.0
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_double/serial_avg_double.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_double/serial_avg_double.1.adm
new file mode 100644
index 0000000..7e08e77
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_double/serial_avg_double.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.92 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_double_null/serial_avg_double_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_double_null/serial_avg_double_null.1.adm
new file mode 100644
index 0000000..877de08
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_double_null/serial_avg_double_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 150.0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_empty/serial_sum_empty.1.adm
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.1.ast
rename to asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_empty/serial_sum_empty.1.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_float/serial_avg_float.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_float/serial_avg_float.1.adm
new file mode 100644
index 0000000..7e08e77
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_float/serial_avg_float.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.92 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_float_null/serial_avg_float_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_float_null/serial_avg_float_null.1.adm
new file mode 100644
index 0000000..47ebaaa
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_float_null/serial_avg_float_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 2.0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int16/serial_avg_int16.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int16/serial_avg_int16.1.adm
new file mode 100644
index 0000000..821af2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int16/serial_avg_int16.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.6 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.1.adm
new file mode 100644
index 0000000..47ebaaa
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int16_null/serial_avg_int16_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 2.0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int32/serial_avg_int32.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int32/serial_avg_int32.1.adm
new file mode 100644
index 0000000..821af2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int32/serial_avg_int32.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.6 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.1.adm
new file mode 100644
index 0000000..47ebaaa
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int32_null/serial_avg_int32_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 2.0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int64/serial_avg_int64.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int64/serial_avg_int64.1.adm
new file mode 100644
index 0000000..821af2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int64/serial_avg_int64.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.6 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.1.adm
new file mode 100644
index 0000000..47ebaaa
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int64_null/serial_avg_int64_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 2.0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int8/serial_avg_int8.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int8/serial_avg_int8.1.adm
new file mode 100644
index 0000000..8e23c3e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int8/serial_avg_int8.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 74.0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.1.adm
new file mode 100644
index 0000000..4c81aef
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_int8_null/serial_avg_int8_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 100.0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_mixed/serial_avg_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_mixed/serial_avg_mixed.1.adm
new file mode 100644
index 0000000..9d306b7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/serial_avg_mixed/serial_avg_mixed.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 2.5 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/avg_mixed/avg_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/avg_mixed/avg_mixed.1.adm
index e3b97f5..19765bd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/avg_mixed/avg_mixed.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/avg_mixed/avg_mixed.1.adm
@@ -1 +1 @@
-[  ]
+null
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_double/serial_avg_double.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_double/serial_avg_double.1.adm
new file mode 100644
index 0000000..7e08e77
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_double/serial_avg_double.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.92 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_double_null/serial_avg_double_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_double_null/serial_avg_double_null.1.adm
new file mode 100644
index 0000000..40a0b73
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_double_null/serial_avg_double_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_empty/serial_sum_empty.1.adm
similarity index 100%
copy from asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.1.ast
copy to asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_empty/serial_sum_empty.1.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_float/serial_avg_float.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_float/serial_avg_float.1.adm
new file mode 100644
index 0000000..7e08e77
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_float/serial_avg_float.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.92 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_float_null/serial_avg_float_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_float_null/serial_avg_float_null.1.adm
new file mode 100644
index 0000000..40a0b73
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_float_null/serial_avg_float_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int16/serial_avg_int16.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int16/serial_avg_int16.1.adm
new file mode 100644
index 0000000..821af2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int16/serial_avg_int16.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.6 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int16_null/serial_avg_int16_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int16_null/serial_avg_int16_null.1.adm
new file mode 100644
index 0000000..40a0b73
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int16_null/serial_avg_int16_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int32/serial_avg_int32.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int32/serial_avg_int32.1.adm
new file mode 100644
index 0000000..821af2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int32/serial_avg_int32.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.6 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int32_null/serial_avg_int32_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int32_null/serial_avg_int32_null.1.adm
new file mode 100644
index 0000000..40a0b73
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int32_null/serial_avg_int32_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int64/serial_avg_int64.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int64/serial_avg_int64.1.adm
new file mode 100644
index 0000000..821af2f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int64/serial_avg_int64.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 4.6 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int64_null/serial_avg_int64_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int64_null/serial_avg_int64_null.1.adm
new file mode 100644
index 0000000..40a0b73
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int64_null/serial_avg_int64_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int8/serial_avg_int8.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int8/serial_avg_int8.1.adm
new file mode 100644
index 0000000..8e23c3e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int8/serial_avg_int8.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": 74.0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int8_null/serial_avg_int8_null.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int8_null/serial_avg_int8_null.1.adm
new file mode 100644
index 0000000..40a0b73
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_int8_null/serial_avg_int8_null.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_mixed/serial_avg_mixed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_mixed/serial_avg_mixed.1.adm
new file mode 100644
index 0000000..40a0b73
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/serial_avg_mixed/serial_avg_mixed.1.adm
@@ -0,0 +1 @@
+{ "gid": 1, "avg": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ast
deleted file mode 100644
index e69de29..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ast
+++ /dev/null
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.ast
deleted file mode 100644
index e69de29..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.ast
+++ /dev/null
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.ast
index 034df11..7fac994 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.ast
@@ -10,7 +10,7 @@
           LiteralExpr [STRING] [2.0]
         ]
         LiteralExpr [STRING] [hello world]
-        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [10]
         FunctionCall null.date@1[
           LiteralExpr [STRING] [2013-01-01]
         ]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.2.ast
deleted file mode 100644
index e69de29..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.2.ast
+++ /dev/null
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 cc2cd24..5ef5808 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -303,10 +303,16 @@
         <output-dir compare="Text">agg_number_rec</output-dir>
       </compilation-unit>
     </test-case>
-    <test-case FilePath="aggregate">
+    <test-case FilePath="aggregate" check-warnings="true">
       <compilation-unit name="avg_mixed">
         <output-dir compare="Text">avg_mixed</output-dir>
-        <expected-error>Type incompatibility: function agg-avg gets incompatible input values: string and float</expected-error>
+        <expected-warn>Unsupported type: agg-avg cannot process input type string (in line 26, at column 16)</expected-warn>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate" check-warnings="true">
+      <compilation-unit name="serial_avg_mixed">
+        <output-dir compare="Text">serial_avg_mixed</output-dir>
+        <expected-warn>Unsupported type: agg-avg cannot process input type string (in line 29, at column 39)</expected-warn>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
@@ -789,6 +795,71 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_empty">
+        <output-dir compare="Text">serial_avg_empty</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_int8">
+        <output-dir compare="Text">serial_avg_int8</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_int8_null">
+        <output-dir compare="Text">serial_avg_int8_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_int16">
+        <output-dir compare="Text">serial_avg_int16</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_int16_null">
+        <output-dir compare="Text">serial_avg_int16_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_int32">
+        <output-dir compare="Text">serial_avg_int32</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_int32_null">
+        <output-dir compare="Text">serial_avg_int32_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_int64">
+        <output-dir compare="Text">serial_avg_int64</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_int64_null">
+        <output-dir compare="Text">serial_avg_int64_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_float">
+        <output-dir compare="Text">serial_avg_float</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_float_null">
+        <output-dir compare="Text">serial_avg_float_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_double">
+        <output-dir compare="Text">serial_avg_double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
+      <compilation-unit name="serial_avg_double_null">
+        <output-dir compare="Text">serial_avg_double_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate">
       <compilation-unit name="serial_kurtosis_double">
         <output-dir compare="Text">serial_kurtosis_double</output-dir>
       </compilation-unit>
@@ -1497,10 +1568,16 @@
         <output-dir compare="Text">agg_number_rec</output-dir>
       </compilation-unit>
     </test-case>
-    <test-case FilePath="aggregate-sql">
+    <test-case FilePath="aggregate-sql" check-warnings="true">
       <compilation-unit name="avg_mixed">
         <output-dir compare="Text">avg_mixed</output-dir>
-        <expected-error>Type incompatibility: function agg-avg gets incompatible input values: string and float</expected-error>
+        <expected-warn>Unsupported type: agg-avg cannot process input type string (in line 26, at column 16)</expected-warn>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql" check-warnings="true">
+      <compilation-unit name="serial_avg_mixed">
+        <output-dir compare="Text">serial_avg_mixed</output-dir>
+        <expected-warn>Unsupported type: agg-avg cannot process input type string (in line 29, at column 38)</expected-warn>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
@@ -1981,6 +2058,71 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_empty">
+        <output-dir compare="Text">serial_avg_empty</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_int8">
+        <output-dir compare="Text">serial_avg_int8</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_int8_null">
+        <output-dir compare="Text">serial_avg_int8_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_int16">
+        <output-dir compare="Text">serial_avg_int16</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_int16_null">
+        <output-dir compare="Text">serial_avg_int16_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_int32">
+        <output-dir compare="Text">serial_avg_int32</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_int32_null">
+        <output-dir compare="Text">serial_avg_int32_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_int64">
+        <output-dir compare="Text">serial_avg_int64</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_int64_null">
+        <output-dir compare="Text">serial_avg_int64_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_float">
+        <output-dir compare="Text">serial_avg_float</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_float_null">
+        <output-dir compare="Text">serial_avg_float_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_double">
+        <output-dir compare="Text">serial_avg_double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
+      <compilation-unit name="serial_avg_double_null">
+        <output-dir compare="Text">serial_avg_double_null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql">
       <compilation-unit name="serial_kurtosis_double">
         <output-dir compare="Text">serial_kurtosis_double</output-dir>
       </compilation-unit>
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/ICoordinationService.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/ICoordinationService.java
index 2019da9..5d2ef07 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/ICoordinationService.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/ICoordinationService.java
@@ -35,6 +35,18 @@
     void put(String key, byte[] value) throws HyracksDataException;
 
     /**
+     * Adds or updates the property with the name {@code key}
+     * with {@code value}, and indicates that values associated with
+     * this key should be treated as sensitive (e.g. not logged). Once a
+     * key is considered sensitive, it remains sensitive until deleted.
+     *
+     * @param key
+     * @param value
+     * @throws HyracksDataException
+     */
+    void putSensitive(String key, byte[] value) throws HyracksDataException;
+
+    /**
      * Gets the value of the property with name {@code key} if exists.
      *
      * @param key
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableAvgAggregateFunction.java
index f77e6c4..bf8698d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableAvgAggregateFunction.java
@@ -35,6 +35,7 @@
 import org.apache.asterix.om.base.AMutableDouble;
 import org.apache.asterix.om.base.AMutableInt64;
 import org.apache.asterix.om.base.ANull;
+import org.apache.asterix.om.exceptions.ExceptionUtil;
 import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
@@ -44,8 +45,8 @@
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 import org.apache.asterix.runtime.evaluators.common.AccessibleByteArrayEval;
 import org.apache.asterix.runtime.evaluators.common.ClosedRecordConstructorEvalFactory.ClosedRecordConstructorEval;
-import org.apache.asterix.runtime.exceptions.IncompatibleTypeException;
 import org.apache.asterix.runtime.exceptions.UnsupportedItemTypeException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IEvaluatorContext;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -65,6 +66,11 @@
     private static final int COUNT_OFFSET = 8;
     protected static final int AGG_TYPE_OFFSET = 16;
 
+    private final IEvaluatorContext context;
+
+    // Warning flag to warn only once in case of non-numeric data
+    private boolean isWarned;
+
     private IPointable inputVal = new VoidPointable();
     private IScalarEvaluator eval;
     private AMutableDouble aDouble = new AMutableDouble(0);
@@ -92,6 +98,7 @@
     public AbstractSerializableAvgAggregateFunction(IScalarEvaluatorFactory[] args, IEvaluatorContext context,
             SourceLocation sourceLoc) throws HyracksDataException {
         super(sourceLoc);
+        this.context = context;
         eval = args[0].createScalarEvaluator(context);
     }
 
@@ -101,6 +108,7 @@
             state.writeDouble(0.0);
             state.writeLong(0);
             state.writeByte(ATypeTag.SERIALIZED_SYSTEM_NULL_TYPE_TAG);
+            isWarned = false;
         } catch (IOException e) {
             throw HyracksDataException.create(e);
         }
@@ -136,17 +144,16 @@
         } else if (aggType == ATypeTag.SYSTEM_NULL) {
             aggType = typeTag;
         } else if (typeTag != ATypeTag.SYSTEM_NULL && !ATypeHierarchy.isCompatible(typeTag, aggType)) {
-            if (typeTag.ordinal() > aggType.ordinal()) {
-                throw new IncompatibleTypeException(sourceLoc, BuiltinFunctions.AVG, bytes[offset],
-                        aggType.serialize());
-            } else {
-                throw new IncompatibleTypeException(sourceLoc, BuiltinFunctions.AVG, aggType.serialize(),
-                        bytes[offset]);
+            // Issue warning only once and treat current tuple as null
+            if (!isWarned) {
+                isWarned = true;
+                ExceptionUtil.warnUnsupportedType(context, sourceLoc, getIdentifier().getName(), typeTag);
             }
+            processNull(state, start);
+            return;
         } else if (ATypeHierarchy.canPromote(aggType, typeTag)) {
             aggType = typeTag;
         }
-        ++count;
         switch (typeTag) {
             case TINYINT: {
                 byte val = AInt8SerializerDeserializer.getByte(bytes, offset + 1);
@@ -179,8 +186,15 @@
                 break;
             }
             default:
-                throw new UnsupportedItemTypeException(sourceLoc, BuiltinFunctions.AVG, bytes[offset]);
+                // Issue warning only once and treat current tuple as null
+                if (!isWarned) {
+                    isWarned = true;
+                    ExceptionUtil.warnUnsupportedType(context, sourceLoc, getIdentifier().getName(), typeTag);
+                }
+                processNull(state, start);
+                return;
         }
+        count++;
         BufferSerDeUtil.writeDouble(sum, state, start + SUM_OFFSET);
         BufferSerDeUtil.writeLong(count, state, start + COUNT_OFFSET);
         state[start + AGG_TYPE_OFFSET] = aggType.serialize();
@@ -279,4 +293,8 @@
         return false;
     }
 
+    // Function identifier
+    private FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.AVG;
+    }
 }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractAvgAggregateFunction.java
index 29719ad..d2367f9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractAvgAggregateFunction.java
@@ -35,6 +35,7 @@
 import org.apache.asterix.om.base.AMutableDouble;
 import org.apache.asterix.om.base.AMutableInt64;
 import org.apache.asterix.om.base.ANull;
+import org.apache.asterix.om.exceptions.ExceptionUtil;
 import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
@@ -44,8 +45,8 @@
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 import org.apache.asterix.runtime.evaluators.common.AccessibleByteArrayEval;
 import org.apache.asterix.runtime.evaluators.common.ClosedRecordConstructorEvalFactory.ClosedRecordConstructorEval;
-import org.apache.asterix.runtime.exceptions.IncompatibleTypeException;
 import org.apache.asterix.runtime.exceptions.UnsupportedItemTypeException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IEvaluatorContext;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -62,6 +63,11 @@
     private static final int SUM_FIELD_ID = 0;
     private static final int COUNT_FIELD_ID = 1;
 
+    private final IEvaluatorContext context;
+
+    // Warning flag to warn only once in case of non-numeric data
+    private boolean isWarned;
+
     private final ARecordType recType;
 
     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -95,6 +101,7 @@
     public AbstractAvgAggregateFunction(IScalarEvaluatorFactory[] args, IEvaluatorContext context,
             SourceLocation sourceLoc) throws HyracksDataException {
         super(sourceLoc);
+        this.context = context;
         eval = args[0].createScalarEvaluator(context);
         recType = new ARecordType(null, new String[] { "sum", "count" },
                 new IAType[] { BuiltinType.ADOUBLE, BuiltinType.AINT64 }, false);
@@ -106,6 +113,7 @@
         aggType = ATypeTag.SYSTEM_NULL;
         sum = 0.0;
         count = 0;
+        isWarned = false;
     }
 
     @Override
@@ -134,15 +142,17 @@
         } else if (aggType == ATypeTag.SYSTEM_NULL) {
             aggType = typeTag;
         } else if (typeTag != ATypeTag.SYSTEM_NULL && !ATypeHierarchy.isCompatible(typeTag, aggType)) {
-            if (typeTag.ordinal() > aggType.ordinal()) {
-                throw new IncompatibleTypeException(sourceLoc, BuiltinFunctions.AVG, data[offset], aggType.serialize());
-            } else {
-                throw new IncompatibleTypeException(sourceLoc, BuiltinFunctions.AVG, aggType.serialize(), data[offset]);
+            // Issue warning only once and treat current tuple as null
+            if (!isWarned) {
+                isWarned = true;
+                ExceptionUtil.warnUnsupportedType(context, sourceLoc, getIdentifier().getName(), typeTag);
             }
+            processNull();
+            return;
         } else if (ATypeHierarchy.canPromote(aggType, typeTag)) {
             aggType = typeTag;
         }
-        ++count;
+
         switch (typeTag) {
             case TINYINT: {
                 byte val = AInt8SerializerDeserializer.getByte(data, offset + 1);
@@ -175,9 +185,16 @@
                 break;
             }
             default: {
-                throw new UnsupportedItemTypeException(sourceLoc, BuiltinFunctions.AVG, data[offset]);
+                // Issue warning only once and treat current tuple as null
+                if (!isWarned) {
+                    isWarned = true;
+                    ExceptionUtil.warnUnsupportedType(context, sourceLoc, getIdentifier().getName(), typeTag);
+                }
+                processNull();
+                return;
             }
         }
+        count++;
     }
 
     protected void finishPartialResults(IPointable result) throws HyracksDataException {
@@ -259,4 +276,8 @@
         return false;
     }
 
+    // Function identifier
+    private FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.AVG;
+    }
 }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/NoOpCoordinationService.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/NoOpCoordinationService.java
index 6f9a8d2..3cbaed4 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/NoOpCoordinationService.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/NoOpCoordinationService.java
@@ -35,6 +35,11 @@
     }
 
     @Override
+    public void putSensitive(String key, byte[] value) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
     public Optional<byte[]> get(String key) {
         throw new UnsupportedOperationException();
     }