Tests : sum() of numeric values with and without nulls
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@546 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred.aql
new file mode 100644
index 0000000..10e952c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_null-with-pred.aql
@@ -0,0 +1,30 @@
+/*
+ * Description : sum() aggregate function must return the numeric sum, when non null values are given as input to sum().
+ * : Get the sum for those tuples which are non null for salary fields.
+ * Expected result : Success
+ * Date : July 20th 2012
+ */
+
+write output to nc1:"rttest/aggregate_sum_null-with-pred.adm";
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+id:int32,
+sal:int32?
+}
+
+create dataset tdst(TestType) partitioned by key id;
+
+insert into dataset tdst({"id":123,"sal":1000});
+insert into dataset tdst({"id":113,"sal":2000});
+insert into dataset tdst({"id":163,"sal":3000});
+insert into dataset tdst({"id":161,"sal":4000});
+insert into dataset tdst({"id":173,"sal":5000});
+insert into dataset tdst({"id":183,"sal":null});
+
+sum(for $l in dataset('tdst')
+where not(is-null($l.sal))
+return $l.sal)
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_numeric_null.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_numeric_null.aql
new file mode 100644
index 0000000..9197e33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_numeric_null.aql
@@ -0,0 +1,31 @@
+/*
+ * Description : Add numeric values with a null value, sum() aggregate function must return null.
+ * Expected result : Success
+ * Date : July 20th 2012
+ */
+
+write output to nc1:"rttest/aggregate_sum_numeric_null.adm";
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+id:int32,
+sal:int32?
+}
+
+create dataset tdst(TestType) partitioned by key id;
+
+// In AQL
+// sum(numeric + null) => null
+
+insert into dataset tdst({"id":123,"sal":345});
+insert into dataset tdst({"id":113,"sal":335});
+insert into dataset tdst({"id":163,"sal":315});
+insert into dataset tdst({"id":161,"sal":365});
+insert into dataset tdst({"id":173,"sal":385});
+insert into dataset tdst({"id":183,"sal":null});
+
+sum(for $l in dataset('tdst')
+return $l.sal)
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/sum_null-with-pred.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/sum_null-with-pred.adm
new file mode 100644
index 0000000..9e70369
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/sum_null-with-pred.adm
@@ -0,0 +1 @@
+15000
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/sum_numeric_null.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/sum_numeric_null.adm
new file mode 100644
index 0000000..19765bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/sum_numeric_null.adm
@@ -0,0 +1 @@
+null