merged asterix_stabilization r620:1109

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_temporal_functionality@1113 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_01.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_01.aql
new file mode 100644
index 0000000..ab2a6fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_01.aql
@@ -0,0 +1,17 @@
+/*
+ * Description    : Tests that avg aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_avg_empty_01.adm";
+
+avg(
+ for $x in [1, 2, 3]
+ where $x > 10
+ return $x
+)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_02.aql
new file mode 100644
index 0000000..3583ce0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_empty_02.aql
@@ -0,0 +1,23 @@
+/*
+ * Description    : Tests that avg aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as closed {
+  id: int32,
+  val: double
+}
+
+create dataset Test(TestType) partitioned by key id;
+
+write output to nc1:"rttest/aggregate_avg_empty_02.adm";
+
+avg(
+ for $x in dataset('Test')
+ return $x.val
+)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_01.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_01.aql
new file mode 100644
index 0000000..f03c252
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_01.aql
@@ -0,0 +1,17 @@
+/*
+ * Description    : Tests that count aggregation correctly returns 0 for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_count_empty_01.adm";
+
+count(
+ for $x in [1, 2, 3]
+ where $x > 10
+ return $x
+)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_02.aql
new file mode 100644
index 0000000..0a6cc8e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/count_empty_02.aql
@@ -0,0 +1,23 @@
+/*
+ * Description    : Tests that count aggregation correctly returns 0 for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as closed {
+  id: int32,
+  val: double
+}
+
+create dataset Test(TestType) partitioned by key id;
+
+write output to nc1:"rttest/aggregate_count_empty_02.adm";
+
+count(
+ for $x in dataset('Test')
+ return $x.val
+)
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/droptype.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/droptype.aql
new file mode 100644
index 0000000..dd0c342
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/droptype.aql
@@ -0,0 +1,22 @@
+/*
+ * Description  : Test to cover =>  create type - drop type - recreate that dropped type 
+ * Expected Res : Success
+ * Date         : 13 Sep 2012
+ * Issue        : 188
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_droptype.adm";
+
+create type footype as open {
+bar : int32?
+}
+
+drop type footype;
+
+create type footype as open {
+bar : int32?
+}
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_01.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_01.aql
new file mode 100644
index 0000000..2464b64
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_01.aql
@@ -0,0 +1,17 @@
+/*
+ * Description    : Tests that max aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_max_empty_01.adm";
+
+max(
+ for $x in [1, 2, 3]
+ where $x > 10
+ return $x
+)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_02.aql
new file mode 100644
index 0000000..79ae1d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/max_empty_02.aql
@@ -0,0 +1,23 @@
+/*
+ * Description    : Tests that max aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as closed {
+  id: int32,
+  val: double
+}
+
+create dataset Test(TestType) partitioned by key id;
+
+write output to nc1:"rttest/aggregate_max_empty_02.adm";
+
+max(
+ for $x in dataset('Test')
+ return $x.val
+)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_01.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_01.aql
new file mode 100644
index 0000000..30abd1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_01.aql
@@ -0,0 +1,17 @@
+/*
+ * Description    : Tests that min aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_min_empty_01.adm";
+
+min(
+ for $x in [1, 2, 3]
+ where $x > 10
+ return $x
+)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_02.aql
new file mode 100644
index 0000000..99d49f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_empty_02.aql
@@ -0,0 +1,23 @@
+/*
+ * Description    : Tests that min aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as closed {
+  id: int32,
+  val: double
+}
+
+create dataset Test(TestType) partitioned by key id;
+
+write output to nc1:"rttest/aggregate_min_empty_02.adm";
+
+min(
+ for $x in dataset('Test')
+ return $x.val
+)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_avg.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_avg.aql
new file mode 100644
index 0000000..8c8ed73
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_avg.aql
@@ -0,0 +1,19 @@
+/*
+ * Description    : Tests the scalar version of avg without nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_avg.adm";
+
+let $i8 := avg([int8("1"), int8("2"), int8("3")])
+let $i16 := avg([int16("1"), int16("2"), int16("3")])
+let $i32 := avg([int32("1"), int32("2"), int32("3")])
+let $i64 := avg([int64("1"), int64("2"), int64("3")])
+let $f := avg([float("1"), float("2"), float("3")])
+let $d := avg([double("1"), double("2"), double("3")])
+for $i in [$i8, $i16, $i32, $i64, $f, $d]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_avg_empty.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_avg_empty.aql
new file mode 100644
index 0000000..351f5f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_avg_empty.aql
@@ -0,0 +1,12 @@
+/*
+ * Description    : Tests the scalar version of avg with an empty list.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_avg_empty.adm";
+
+avg([ ])
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_avg_null.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_avg_null.aql
new file mode 100644
index 0000000..5108573
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_avg_null.aql
@@ -0,0 +1,19 @@
+/*
+ * Description    : Tests the scalar version of avg with nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_avg_null.adm";
+
+let $i8 := avg([int8("1"), int8("2"), int8("3"), null])
+let $i16 := avg([int16("1"), int16("2"), int16("3"), null])
+let $i32 := avg([int32("1"), int32("2"), int32("3"), null])
+let $i64 := avg([int64("1"), int64("2"), int64("3"), null])
+let $f := avg([float("1"), float("2"), float("3"), null])
+let $d := avg([double("1"), double("2"), double("3"), null])
+for $i in [$i8, $i16, $i32, $i64, $f, $d]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_count.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_count.aql
new file mode 100644
index 0000000..3508fc6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_count.aql
@@ -0,0 +1,20 @@
+/*
+ * Description    : Tests the scalar version of count without nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_count.adm";
+
+let $i8 := count([int8("1"), int8("2"), int8("3")])
+let $i16 := count([int16("1"), int16("2"), int16("3")])
+let $i32 := count([int32("1"), int32("2"), int32("3")])
+let $i64 := count([int64("1"), int64("2"), int64("3")])
+let $f := count([float("1"), float("2"), float("3")])
+let $d := count([double("1"), double("2"), double("3")])
+let $s := count(["a", "b", "c"])
+for $i in [$i8, $i16, $i32, $i64, $f, $d, $s]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_count_empty.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_count_empty.aql
new file mode 100644
index 0000000..afd3dab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_count_empty.aql
@@ -0,0 +1,12 @@
+/*
+ * Description    : Tests the scalar version of count with an empty list.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_count_empty.adm";
+
+count([ ])
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_count_null.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_count_null.aql
new file mode 100644
index 0000000..60dd19f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_count_null.aql
@@ -0,0 +1,20 @@
+/*
+ * Description    : Tests the scalar version of count with nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_count_null.adm";
+
+let $i8 := count([int8("1"), int8("2"), int8("3"), null])
+let $i16 := count([int16("1"), int16("2"), int16("3"), null])
+let $i32 := count([int32("1"), int32("2"), int32("3"), null])
+let $i64 := count([int64("1"), int64("2"), int64("3"), null])
+let $f := count([float("1"), float("2"), float("3"), null])
+let $d := count([double("1"), double("2"), double("3"), null])
+let $s := count(["a", "b", "c", null])
+for $i in [$i8, $i16, $i32, $i64, $f, $d, $s]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_max.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_max.aql
new file mode 100644
index 0000000..8eefced
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_max.aql
@@ -0,0 +1,21 @@
+/*
+ * Description    : Tests the scalar version of max without nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_max.adm";
+
+let $i8 := max([int8("1"), int8("2"), int8("3")])
+let $i16 := max([int16("1"), int16("2"), int16("3")])
+let $i32 := max([int32("1"), int32("2"), int32("3")])
+let $i64 := max([int64("1"), int64("2"), int64("3")])
+let $f := max([float("1"), float("2"), float("3")])
+let $d := max([double("1"), double("2"), double("3")])
+let $s := max(["foo", "bar", "world"])
+let $dt := max([datetime("2012-03-01T00:00:00Z"), datetime("2012-01-01T00:00:00Z"), datetime("2012-02-01T00:00:00Z")])
+for $i in [$i8, $i16, $i32, $i64, $f, $d, $s, $dt]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_max_empty.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_max_empty.aql
new file mode 100644
index 0000000..3a4396e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_max_empty.aql
@@ -0,0 +1,12 @@
+/*
+ * Description    : Tests the scalar version of max with an empty list.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_max_empty.adm";
+
+max([ ])
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_max_null.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_max_null.aql
new file mode 100644
index 0000000..04436bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_max_null.aql
@@ -0,0 +1,21 @@
+/*
+ * Description    : Tests the scalar version of max with nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_max_null.adm";
+
+let $i8 := max([int8("1"), int8("2"), int8("3"), null])
+let $i16 := max([int16("1"), int16("2"), int16("3"), null])
+let $i32 := max([int32("1"), int32("2"), int32("3"), null])
+let $i64 := max([int64("1"), int64("2"), int64("3"), null])
+let $f := max([float("1"), float("2"), float("3"), null])
+let $d := max([double("1"), double("2"), double("3"), null])
+let $s := max(["foo", "bar", "world", null])
+let $dt := min([datetime("2012-03-01T00:00:00Z"), datetime("2012-01-01T00:00:00Z"), datetime("2012-02-01T00:00:00Z"), null])
+for $i in [$i8, $i16, $i32, $i64, $f, $d, $s, $dt]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_min.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_min.aql
new file mode 100644
index 0000000..04aa735
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_min.aql
@@ -0,0 +1,21 @@
+/*
+ * Description    : Tests the scalar version of min without nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_min.adm";
+
+let $i8 := min([int8("1"), int8("2"), int8("3")])
+let $i16 := min([int16("1"), int16("2"), int16("3")])
+let $i32 := min([int32("1"), int32("2"), int32("3")])
+let $i64 := min([int64("1"), int64("2"), int64("3")])
+let $f := min([float("1"), float("2"), float("3")])
+let $d := min([double("1"), double("2"), double("3")])
+let $s := min(["foo", "bar", "world"])
+let $dt := min([datetime("2012-03-01T00:00:00Z"), datetime("2012-01-01T00:00:00Z"), datetime("2012-02-01T00:00:00Z")])
+for $i in [$i8, $i16, $i32, $i64, $f, $d, $s, $dt]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_min_empty.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_min_empty.aql
new file mode 100644
index 0000000..e242a35
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_min_empty.aql
@@ -0,0 +1,12 @@
+/*
+ * Description    : Tests the scalar version of min with an empty list.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_min_empty.adm";
+
+min([ ])
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_min_null.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_min_null.aql
new file mode 100644
index 0000000..523ca26
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_min_null.aql
@@ -0,0 +1,21 @@
+/*
+ * Description    : Tests the scalar version of min with nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_min_null.adm";
+
+let $i8 := min([int8("1"), int8("2"), int8("3"), null])
+let $i16 := min([int16("1"), int16("2"), int16("3"), null])
+let $i32 := min([int32("1"), int32("2"), int32("3"), null])
+let $i64 := min([int64("1"), int64("2"), int64("3"), null])
+let $f := min([float("1"), float("2"), float("3"), null])
+let $d := min([double("1"), double("2"), double("3"), null])
+let $s := min(["foo", "bar", "world", null])
+let $dt := min([datetime("2012-03-01T00:00:00Z"), datetime("2012-01-01T00:00:00Z"), datetime("2012-02-01T00:00:00Z"), null])
+for $i in [$i8, $i16, $i32, $i64, $f, $d, $s, $dt]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_sum.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_sum.aql
new file mode 100644
index 0000000..843360f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_sum.aql
@@ -0,0 +1,19 @@
+/*
+ * Description    : Tests the scalar version of sum without nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_sum.adm";
+
+let $i8 := sum([int8("1"), int8("2"), int8("3")])
+let $i16 := sum([int16("1"), int16("2"), int16("3")])
+let $i32 := sum([int32("1"), int32("2"), int32("3")])
+let $i64 := sum([int64("1"), int64("2"), int64("3")])
+let $f := sum([float("1"), float("2"), float("3")])
+let $d := sum([double("1"), double("2"), double("3")])
+for $i in [$i8, $i16, $i32, $i64, $f, $d]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_sum_empty.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_sum_empty.aql
new file mode 100644
index 0000000..35bf676
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_sum_empty.aql
@@ -0,0 +1,12 @@
+/*
+ * Description    : Tests the scalar version of sum with an empty list.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_sum_empty.adm";
+
+sum([ ])
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_sum_null.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_sum_null.aql
new file mode 100644
index 0000000..a4c2e61
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/scalar_sum_null.aql
@@ -0,0 +1,19 @@
+/*
+ * Description    : Tests the scalar version of sum with nulls.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_scalar_sum_null.adm";
+
+let $i8 := sum([int8("1"), int8("2"), int8("3"), null])
+let $i16 := sum([int16("1"), int16("2"), int16("3"), null])
+let $i32 := sum([int32("1"), int32("2"), int32("3"), null])
+let $i64 := sum([int64("1"), int64("2"), int64("3"), null])
+let $f := sum([float("1"), float("2"), float("3"), null])
+let $d := sum([double("1"), double("2"), double("3"), null])
+for $i in [$i8, $i16, $i32, $i64, $f, $d]
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_01.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_01.aql
new file mode 100644
index 0000000..b4e26b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_01.aql
@@ -0,0 +1,17 @@
+/*
+ * Description    : Tests that sum aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/aggregate_sum_empty_01.adm";
+
+sum(
+ for $x in [1, 2, 3]
+ where $x > 10
+ return $x
+)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_02.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_02.aql
new file mode 100644
index 0000000..a94457a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_empty_02.aql
@@ -0,0 +1,23 @@
+/*
+ * Description    : Tests that sum aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as closed {
+  id: int32,
+  val: double
+}
+
+create dataset Test(TestType) partitioned by key id;
+
+write output to nc1:"rttest/aggregate_sum_empty_02.adm";
+
+sum(
+ for $x in dataset('Test')
+ return $x.val
+)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv01.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv01.aql
new file mode 100644
index 0000000..e95d102
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv01.aql
@@ -0,0 +1,50 @@
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to access datasets.
+ * Expected Res : Success
+ * Date         : 29th Aug 2012
+ */
+
+drop dataverse student if exists;
+drop dataverse teacher if exists;
+
+create dataverse student;
+create dataverse teacher;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv01.adm";
+
+create type student.stdType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create type teacher.tchrType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create dataset student.ugdstd(stdType) partitioned by key id;
+create dataset student.gdstd(stdType) partitioned by key id;
+create dataset teacher.prof(tchrType) partitioned by key id;
+create dataset teacher.pstdoc(tchrType) partitioned by key id;
+
+insert into dataset student.ugdstd({"id":457,"name":"John Doe","age":22,"sex":"M","dept":"Dance"});
+
+insert into dataset student.gdstd({"id":418,"name":"John Smith","age":26,"sex":"M","dept":"Economics"});
+
+insert into dataset teacher.prof({"id":152,"name":"John Meyer","age":42,"sex":"M","dept":"History"});
+
+insert into dataset teacher.pstdoc({"id":259,"name":"Sophia Reece","age":36,"sex":"F","dept":"Anthropology"});
+
+for $s in dataset('student.ugdstd')
+for $p in dataset('teacher.prof')
+for $a in dataset('student.gdstd')
+for $b in dataset('teacher.pstdoc')
+return {"ug-student":$s,"prof":$p,"grd-student":$a,"postdoc":$b}
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv02.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv02.aql
new file mode 100644
index 0000000..1257cac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv02.aql
@@ -0,0 +1,48 @@
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types and query Metadata to verify.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+drop dataverse student if exists;
+drop dataverse teacher if exists;
+
+create dataverse student;
+create dataverse teacher;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv02.adm";
+
+create type student.stdType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create type teacher.tchrType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create dataset student.ugdstd(stdType) partitioned by key id;
+create dataset student.gdstd(stdType) partitioned by key id;
+create dataset teacher.prof(tchrType) partitioned by key id;
+create dataset teacher.pstdoc(tchrType) partitioned by key id;
+
+insert into dataset student.ugdstd({"id":457,"name":"John Doe","age":22,"sex":"M","dept":"Dance"});
+
+insert into dataset student.gdstd({"id":418,"name":"John Smith","age":26,"sex":"M","dept":"Economics"});
+
+insert into dataset teacher.prof({"id":152,"name":"John Meyer","age":42,"sex":"M","dept":"History"});
+
+insert into dataset teacher.pstdoc({"id":259,"name":"Sophia Reece","age":36,"sex":"F","dept":"Anthropology"});
+
+for $l in dataset('Metadata.Dataset')
+where $l.DataverseName='student' or $l.DataverseName='teacher'
+return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv03.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv03.aql
new file mode 100644
index 0000000..0c80540
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv03.aql
@@ -0,0 +1,49 @@
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types.
+ *              : drop datasets using fully qualified names
+ *              : Query metadata to verify datasets are dropped.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+drop dataverse student if exists;
+drop dataverse teacher if exists;
+
+create dataverse student;
+create dataverse teacher;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv03.adm";
+
+create type student.stdType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create type teacher.tchrType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create dataset student.ugdstd(stdType) partitioned by key id;
+create dataset student.gdstd(stdType) partitioned by key id;
+create dataset teacher.prof(tchrType) partitioned by key id;
+create dataset teacher.pstdoc(tchrType) partitioned by key id;
+
+drop dataset student.ugdstd;
+drop dataset student.gdstd;
+drop dataset teacher.prof;
+drop dataset teacher.pstdoc;
+
+count(
+for $l in dataset('Metadata.Dataset')
+where $l.DataverseName='student' or $l.DataverseName='teacher'
+return $l
+)
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv04.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv04.aql
new file mode 100644
index 0000000..20be103
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv04.aql
@@ -0,0 +1,53 @@
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types.
+ *              : drop datasets using fully qualified names
+ *              : re create the datasets 
+ *              : Query metadata to verify datasets are created.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+drop dataverse student if exists;
+drop dataverse teacher if exists;
+
+create dataverse student;
+create dataverse teacher;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv04.adm";
+
+create type student.stdType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create type teacher.tchrType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create dataset student.ugdstd(stdType) partitioned by key id;
+create dataset student.gdstd(stdType) partitioned by key id;
+create dataset teacher.prof(tchrType) partitioned by key id;
+create dataset teacher.pstdoc(tchrType) partitioned by key id;
+
+drop dataset student.ugdstd;
+drop dataset student.gdstd;
+drop dataset teacher.prof;
+drop dataset teacher.pstdoc;
+
+create dataset student.ugdstd(stdType) partitioned by key id;
+create dataset student.gdstd(stdType) partitioned by key id;
+create dataset teacher.prof(tchrType) partitioned by key id;
+create dataset teacher.pstdoc(tchrType) partitioned by key id;
+
+for $l in dataset('Metadata.Dataset')
+where $l.DataverseName='student' or $l.DataverseName='teacher'
+return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv07.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv07.aql
new file mode 100644
index 0000000..4bba053
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv07.aql
@@ -0,0 +1,34 @@
+/*
+ * Description     : Use fully qualified name to create dataset, type and index
+ *                 : and to access dataset
+ * Expected Result : Success
+ * Date            : 29th August 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv07.adm";
+
+create type test.Emp as closed {
+id:int32,
+fname:string,
+lname:string,
+age:int32,
+dept:string
+}
+
+create dataset test.employee(Emp) partitioned by key id;
+
+load dataset test.employee
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+create index idx_employee_f_l_name on test.employee(fname,lname);
+
+write output to nc1:"rttest/cross-dataverse_cross-dv07.adm";
+
+for $l in dataset('test.employee')
+where $l.fname="Julio" and $l.lname="Isa"
+return $l
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv08.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv08.aql
new file mode 100644
index 0000000..10985e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv08.aql
@@ -0,0 +1,52 @@
+/*
+ * Description  : Create two UDFs in two different dataverses and create datasets in tose dvs
+ *              : access the datasets from the UDF defined in the other dataverse and invoke one of the UDF
+ * Expected Res : Success
+ * Date         : Sep 7th 2012
+ */
+
+// dv1 - udf1 - dataset1
+// dv2 - udf2 - dataset2
+
+drop dataverse test if exists;
+drop dataverse fest if exists;
+
+create dataverse test;
+create dataverse fest;
+
+create type test.testtype as open {
+id : int32
+}
+
+create type fest.testtype as open {
+id : int32
+}
+
+create dataset test.t1(testtype) partitioned by key id;
+create dataset fest.t1(testtype) partitioned by key id;
+
+insert into dataset test.t1({"id":24});
+insert into dataset test.t1({"id":23});
+insert into dataset test.t1({"id":21});
+insert into dataset test.t1({"id":44});
+insert into dataset test.t1({"id":64});
+
+insert into dataset fest.t1({"id":24});
+insert into dataset fest.t1({"id":23});
+insert into dataset fest.t1({"id":21});
+insert into dataset fest.t1({"id":44});
+insert into dataset fest.t1({"id":64});
+
+create function test.f1(){
+for $l in dataset('fest.t1')
+return $l
+}
+
+create function fest.f1(){
+for $m in dataset('test.t1')
+return $m
+}
+
+let $a := test.f1()
+let $b := fest.f1()
+return { "a" : $a, "b" : $b }
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv09.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv09.aql
new file mode 100644
index 0000000..6eea8ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv09.aql
@@ -0,0 +1,24 @@
+/*
+ * Description  : Create user defined funs. in two different dataverses
+ *              : and invoke one of them.
+ *              : In this test we use fully qualified names to access and create the UDFs.
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
+drop dataverse testdv1 if exists;
+drop dataverse testdv2 if exists;
+create dataverse testdv1;
+create dataverse testdv2;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv09.adm";
+
+create function testdv1.fun01(){
+"function 01"
+}
+
+create function testdv2.fun02(){
+"function 02"
+}
+
+testdv1.fun01()
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv11.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv11.aql
new file mode 100644
index 0000000..03b84a7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv11.aql
@@ -0,0 +1,23 @@
+/* 
+ * Description  : Create two UDFs in two different dataverses
+ *              : Invoke one UDF from the body of the other UDF.
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
+drop dataverse testdv1 if exists;
+drop dataverse testdv2 if exists;
+create dataverse testdv1;
+create dataverse testdv2;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv11.adm";
+
+create function testdv1.fun01(){
+testdv2.fun02()
+}
+
+create function testdv2.fun02(){
+"function 02"
+}
+
+testdv1.fun01()
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv12.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv12.aql
new file mode 100644
index 0000000..e3cde9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv12.aql
@@ -0,0 +1,25 @@
+/* 
+ * Description  : Create two UDFs in two different dataverses
+ *              : Bind the results returned by each UDF to a variable and return those variables
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
+drop dataverse testdv1 if exists;
+drop dataverse testdv2 if exists;
+create dataverse testdv1;
+create dataverse testdv2;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv12.adm";
+
+create function testdv1.fun01(){
+"function 01"
+}
+
+create function testdv2.fun02(){
+"function 02"
+}
+
+let $a := testdv1.fun01()
+let $b := testdv2.fun02()
+return {"fun-01":$a,"fun-02":$b}
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv13.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv13.aql
new file mode 100644
index 0000000..13e31b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv13.aql
@@ -0,0 +1,28 @@
+/* 
+ * Description  : Create UDFs in different dataverses
+ *              : Test for recursion in those UDFs
+ * Expected Res : Failure - Recursion is not allowed!
+ * Date         : 31st Aug 2012
+ * Ignored      : This test is currently not part of the test build, because it being a negative test case expectedly throws an exception. 
+ */
+
+drop dataverse testdv1 if exists;
+drop dataverse testdv2 if exists;
+create dataverse testdv1;
+create dataverse testdv2;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv13.adm";
+
+create function testdv1.fun01(){
+testdv2.fun02()
+}
+
+create function testdv2.fun02(){
+testdv2.fun03()
+}
+
+create function testdv2.fun03(){
+testdv1.fun01()
+}
+
+testdv1.fun01();
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv14.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv14.aql
new file mode 100644
index 0000000..1c6b863
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv14.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Create UDF and invoke UDF in return clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
+drop dataverse testdv1 if exists;
+create dataverse testdv1;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv14.adm";
+
+create function testdv1.fun01(){
+100
+}
+
+let $a := true
+return testdv1.fun01();
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv15.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv15.aql
new file mode 100644
index 0000000..2aee200
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv15.aql
@@ -0,0 +1,30 @@
+/*
+ * Description  : Create user defined functions using fully qualified names
+ *              : verify their details in Function dataset in Metadata dataverse.
+ * Expected Res :
+ * Date         : 30th Aug 2012
+ */
+
+drop dataverse testdv1 if exists;
+create dataverse testdv1;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv15.adm";
+
+// UDF with no inputs
+create function testdv1.fun01(){
+100
+}
+
+// UDF with one input
+create function testdv1.fun02($a){
+"function 02"
+}
+
+// UDF with two inputs
+create function testdv1.fun03($b,$c){
+$b+$c
+}
+
+for $l in dataset('Metadata.Function')
+where $l.DataverseName='testdv1'
+return $l;
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv16.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv16.aql
new file mode 100644
index 0000000..b0ac16d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv16.aql
@@ -0,0 +1,32 @@
+/*
+ * Description  : Detect Recursion in UDFs
+ * Expected Res : Failure
+ * Date         : 30 Aug 2012
+ * Ignored      : Not part of test build, as its a negative test case that thrwos an exception
+ */
+
+drop dataverse testdv1 if exists;
+create dataverse testdv1;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv16.adm";
+
+// UDF with no inputs
+create function testdv1.fun01(){
+testdv1.fun02()
+}
+
+// UDF with one input
+create function testdv1.fun02(){
+testdv1.fun03()
+}
+
+// UDF with two inputs
+create function testdv1.fun03(){
+testdv1.fun04()
+}
+
+create function testdv1.fun04(){
+testdv1.fun02()
+}
+
+testdv1.fun01()
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv17.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv17.aql
new file mode 100644
index 0000000..26556e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv17.aql
@@ -0,0 +1,48 @@
+/*
+ * Decription   : Create UDF to query two different datasets that are in tow different dataverses.
+ * Expected Res : Success
+ * Date         : Sep 7 2012
+ */
+
+// this test currently gives ParseException
+
+drop dataverse test if exists;
+drop dataverse fest if exists;
+
+create dataverse test;
+create dataverse fest;
+
+create type test.testtype as open {
+id : int32
+}
+
+create type fest.testtype as open {
+id : int32
+}
+
+create dataset test.t1(testtype) partitioned by key id;
+create dataset fest.t1(testtype) partitioned by key id;
+
+insert into dataset test.t1({"id":24});
+insert into dataset test.t1({"id":23});
+insert into dataset test.t1({"id":21});
+insert into dataset test.t1({"id":44});
+insert into dataset test.t1({"id":64});
+
+insert into dataset fest.t1({"id":24});
+insert into dataset fest.t1({"id":23});
+insert into dataset fest.t1({"id":21});
+insert into dataset fest.t1({"id":44});
+insert into dataset fest.t1({"id":64});
+
+create function fest.f1(){
+for $m in dataset('test.t1')
+for $l in dataset('fest.t1')
+order by $m,$l
+return { "l":$l,"m":$m }
+}
+
+write output to nc1:"rttest/cross-dataverse_cross-dv17.adm";
+
+fest.f1();
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv18.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv18.aql
new file mode 100644
index 0000000..0d3bd53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv18.aql
@@ -0,0 +1,41 @@
+/*
+ * Description  : Create two dataverses and one dataset in each of the dataverse
+ *              : insert data and query using the datasets using fully qualified names and return results.
+ * Expected Res : Success
+ * Date         : Sep 7th 2012
+ * Ignored      : Not part of the current test build because of Issue 199
+ */
+
+
+drop dataverse test if exists;
+drop dataverse fest if exists;
+
+create dataverse test;
+create dataverse fest;
+
+create type test.testtype as open {
+id : int32
+}
+
+create type fest.testtype as open {
+id : int32
+}
+
+create dataset test.t1(testtype) partitioned by key id;
+create dataset fest.t1(testtype) partitioned by key id;
+
+insert into dataset test.t1({"id":24});
+insert into dataset test.t1({"id":23});
+insert into dataset test.t1({"id":21});
+insert into dataset test.t1({"id":44});
+insert into dataset test.t1({"id":64});
+
+insert into dataset fest.t1({"id":24});
+insert into dataset fest.t1({"id":23});
+insert into dataset fest.t1({"id":21});
+insert into dataset fest.t1({"id":44});
+insert into dataset fest.t1({"id":64});
+
+let $a := (for $l in dataset('fest.t1') return $l)
+let $b := (for $m in dataset('test.t1') return $m)
+return {"a":$a,"b":$b}
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv19.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv19.aql
new file mode 100644
index 0000000..335f11c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv19.aql
@@ -0,0 +1,57 @@
+/*
+ * Description  : Create internal and external datasets in more than one dataverse and query metadata to verify entries in Metadata.
+ * Expected Res : Success
+ * Date         : Sep 20 2012
+ */
+
+drop dataverse test1 if exists;
+drop dataverse test2 if exists;
+create dataverse test1;
+create dataverse test2;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv19.adm";
+
+create type test1.testtype as open {
+id : int32,
+name : string,
+loc: point,
+time: datetime
+}
+
+create type test2.testtype as open {
+id : int32,
+name : string?,
+loc: point,
+time: datetime
+}
+
+create type test1.Tweet as open {
+  id: int32,
+  tweetid: int64,
+  loc: point,
+  time: datetime,
+  text: string
+}
+
+create dataset test1.t1(testtype) partitioned by key id;
+
+create dataset test2.t2(testtype) partitioned by key id;
+
+create dataset test2.t3(testtype) partitioned by key id;
+
+create dataset test1.t2(testtype) partitioned by key id;
+
+create dataset test1.t3(testtype) partitioned by key id;
+
+create dataset test2.t4(testtype) partitioned by key id;
+
+create external dataset test1.TwitterData(Tweet)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/extrasmalltweets.txt"),("format"="adm"));
+
+for $l in dataset('Metadata.Dataset')
+where $l.DataverseName='test1' or $l.DataverseName='test2' or $l.DataverseName='TwitterData'
+return $l
+
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/drop_dataset.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/drop_dataset.aql
new file mode 100644
index 0000000..7b14957
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/drop_dataset.aql
@@ -0,0 +1,31 @@
+drop dataverse test if exists;
+create dataverse test;
+
+create type test.AddressType as open {
+  number: int32,
+  street: string,
+  city: string
+};
+
+create type test.CustomerType as closed {
+  cid: int32,
+  name: string,
+  cashBack: int32,
+  age: int32?,
+  address: AddressType?,
+  lastorder: {
+    oid: int32,
+    total: float
+  }
+};
+
+create dataset test.Customers(CustomerType)
+partitioned by key cid;
+
+drop dataset test.Customers;
+
+write output to nc1:"rttest/cross-dataverse_drop_dataset.adm";
+
+for $x in dataset('Metadata.Dataset')
+where $x.DataverseName='test' and $x.DatasetName='Customers'
+return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_across_dataverses.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_across_dataverses.aql
new file mode 100644
index 0000000..7eebbaf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_across_dataverses.aql
@@ -0,0 +1,65 @@
+//***** Test to read from a dataset and insert into another dataset when the datasets belong to different dataverses*****//
+drop dataverse test1 if exists;
+drop dataverse test2 if exists;
+
+create dataverse test1;
+create dataverse test2;
+
+create type test1.AddressType as open {
+  number: int32,
+  street: string,
+  city: string
+};
+
+create type test1.CustomerType as closed {
+  cid: int32,
+  name: string,
+  cashBack: int32,
+  age: int32?,
+  address: AddressType?,
+  lastorder: {
+    oid: int32,
+    total: float
+  }
+};
+
+create type test2.AddressType as open {
+  number: int32,
+  street: string,
+  city: string
+};
+
+create type test2.CustomerType as closed {
+  cid: int32,
+  name: string,
+  cashBack: int32,
+  age: int32?,
+  address: AddressType?,
+  lastorder: {
+    oid: int32,
+    total: float
+  }
+};
+
+create dataset test1.Customers(CustomerType)
+partitioned by key cid;
+
+create dataset test2.Customers(CustomerType)
+partitioned by key cid;
+
+load dataset test1.Customers
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+
+insert into dataset test2.Customers(
+for $x in dataset('test1.Customers')
+return $x
+);
+
+write output to nc1:"rttest/cross-dataverse_insert_across_dataverses.adm";
+
+for $c in dataset('test2.Customers')
+order by $c.cid
+return $c
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_from_source_dataset.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_from_source_dataset.aql
new file mode 100644
index 0000000..89180ef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/insert_from_source_dataset.aql
@@ -0,0 +1,41 @@
+/*
+ * Description  : Use fully qualified dataset names to insert into target dataset by doing a select on source dataset.
+ * Expected Res : Success
+ * Date         : Sep 19 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+create type test.testtype as open {
+id : int32,
+name : string
+}
+
+write output to nc1:"rttest/cross-dataverse_insert_from_source_dataset.adm";
+
+create dataset test.t1(testtype) partitioned by key id;
+
+insert into dataset test.t1({"id":456,"name":"Roger"});
+insert into dataset test.t1({"id":351,"name":"Bob"});
+insert into dataset test.t1({"id":257,"name":"Sammy"});
+insert into dataset test.t1({"id":926,"name":"Richard"});
+insert into dataset test.t1({"id":482,"name":"Kevin"});
+
+create dataset test.t2(testtype) partitioned by key id;
+
+insert into dataset test.t2({"id":438,"name":"Ravi"});
+insert into dataset test.t2({"id":321,"name":"Bobby"});
+insert into dataset test.t2({"id":219,"name":"Sam"});
+insert into dataset test.t2({"id":851,"name":"Ricardo"});
+insert into dataset test.t2({"id":201,"name":"Kelvin"});
+
+insert into dataset test.t1(for $l in dataset('test.t2') return $l);
+
+for $l in dataset('test.t1')
+order by $l.id
+return $l;
+
+drop dataset test.t1 if exists;
+
+drop dataverse test if exists;
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql
new file mode 100644
index 0000000..d09755a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql
@@ -0,0 +1,60 @@
+//***** Test to conduct a join between datasets belonging to different dataverses*****//
+
+drop dataverse test1 if exists;
+drop dataverse test2 if exists;
+
+create dataverse test1;
+create dataverse test2;
+
+create type test1.AddressType as open {
+  number: int32,
+  street: string,
+  city: string
+};
+
+create type test1.CustomerType as closed {
+  cid: int32,
+  name: string,
+  cashBack: int32,
+  age: int32?,
+  address: AddressType?,
+  lastorder: {
+    oid: int32,
+    total: float
+  }
+};
+
+create dataset test1.Customers(CustomerType)
+partitioned by key cid;
+
+
+create type test2.OrderType as open {
+  oid: int32,
+  cid: int32,
+  orderstatus: string,
+  orderpriority: string,
+  clerk: string,
+  total: float,
+  items: [int32]
+}
+
+create dataset test2.Orders(OrderType)
+partitioned by key oid;
+
+
+load dataset test1.Customers
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/nontagged/customerData.json"),
+("format"="adm"));
+
+load dataset test2.Orders
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
+write output to nc1:"rttest/cross-dataverse_join_across_dataverses.adm";
+
+for $c in dataset('test1.Customers')
+for $o in dataset('test2.Orders')
+where $c.cid = $o.cid
+order by $c.name, $o.total
+return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total, "orderList":[$o.oid, $o.cid], "orderList":{{$o.oid, $o.cid}}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/metadata_dataset.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/metadata_dataset.aql
new file mode 100644
index 0000000..777613c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/metadata_dataset.aql
@@ -0,0 +1,8 @@
+write output to nc1:"rttest/cross-dataverse_metadata_dataset.adm";
+
+for $c in dataset('Metadata.Dataset')
+where $c.DataverseName='Metadata'
+return $c
+
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205.aql b/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205.aql
new file mode 100644
index 0000000..e0a0695
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205.aql
@@ -0,0 +1,33 @@
+/*
+ * Description  : This test case is to verify the fix for issue205
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=205
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type EmployeeStat as open {
+  age: int32,
+  salary:int32
+}
+
+create type EmployeeType as closed {
+  id:string,
+  stat:EmployeeStat,
+  deptCode:int32
+}
+
+create dataset Employees(EmployeeType)
+  partitioned by key id;
+
+insert into dataset Employees({"id":"1234", "stat":{ "age":50, "salary":120000}, "deptCode":32 });
+insert into dataset Employees({"id":"5678", "stat":{ "age":40, "salary":100000}, "deptCode":16 });
+
+delete $l from dataset Employees where $l.id = "1234";
+
+write output to nc1:"rttest/dml_query-issue205.adm";
+for $l in dataset('Employees')
+return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index.aql
index 6201ca2..4e2ca6c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-rtree-secondary-index.aql
@@ -10,7 +10,8 @@
   line2: line,
   poly1: polygon,
   poly2: polygon,
-  rec: rectangle
+  rec: rectangle,
+  circle: circle
 }
 
 create dataset MyData(MyRecord)
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index.aql b/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index.aql
index 236b4a9..f1bc29d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-rtree-secondary-index.aql
@@ -10,7 +10,8 @@
   line2: line,
   poly1: polygon,
   poly2: polygon,
-  rec: rectangle
+  rec: rectangle,
+  circle: circle
 }
 
 create type MyMiniRecord as closed {
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree.aql
new file mode 100644
index 0000000..5678681
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree.aql
@@ -0,0 +1,7 @@
+use dataverse test;
+
+write output to nc1:"rttest/failure_verify_delete-rtree.adm";
+
+for $o in dataset('MyData')
+order by $o.id
+return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete.aql
new file mode 100644
index 0000000..61006a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete.aql
@@ -0,0 +1,8 @@
+use dataverse test;
+
+write output to nc1:"rttest/failure_verify_delete.adm";
+
+for $c in dataset('LineItem')
+where $c.l_orderkey>=10
+order by $c.l_orderkey, $c.l_linenumber
+return $c
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree.aql
new file mode 100644
index 0000000..3e52732
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree.aql
@@ -0,0 +1,7 @@
+use dataverse test;
+
+write output to nc1:"rttest/failure_verify_insert-rtree.adm";
+
+for $o in dataset('MyMiniData')
+order by $o.id
+return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert.aql
new file mode 100644
index 0000000..97ca9ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert.aql
@@ -0,0 +1,7 @@
+use dataverse test;
+
+write output to nc1:"rttest/failure_verify_insert.adm";
+
+for $c in dataset('LineID')
+order by $c.l_orderkey, $c.l_linenumber
+return $c
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_01.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_01.aql
new file mode 100644
index 0000000..d4dcd38
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_01.aql
@@ -0,0 +1,27 @@
+/*
+ * Description  : Create a feed dataset and verify contents in Metadata
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+drop dataverse feeds if exists;
+create dataverse feeds;
+use dataverse feeds;
+
+create type TweetType as closed {
+  id: string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}      
+
+create feed dataset TweetFeed(TweetType)
+using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
+(("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("output-type-name"="TweetType"),("tuple-interval"="10"))
+partitioned by key id;
+
+write output to nc1:"rttest/feeds_feeds_01.adm";
+
+for $x in dataset('Metadata.Dataset')
+where $x.DataverseName='feeds' and $x.DatasetName='TweetFeed'
+return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_02.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_02.aql
new file mode 100644
index 0000000..3129d63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_02.aql
@@ -0,0 +1,31 @@
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+                  Begin ingestion and verify contents of the dataset post completion.  
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+drop dataverse feeds if exists;
+create dataverse feeds;
+use dataverse feeds;
+
+create type TweetType as closed {
+  id: string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}      
+
+create feed dataset TweetFeed(TweetType)
+using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
+(("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("output-type-name"="TweetType"),("tuple-interval"="10"))
+partitioned by key id;
+
+begin feed TweetFeed; 
+
+write output to nc1:"rttest/feeds_feeds_02.adm";
+
+for $x in dataset('TweetFeed')
+return $x
+
+drop dataverse feeds;
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_03.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_03.aql
new file mode 100644
index 0000000..a4b22d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_03.aql
@@ -0,0 +1,34 @@
+/*
+ * Description  : Create a feed dataset with an associated function and verify contents in Metadata
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+drop dataverse feeds if exists;
+create dataverse feeds;
+use dataverse feeds;
+
+create type TweetType as closed {
+  id: string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}      
+
+create function feed_processor($x) {
+$x
+}
+
+create feed dataset TweetFeed(TweetType)
+using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
+(("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("output-type-name"="TweetType"),("tuple-interval"="10"))
+apply function feed_processor@1
+partitioned by key id;
+
+write output to nc1:"rttest/feeds_feeds_03.adm";
+
+for $x in dataset('Metadata.Dataset')
+where $x.DataverseName='feeds' and $x.DatasetName='TweetFeed'
+return $x
+
+drop dataverse feeds;
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_04.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_04.aql
new file mode 100644
index 0000000..c38cfd2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/feeds_04.aql
@@ -0,0 +1,32 @@
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+                  The feed simulator simulates feed from a file in the HDFS. 
+                  Begin ingestion and verify contents of the dataset post completion.  
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+drop dataverse feeds if exists;
+create dataverse feeds;
+use dataverse feeds;
+
+create type TweetType as closed {
+  id: string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}      
+
+create feed dataset TweetFeed(TweetType)
+using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
+(("fs"="hdfs"),("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/obamatweets.adm"),("format"="adm"),("input-format"="text-input-format"),("output-type-name"="TweetType"),("tuple-interval"="10"))
+partitioned by key id;
+
+begin feed TweetFeed; 
+
+write output to nc1:"rttest/feeds_feeds_04.adm";
+
+for $x in dataset('TweetFeed')
+return $x
+
+drop dataverse feeds;
diff --git a/asterix-app/src/test/resources/runtimets/queries/feeds/issue_230_feeds.aql b/asterix-app/src/test/resources/runtimets/queries/feeds/issue_230_feeds.aql
new file mode 100644
index 0000000..a7dc4fa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/feeds/issue_230_feeds.aql
@@ -0,0 +1,31 @@
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+                  Begin ingestion using a fully qualified name and verify contents of the dataset post completion.  
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+drop dataverse feeds if exists;
+create dataverse feeds;
+use dataverse feeds;
+
+create type TweetType as closed {
+  id: string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}      
+
+create feed dataset TweetFeed(TweetType)
+using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
+(("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("output-type-name"="TweetType"),("tuple-interval"="10"))
+partitioned by key id;
+
+begin feed feeds.TweetFeed; 
+
+write output to nc1:"rttest/feeds_issue_230_feeds.adm";
+
+for $x in dataset('TweetFeed')
+return $x
+
+drop dataverse feeds;
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for01.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for01.aql
index 046c55f..afb3783 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for01.aql
@@ -4,6 +4,8 @@
  * Date             :  23rd July 2012
  */
 
+write output to nc1:"rttest/flwor_for01.adm";
+
 for $a in [1,2,3,4,5,6,7,8,9]
 where not(false)
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for02.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for02.aql
index aa75cfa..6ff278a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for02.aql
@@ -4,6 +4,8 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for02.adm";
+
 for $a in [[1,2,3,4,5,6,7,8,9],[20,30,40,50,60,70,80]]
 where true
 return for $b in $a where $b > 5 and $b <70 return $b
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for03.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for03.aql
index 00bf474..090aa69 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for03.aql
@@ -4,5 +4,7 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for03.adm";
+
 for $a in [[1,2,3,4,5,6,7,8,9,0],["r","t","w","a"],[11,34,56,78,98,01,12,34,56,76,83],[null,null,null],[" ","","    "],["at"],[-1],[0]]
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for04.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for04.aql
index 0d26a37..c419b6e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for04.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for04.aql
@@ -4,6 +4,8 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for04.adm";
+
 for $a in [[1,2,3,4,5,6,7,8,9,0],[11,34,56,78,98,01,12,34,56,76,83],[null,null,null,"and","bat","gone","do"],[" ","","    "],["at"],[-1],[0]]
 where len($a) > 1
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for05.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for05.aql
index f2f1ca3..a8533d9 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for05.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for05.aql
@@ -4,6 +4,8 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for05.adm";
+
 for $a in [1,2,3,4,5,6,7,8,9]
 where ()
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for06.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for06.aql
index 9cc9fe3..5ed5e5e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for06.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for06.aql
@@ -4,6 +4,8 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for06.adm";
+
 for $a in [1,2,3,4,5,6,7,8,9]
 where $undefined
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for07.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for07.aql
index 9639c60..af2cd3c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for07.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for07.aql
@@ -4,5 +4,7 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for07.adm";
+
 for $a in [{"name":"Bob","age":10,"sex":"Male"},{"name":"John","age":45,"sex":"Female"},{"name":"Raj","age":35,"sex":"Male"}]
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for08.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for08.aql
index f0e0191..b8a88fe 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for08.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for08.aql
@@ -4,6 +4,8 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for08.adm";
+
 for $a in [{"name":"Bob","age":10,"sex":"Male"},{"name":"John","age":45,"sex":"Female"},{"name":"Raj","age":35,"sex":"Male"}]
 where $a.name="John"
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for09.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for09.aql
index 872257f..fb03193 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for09.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for09.aql
@@ -4,6 +4,8 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for09.adm";
+
 for $a in [{"name":"Bob","age":10,"sex":"Male"},{"name":"John","age":45,"sex":"Female"},{"name":"Raj","age":35,"sex":"Male"}]
 where $a.name="Tom"
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for10.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for10.aql
index 99c96b4..81589ea 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for10.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for10.aql
@@ -4,5 +4,7 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for10.adm";
+
 for $a in [{"name":"Bob","age":10,"sex":"Male"},{"name":"John","age":45,"sex":"Female"},{"name":"Raj","age":35,"sex":"Male"}]
 return {"a":$a,"additional-data":{{"this is additional data","this is too","and this is additional too"}}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for11.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for11.aql
index f2c8ade..50f5635 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for11.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for11.aql
@@ -4,5 +4,8 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for11.adm";
+
 for $a in [true,true,false,true]
+where $a = true
 return {{"this is additional data","this is too","and this is additional too"}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for12.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for12.aql
index 609af54..f870374 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for12.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for12.aql
@@ -4,6 +4,9 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for12.adm";
+
 for $a in [true,true,false,true]
+where $a = false
 return {"a":{{"this is additional data","this is too","and this is additional too"}},"b":{{"this is additional data","this is too","and this is additional too"}}}
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for13.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for13.aql
index 307995b..5a6388e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for13.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for13.aql
@@ -4,5 +4,7 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for13.adm";
+
 for $a in [true]
 return {{"this is additional data","this is too","and this is additional too"}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for14.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for14.aql
index bd9eff7..bef8754 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for14.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for14.aql
@@ -4,5 +4,7 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for14.adm";
+
 for $a in [{"name":"Rocky","age":59,"sex":"M"},["job","ink","king","ontario","lavelle"],[1,4,5,6,7,8,9,2,3,4,5,6,7],{{"extra data","extra data","extra data"}}]
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for15.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for15.aql
index 5e8f9786..5a65ae6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for15.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for15.aql
@@ -4,5 +4,7 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for15.adm";
+
 for $a in [{"name":"Rocky","age":59,"sex":"M"},[1]]
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for16.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for16.aql
index 790f9ce..c2fb57f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for16.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for16.aql
@@ -4,5 +4,7 @@
  * Date             :  7th July 2012
  */
 
+write output to nc1:"rttest/flwor_for16.adm";
+
 for $a in [[[1,2],[3]],[[4,5],[6,7]],[[8,9],[10,11]],[[12,13],[14]],[[15],[16,17]],[[18],[19,20]]]
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for17.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for17.aql
index 9e05da3..0d5d16c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/for17.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for17.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_for17.adm";
+
 (for $a in [{"id":1234,"name":"John Doe","age":56,"salary":50000,"dept":"HR"}]
 return $a)
 union
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for18.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for18.aql
new file mode 100644
index 0000000..e17daa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for18.aql
@@ -0,0 +1,15 @@
+/*
+ * Description     : Test nested for and return
+ * Expected Result : Success
+ * Date            : 21st Aug 2012
+ */
+
+write output to nc1:"rttest/flwor_for18.adm";
+
+for $a in (
+    for $b in (
+               for $c in (
+                         for $d in [1,2,3,4,5,6,7] return $d+1
+               ) return $c+1
+    ) return $b+1
+) return $a+1
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/for19.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/for19.aql
new file mode 100644
index 0000000..1101c95
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/for19.aql
@@ -0,0 +1,11 @@
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+write output to nc1:"rttest/flwor_for19.adm";
+
+for $a in [[1,2,3,4,5,6,7,8,9,0],[11,34,56,78,98,01,12,34,56,76,83]]
+where len($a) > 1
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/grpby01.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/grpby01.aql
new file mode 100644
index 0000000..252016f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/grpby01.aql
@@ -0,0 +1,15 @@
+/*
+ * Description      :  Test group by clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  31st July 2012
+ */
+
+for $sales in [{"storeno":"S101","itemno":"P78395","qty":125},
+{"storeno":"S101","itemno":"P71395","qty":135},
+{"storeno":"S102","itemno":"P78395","qty":225},
+{"storeno":"S103","itemno":"P78345","qty":105},
+{"storeno":"S104","itemno":"P71395","qty":115},
+{"storeno":"S105","itemno":"P74395","qty":120}]
+group by $strNum:=$sales.storeno with $sales
+order by $strNum desc
+return {"store-number":$strNum,"total-qty":sum(for $l in $sales return $l.qty)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/grpby02.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/grpby02.aql
new file mode 100644
index 0000000..252016f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/grpby02.aql
@@ -0,0 +1,15 @@
+/*
+ * Description      :  Test group by clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  31st July 2012
+ */
+
+for $sales in [{"storeno":"S101","itemno":"P78395","qty":125},
+{"storeno":"S101","itemno":"P71395","qty":135},
+{"storeno":"S102","itemno":"P78395","qty":225},
+{"storeno":"S103","itemno":"P78345","qty":105},
+{"storeno":"S104","itemno":"P71395","qty":115},
+{"storeno":"S105","itemno":"P74395","qty":120}]
+group by $strNum:=$sales.storeno with $sales
+order by $strNum desc
+return {"store-number":$strNum,"total-qty":sum(for $l in $sales return $l.qty)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let01.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let01.aql
index 9836f85..7313680 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let01.aql
@@ -4,5 +4,7 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let01.adm";
+
 let $x := int64("92233720368547758")
 return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let02.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let02.aql
index a0f936f..8fae4a2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let02.aql
@@ -4,5 +4,7 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let02.adm";
+
 let $x := 92233720368547758
 return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let03.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let03.aql
index 4cb816b..895630a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let03.aql
@@ -4,5 +4,7 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let03.adm";
+
 let $x := int64("92233720368547758")+1
 return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let04.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let04.aql
index 4832e2c..fad97fa 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let04.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let04.aql
@@ -4,5 +4,7 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let04.adm";
+
 let $x := double("1.7976931348623157E308") 
 return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let05.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let05.aql
index d8d3023..f718608 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let05.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let05.aql
@@ -4,5 +4,7 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let05.adm";
+
 let $x := {"a":(1+1*(100/20))}
 return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let06.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let06.aql
index 2d443a9..c693a04 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let06.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let06.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let06.adm";
+
 let $x := 1
 let $y := $x+1
 return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let07.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let07.aql
index 894b1da..5abf05e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let07.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let07.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let07.adm";
+
 let $x := 1
 let $y := ($x+1)
 return $y
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let08.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let08.aql
index 687cc51..ca38246 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let08.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let08.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let08.adm";
+
 let $x:=[1,2,3]
 for $b in $x
 let $y:=$b+1
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let09.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let09.aql
index 2d4439b..0c10d5a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let09.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let09.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let09.adm";
+
 for $a in range(1,100)
 where $a%5=0
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let10.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let10.aql
index 208a478..a10b28f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let10.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let10.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let10.adm";
+
 let $x:=[1,2,3,4,5,6,7,8,9,10,11,14,15,17,19,24,35,56,67,77,89,60,35,25,60]
 for $y in $x
 where $y%5=0
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let11.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let11.aql
index 1a96ff3..150b075 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let11.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let11.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let11.adm";
+
 // Return an ordered list comprising of records and other values
 
 let $a := ["a",{"i":1},"b",{"j":2},"c",{"k":3}]
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let12.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let12.aql
index 6b80062..3061ea8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let12.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let12.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let12.adm";
+
 let $a := 1 
 let $b := $a
 let $c := $a+$b 
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let13.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let13.aql
index 8722947..cf987b8 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let13.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let13.aql
@@ -1,9 +1,11 @@
 /*
  * Description     :  Test let clause
- * Expected Result :  Success
+ * Expected Result :  Failure - Negative test
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let13.adm";
+
 // Bind an undefined variable.
 
 let $a := $b 
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let14.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let14.aql
index b0cdcad..524dd97 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let14.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let14.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let14.adm";
+
 // nested ordered list
 
 let $a := [[[[[[[[[[[[1,2,3,4,5,6,7,8,9,10],[3,4,5,6,7,8,9,0,0],int64("9222872036854775809")]]]]]]]]]]]
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let15.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let15.aql
index 317726a..52f9862 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let15.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let15.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let15.adm";
+
 // nested ordered list comprising of only one integer value.
 
 let $a := [[[[[[[[[[[int64("9222872036854775809")]]]]]]]]]]]
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let16.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let16.aql
index 122d3ee..b403c3e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let16.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let16.aql
@@ -4,5 +4,7 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let16.adm";
+
 let $a := [[[[[[[[[[[int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809"),int64("9222872036854775809")]]]]]]]]]]]
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let17.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let17.aql
index 4f9be6f..4b53f84 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let17.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let17.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let17.adm";
+
 let $a := ["and","here","we","are",["this is new","stuff"]]
 return $a
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let18.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let18.aql
index c50c871..3373323 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let18.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let18.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let18.adm";
+
 // An ordered list comprising of an un ordered list.
 
 let $a:=[{{"John Doe",45,"HR",60000,"Separation"}}]
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let19.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let19.aql
index d3fbafc..e46856a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let19.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let19.aql
@@ -4,5 +4,10 @@
  * Date            :  6th July 2012 
  */
 
+
+// bind and return bag of data
+
+write output to nc1:"rttest/flwor_let19.adm";
+
 let $a:={{"John Doe",45,"HR",60000,"Separation"}}
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let20.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let20.aql
index 22814e6..0172b22 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let20.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let20.aql
@@ -4,6 +4,8 @@
  * Date            :  6th July 2012 
  */
 
+write output to nc1:"rttest/flwor_let20.adm";
+
 // An ordered list of un ordered lists, records and ordered list.
 
 let $a:=[{{"John Doe",45,"HR",60000,"Separation"}},{"name":"Roger Sanders","age":50,"dept":"DB2-Books","designatin":"Author"},["DB2 for Z/OS","DB2 for LUW","DB2 9 Application Development","DB2 9 DBA","DB2 for Dummies"]]
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let21.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let21.aql
index 81f93be..1106a75 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let21.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let21.aql
@@ -4,6 +4,7 @@
  * Date             :  23rd July 2012
  */
 
+write output to nc1:"rttest/flwor_let21.adm";
 
 // Ordered list of boolean values.
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let22.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let22.aql
index da33601..c83d81e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let22.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let22.aql
@@ -4,5 +4,7 @@
  * Date            : 23rd July 2012
  */
 
+write output to nc1:"rttest/flwor_let22.adm";
+
 let $a := [null]
 return len($a)
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let23.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let23.aql
index 07ea21b..7ad2152 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let23.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let23.aql
@@ -4,5 +4,7 @@
  * Date            : 23rd July 2012
  */
 
+write output to nc1:"rttest/flwor_let23.adm";
+
 let $a := [1,2,3,4,5,6,7,8,9,null]
 return len($a)
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let24.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let24.aql
index 9bfe510..75a96b1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let24.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let24.aql
@@ -12,6 +12,8 @@
  * q - nested record
  */
 
+write output to nc1:"rttest/flwor_let24.adm";
+
 let $m := {"name":"Holmes S","age":25,"sex":"M"}
 let $n := {"name":"Bob","age":35,"sex":null}
 let $o := {{"John",45,"M"}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let25.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let25.aql
index e2b88da..4959b7e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let25.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let25.aql
@@ -4,6 +4,8 @@
  * Date            : 23rd July 2012
  */
 
+write output to nc1:"rttest/flwor_let25.adm";
+
 let $a := true or false
 let $b := (true or false) and not(false)
 return {"a":$a,"b":$b}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let26.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let26.aql
index a8afffe..5352548 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let26.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let26.aql
@@ -8,6 +8,8 @@
  * Test let clause - let variable := relational expression
  */
 
+write output to nc1:"rttest/flwor_let26.adm";
+
 let $a := 10 > 9
 let $b := ((100 * 100)/10 -1999) > 3900
 let $c := true != false
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let27.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let27.aql
index 5cfc1a7..b675e2c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let27.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let27.aql
@@ -6,5 +6,7 @@
 
 // Bind arithmetic expressions to variable using let clause
 
+write output to nc1:"rttest/flwor_let27.adm";
+
 let $a := [(100+100),(100-100),(100 * 100),(100 / 100),(100 %10)] 
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let28.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let28.aql
index 2f1b7ce..663304b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let28.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let28.aql
@@ -4,5 +4,7 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_let28.adm";
+
 let $a := [137.8932f,156f,.98781f, 436.219F,.89217F,16789F]
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let29.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let29.aql
index 55d6319..45083eb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let29.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let29.aql
@@ -4,5 +4,7 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_let29.adm";
+
 let $a := [137.8932,.98781,436.219,.89217,-234.324]
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let30.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let30.aql
index eebc11f..3229d86 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let30.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let30.aql
@@ -6,6 +6,8 @@
 
 // $a and $b are ordered lists with one Record each.
 
+write output to nc1:"rttest/flwor_let30.adm";
+
 let $a := [{"id":1234,"name":"John Doe","age":56,"salary":50000,"dept":"HR"}]
 let $b := [{"id":3424,"name":"Roger Sanders","age":46,"salary":60000,"dept":"Publishing"}]
 let $c := $a union $b
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let31.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let31.aql
index 84ac278..4c8da02 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let31.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let31.aql
@@ -6,6 +6,8 @@
 
 // $a and $b hold one Record each.
 
+write output to nc1:"rttest/flwor_let31.adm";
+
 let $a := {"id":1234,"name":"John Doe","age":56,"salary":50000,"dept":"HR"}
 let $b := {"id":3424,"name":"Roger Sanders","age":46,"salary":60000,"dept":"Publishing"}
 let $c := $a union $b
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/let32.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/let32.aql
index 0881fde..f78d8b5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/let32.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/let32.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_let32.adm";
+
 let $m := (for $a in [{"id":1234,"name":"John Doe","age":56,"salary":50000,"dept":"HR"}]
 return $a)
 let $n := (for $b in [{"id":3424,"name":"Roger Sanders","age":46,"salary":60000,"dept":"Publishing"}]
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-01.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-01.aql
index a5aec23..7824518 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-01.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-01.adm";
+
 for $a in ["two","four","six","eight","ten","twenty","undo"]
 order by $a desc
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-02.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-02.aql
index 4cc087c..a60d172 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-02.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-02.adm";
+
 for $a in ["two","four","six","eight","ten","twenty","undo"]
 order by $a asc
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-03.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-03.aql
index 3792c74..eb0c23b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-03.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-03.adm";
+
 for $b in ["ten","twenty","thirty","forty","fifty","sixty","seventy","ninety"]
 order by string-concat([$b,"test"]) asc
 return string-concat([$b,"test"])
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-04.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-04.aql
index e7a209b..65c432f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-04.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-04.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-04.adm";
+
 for $b in ["ten","twenty","thirty","forty","fifty","sixty","seventy","ninety"]
 order by string-concat([$b,"test"]) desc
 return string-concat([$b,"test"])
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-05.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-05.aql
index c3139f5..7f9a751 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-05.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-05.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-05.adm";
+
 for $b in ["ten","twenty","thirty","forty","fifty","sixty","seventy","ninety"]
 order by string-concat([$b,""]) desc
 return string-concat([$b,""])
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-06.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-06.aql
index 791af3a..bf77da1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-06.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-06.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-06.adm";
+
 for $b in ["ten","twenty","thirty","forty","fifty","sixty","seventy","ninety"]
 order by string-concat([$b,""]) asc
 return string-concat([$b,""])
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-07.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-07.aql
index 9c85780..67e6c04 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-07.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-07.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-07.adm";
+
 for $b in ["ten","twenty","thirty","forty","fifty","sixty","seventy","ninety"]
 order by string-concat(["",$b]) desc
 return string-concat(["",$b])
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-08.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-08.aql
index 6a823c8..59de072 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-08.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-08.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-08.adm";
+
 for $b in ["ten","twenty","thirty","forty","fifty","sixty","seventy","ninety"]
 order by string-concat(["",$b]) asc
 return string-concat(["",$b])
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-09.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-09.aql
index 0df3a9e..cce7299 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-09.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-09.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-09.adm";
+
 for $x in ["ten","twenty","thirty","forty","fifty","sixty","seventy","ninety"]
 order by string-concat([$x,$x]) asc 
 return string-concat([$x,$x])
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-10.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-10.aql
index 09a9026..91b7dc7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-10.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-10.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-10.adm";
+
 for $x in ["ten","twenty","thirty","forty","fifty","sixty","seventy","ninety"]
 order by string-concat([$x,$x]) desc 
 return string-concat([$x,$x])
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-11.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-11.aql
index 5b79987..c97b708 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-11.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-11.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-11.adm";
+
 for $x in [1,3,4,5,2,3,33,55,43,12,34,45,67,66,89,0,-1,999]
 order by ($x+$x) asc
 return ($x+$x)
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-12.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-12.aql
index b620a05..b604158 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-12.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/order-by-12.aql
@@ -4,6 +4,8 @@
  * Date            : 24th July 2012
  */
 
+write output to nc1:"rttest/flwor_order-by-12.adm";
+
 for $x in [[1,3,4],[5,2],[3,33,55],[43,12,34],[45,67],[66,89,0],[-1,999]]
 order by len($x)
 return { "x":$x,"len($x)":len($x) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-01.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-01.aql
index 0c7e73e..72fb94a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-01.aql
@@ -4,5 +4,9 @@
  * Date             :  7th July 2012
  */
 
+// return string length
+
+write output to nc1:"rttest/flwor_ret-01.adm";
+
 for $x in ["ten","twenty","thirty","forty","fifty","sixty","seventy","ninety"]
 return string-length($x)
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-02.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-02.aql
new file mode 100644
index 0000000..5201cc5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-02.aql
@@ -0,0 +1,12 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+// Return a string
+
+write output to nc1:"rttest/flwor_ret-02.adm";
+
+for $x in [true]
+return "this is a test string"
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-03.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-03.aql
new file mode 100644
index 0000000..e51f787
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-03.aql
@@ -0,0 +1,11 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Tes if expression then expression else expression in the return clause 
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+write output to nc1:"rttest/flwor_ret-03.adm";
+
+for $x in [true]
+return (if(true) then "YES" else "NO") 
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-04.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-04.aql
new file mode 100644
index 0000000..5974ed4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-04.aql
@@ -0,0 +1,12 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Tes if expression then expression else expression in the return clause
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+write output to nc1:"rttest/flwor_ret-04.adm";
+
+
+let $a := 12345
+return (if($a > 999) then "GREATER" else "LESSER") 
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-05.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-05.aql
new file mode 100644
index 0000000..4f6249b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-05.aql
@@ -0,0 +1,11 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  For + Return within return clause
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+write output to nc1:"rttest/flwor_ret-05.adm";
+
+let $b := 12345
+return (for $a in [[1,2,3],[4,5,6,7],[8,9],[0,4,5],[6,7,1],[2,3,4],[5,6,7],[8,9,0]] return $a)
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-06.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-06.aql
new file mode 100644
index 0000000..e164cd3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-06.aql
@@ -0,0 +1,11 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Return an un-ordered list
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+write output to nc1:"rttest/flwor_ret-06.adm";
+
+let $b := 12345
+return {{"Welcome","UCI","Anteater","DBH","ICS"}}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-07.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-07.aql
new file mode 100644
index 0000000..73c86cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-07.aql
@@ -0,0 +1,12 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+// return nothing
+
+write output to nc1:"rttest/flwor_ret-07.adm";
+
+let $b := true
+return {}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-08.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-08.aql
new file mode 100644
index 0000000..0b67dca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-08.aql
@@ -0,0 +1,13 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+// for and return in return clause
+
+write output to nc1:"rttest/flwor_ret-08.adm";
+
+for $a in [1,2,3,4,5,6,7,8]
+return {"a":$a,"inner-for":(for $b in [11,22,33,44,55,66,77,88] return $b)}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-09.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-09.aql
new file mode 100644
index 0000000..a186c99
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-09.aql
@@ -0,0 +1,12 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+// return a constant
+
+write output to nc1:"rttest/flwor_ret-09.adm";
+
+let $b:=true
+return 1
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-10.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-10.aql
new file mode 100644
index 0000000..cc05a11
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-10.aql
@@ -0,0 +1,13 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+// nested for and return within another for
+
+write output to nc1:"rttest/flwor_ret-10.adm";
+
+for $a in 
+    for $b in [1,2,3,4,5,6,7,8,9,0] return $b
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-11.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-11.aql
new file mode 100644
index 0000000..3f54a13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-11.aql
@@ -0,0 +1,10 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+write output to nc1:"rttest/flwor_ret-11.adm";
+
+for $a in [1,2,3,4,5,6,7,8,9] 
+return ($a + 1)
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-12.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-12.aql
new file mode 100644
index 0000000..7ce8e90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-12.aql
@@ -0,0 +1,10 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+write output to nc1:"rttest/flwor_ret-12.adm";
+
+for $a in [1,2,3,4,5,6,7,8,9] 
+return ($a - 1)
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-13.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-13.aql
new file mode 100644
index 0000000..cc16cb3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-13.aql
@@ -0,0 +1,10 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+write output to nc1:"rttest/flwor_ret-13.adm";
+
+for $a in [1,2,3,4,5,6,7,8,9] 
+return ($a * 9)
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-14.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-14.aql
new file mode 100644
index 0000000..4716e71
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-14.aql
@@ -0,0 +1,12 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+// Return record
+
+write output to nc1:"rttest/flwor_ret-14.adm";
+
+let $a := true
+return {"name":"John Doe", "age":26,"sex":"M","salary":50000,"dept":"HR"}
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-15.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-15.aql
new file mode 100644
index 0000000..e17312d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-15.aql
@@ -0,0 +1,15 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+// Return  op1 and op2 or op3 and op4
+
+write output to nc1:"rttest/flwor_ret-15.adm";
+
+let $a := true
+let $b := false
+let $c := true
+let $d := false
+return ($a and $b or $c and $d)
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-16.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-16.aql
new file mode 100644
index 0000000..185d7b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-16.aql
@@ -0,0 +1,15 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+// Return arithmetic-expr1 and arithmetic-expr2 
+
+write output to nc1:"rttest/flwor_ret-16.adm";
+
+let $a := 100 + 100
+let $b := 13.4 * 14.97
+let $c := 9999 + 98677
+let $d := 34.67 / 5.324
+return (($a*$d) and ($b / $c))
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-17.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-17.aql
new file mode 100644
index 0000000..f384f81
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-17.aql
@@ -0,0 +1,15 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+// Return arithmetic-expr1 and arithmetic-expr2 
+
+write output to nc1:"rttest/flwor_ret-17.adm";
+
+let $a := 100 + 100
+let $b := 13.4 * 14.97
+let $c := 9999 + 98677
+let $d := 34.67 / 5.324
+return (($a*$d) and ($b / $c))
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-18.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-18.aql
new file mode 100644
index 0000000..cf858f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-18.aql
@@ -0,0 +1,12 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+// Return an item from the ordered list 
+
+write output to nc1:"rttest/flwor_ret-18.adm";
+
+let $a := [1,2,3,4,5,6,7]
+return $a[6]
diff --git a/asterix-app/src/test/resources/runtimets/queries/flwor/ret-19.aql b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-19.aql
new file mode 100644
index 0000000..4cfa63b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/flwor/ret-19.aql
@@ -0,0 +1,12 @@
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+// Return an item from the ordered list 
+
+write output to nc1:"rttest/flwor_ret-19.adm";
+
+let $a := [[1,2,3,4,5,6,7],[7,8,9,10]]
+return $a[0]
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_2.aql
new file mode 100644
index 0000000..7bf7d5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_2.aql
@@ -0,0 +1,32 @@
+/*
+ * Description    : Tests that a proper error messags is returned for this scenario.
+ *                  Since we cannot statically know the type of the field 'title', the FuzzyEqRule
+ *                  cannot auto-inject a tokenizer, and hence we expect an error saying that we cannot
+ *                  scan over a string as if it were a collection.
+ *                  Guards against regression to issue 207.
+ * Success        : Yes
+ */
+
+drop dataverse fuzzyjoin if exists;
+create dataverse fuzzyjoin;
+use dataverse fuzzyjoin;
+
+create type DBLPType as open {
+  id: int32
+}
+
+create dataset DBLP(DBLPType) partitioned by key id;
+
+load dataset DBLP 
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/dblp-small/dblp-small.adm"),("format"="adm"));
+
+write output to nc1:'rttest/fuzzyjoin_dblp-aqlplus_2.adm';
+
+set simthreshold '.5f';
+
+for $dblp in dataset('DBLP')
+for $dblp2 in dataset('DBLP')
+where $dblp.title ~= $dblp2.title and $dblp.id < $dblp2.id
+order by $dblp.id, $dblp2.id
+return {'dblp': $dblp, 'dblp2': $dblp2}
diff --git a/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_02.aql b/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_02.aql
new file mode 100644
index 0000000..7a0494f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_02.aql
@@ -0,0 +1,26 @@
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+                 Perform a word-count over the data in the dataset.
+* Expected Res : Success
+* Date         : 7th Jan 2013
+*/
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type LineType as closed {
+ content: string
+};
+
+create external dataset TextDataset(LineType)
+using "hdfs"
+(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/textFileS"),("input-format"="sequence-input-format"),("format"="delimited-text"),("delimiter"="."));
+
+write output to nc1:"rttest/hdfs_hdfs_02.adm";
+
+for $line in dataset('TextDataset')
+let $tokens := word-tokens($line.content)
+for $token in $tokens
+group by $tok := $token with $token
+order by $tok
+return { "word": $tok, "count": count($token) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_03.aql b/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_03.aql
new file mode 100644
index 0000000..fc5b3ab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/hdfs/hdfs_03.aql
@@ -0,0 +1,28 @@
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a large (35kb) text file in HDFS.
+                 The input file is sufficiently large to guarantee that # of bytes > than internal buffer of size 8192.
+                 This causes a record to span across the buffer size boundaries. 
+                 Perform a word-count over the data in the dataset.
+* Expected Res : Success
+* Date         : 7th Jan 2013
+*/
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type LineType as closed {
+ content: string
+};
+
+create external dataset TextDataset(LineType)
+using "hdfs"
+(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/large_text"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="."));
+
+write output to nc1:"rttest/hdfs_hdfs_03.adm";
+
+for $line in dataset('TextDataset')
+let $tokens := word-tokens($line.content)
+for $token in $tokens
+group by $tok := $token with $token
+order by $tok
+return { "word": $tok, "count": count($token) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/hdfs/issue_245_hdfs.aql b/asterix-app/src/test/resources/runtimets/queries/hdfs/issue_245_hdfs.aql
new file mode 100644
index 0000000..c2a0963
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/hdfs/issue_245_hdfs.aql
@@ -0,0 +1,23 @@
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a file in HDFS.
+                 Iterate over the contained tuples.
+* Expected Res : Success
+* Issue        : 245
+* Date         : 7th Jan 2013
+*/
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type LineType as closed {
+ line: string
+};
+
+create external dataset TextDataset(LineType)
+using "hdfs"
+(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/asterix_info.txt"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="."));
+
+write output to nc1:"rttest/hdfs_issue_245_hdfs.adm";
+
+for $x in dataset('TextDataset')
+return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/ifthenelse_01.aql b/asterix-app/src/test/resources/runtimets/queries/ifthenelse_01.aql
deleted file mode 100644
index 1da06a7..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/ifthenelse_01.aql
+++ /dev/null
@@ -1,8 +0,0 @@
-use dataverse test;
-
-write output to nc1:"rttest/ifthenelse_01.adm";
-
-if (2>1) then
-    20
-else
-    10
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/btree-primary-equi-join.aql b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-primary-equi-join.aql
new file mode 100644
index 0000000..1015e82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-primary-equi-join.aql
@@ -0,0 +1,57 @@
+/*
+ * Description    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as open {
+  number: int32, 
+  street: string,
+  city: string
+}
+
+create type CustomerType as closed {
+  cid: int32, 
+  name: string,
+  cashBack: int32,
+  age: int32?,
+  address: AddressType?,
+  lastorder: {
+    oid: int32,
+    total: float
+  }
+}
+
+create type OrderType as open {
+  oid: int32,
+  cid: int32,
+  orderstatus: string,
+  orderpriority: string,
+  clerk: string,
+  total: float,
+  items: [int32]
+}
+
+create dataset Customers(CustomerType) partitioned by key cid;
+create dataset Orders(OrderType) partitioned by key oid;
+
+load dataset Customers
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+load dataset Orders
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
+write output to nc1:"rttest/index-join_btree-primary-equi-join.adm";
+
+for $c in dataset('Customers')
+for $o in dataset('Orders')
+where $c.cid /*+ indexnl */ = $o.cid
+order by $c.cid, $o.oid
+return {"cid":$c.cid, "oid": $o.oid}
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/btree-secondary-equi-join.aql b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-secondary-equi-join.aql
new file mode 100644
index 0000000..d1e9824
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-secondary-equi-join.aql
@@ -0,0 +1,47 @@
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as closed {
+  id: int32, 
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type CSXType as closed {
+  id: int32, 
+  csxid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) partitioned by key id;
+create dataset CSX(CSXType) partitioned by key id;
+
+load dataset DBLP 
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
+load dataset CSX
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/pub-small/csx-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
+create index title_index on DBLP(authors);
+
+write output to nc1:"rttest/index-join_btree-secondary-equi-join.adm";
+
+for $a in dataset('DBLP')
+for $b in dataset('CSX')
+where $a.authors /*+ indexnl */ = $b.authors
+order by $a.id, $b.id
+return {"aid": $a.id, "bid": $b.id, "authors": $a.authors}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/rtree-spatial-intersect-point.aql b/asterix-app/src/test/resources/runtimets/queries/index-join/rtree-spatial-intersect-point.aql
new file mode 100644
index 0000000..ab79189
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-join/rtree-spatial-intersect-point.aql
@@ -0,0 +1,43 @@
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the 
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as closed {
+  id: int32,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData1(MyRecord) partitioned by key id;
+create dataset MyData2(MyRecord) partitioned by key id;
+
+load dataset MyData1
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load dataset MyData2
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+create index rtree_index on MyData1(point) type rtree;
+
+write output to nc1:"rttest/index-join_rtree-spatial-intersect-point.adm";
+
+for $a in dataset('MyData1')
+for $b in dataset('MyData2')
+where spatial-intersect($a.point, $b.point) and $a.id != $b.id
+order by $a.id, $b.id
+return {"aid": $a.id, "bid": $b.id, "apt": $a.point, "bp": $b.point}
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-composite-key.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-composite-key.aql
new file mode 100644
index 0000000..dadb884
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-composite-key.aql
@@ -0,0 +1,35 @@
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Emp as closed {
+id:int32,
+fname:string,
+lname:string,
+age:int32,
+dept:string
+}
+
+create dataset employee(Emp) partitioned by key id;
+
+load dataset employee
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+create index idx_employee_f_l_name on employee(fname,lname);
+
+write output to nc1:"rttest/index-selection_btree-index-composite-key.adm";
+
+for $l in dataset('employee')
+where $l.fname="Julio" and $l.lname="Isa"
+return $l
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-rewrite-multiple.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-rewrite-multiple.aql
new file mode 100644
index 0000000..7b72a80
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-rewrite-multiple.aql
@@ -0,0 +1,48 @@
+/*
+ * Description     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+ 
+drop dataverse tpch if exists;
+create dataverse tpch;
+use dataverse tpch;
+
+create type OrderType as open {
+  o_orderkey: int32, 
+  o_custkey: int32, 
+  o_orderstatus: string, 
+  o_totalprice: double, 
+  o_orderdate: string, 
+  o_orderpriority: string,
+  o_clerk: string, 
+  o_shippriority: int32, 
+  o_comment: string
+}
+
+create dataset Orders(OrderType) partitioned by key o_orderkey;
+
+load dataset Orders 
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+create index idx_Orders_Custkey on Orders(o_custkey);
+
+write output to nc1:"rttest/index-selection_btree-index-rewrite-multiple.adm";
+
+for $o in dataset('Orders')
+for $o2 in dataset('Orders')
+where $o.o_custkey = 20 and $o2.o_custkey = 10
+and $o.o_orderstatus < $o2.o_orderstatus
+order by $o.o_orderkey, $o2.o_orderkey
+return {
+  "o_orderkey": $o.o_orderkey,
+  "o_custkey": $o.o_custkey,
+  "o_orderstatus": $o.o_orderstatus,
+  "o_orderkey2": $o2.o_orderkey,
+  "o_custkey2": $o2.o_custkey,
+  "o_orderstatus2": $o2.o_orderstatus
+}
+ 
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index.aql
index 7ff775c..c1e1890 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index.aql
@@ -10,7 +10,8 @@
   line2: line,
   poly1: polygon,
   poly2: polygon,
-  rec: rectangle
+  rec: rectangle,
+  circle: circle
 }
 
 create dataset MyData(MyRecord)
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql
similarity index 69%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql
index dfd86e3..0ea267c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance-inline.aql
@@ -1,6 +1,8 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
  *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -37,10 +39,11 @@
 
 create index ngram_index on Customers(name) type ngram(3);
 
-write output to nc1:"rttest/index-join_inverted-index-ngram-edit-distance.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-edit-distance-inline.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where edit-distance($a.name, $b.name) <= 4 and $a.cid < $b.cid
-order by $a.cid, $b.cid
-return { "arec": $a, "brec": $b }
\ No newline at end of file
+let $ed := edit-distance($a.name, $b.name)
+where $ed <= 4 and $a.cid < $b.cid
+order by $ed, $a.cid, $b.cid
+return { "a": $a.name, "b": $b.name, "ed": $ed }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql
similarity index 83%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql
index dfd86e3..f7e3a8b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-edit-distance.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
  *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -37,10 +38,10 @@
 
 create index ngram_index on Customers(name) type ngram(3);
 
-write output to nc1:"rttest/index-join_inverted-index-ngram-edit-distance.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-edit-distance.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
 where edit-distance($a.name, $b.name) <= 4 and $a.cid < $b.cid
 order by $a.cid, $b.cid
-return { "arec": $a, "brec": $b }
\ No newline at end of file
+return { "a": $a.name, "b": $b.name }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
similarity index 66%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
index 6f69866..734a269 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard-inline.aql
@@ -1,6 +1,8 @@
 /*
  * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
  *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -38,11 +40,11 @@
 
 create index ngram_index on DBLP(title) type ngram(3);
 
-write output to nc1:"rttest/index-join_inverted-index-ngram-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm";
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
-where similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) >= 0.5f 
-      and $a.id < $b.id
-order by $a.id, $b.id
-return { "arec": $a.title, "brec": $b.title }
\ No newline at end of file
+let $jacc := similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false))
+where $jacc >= 0.5f and $a.id < $b.id
+order by $jacc, $a.id, $b.id
+return { "a": $a.title, "b": $b.title, "jacc": $jacc }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
similarity index 83%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
index 6f69866..2e1a635 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ngram-jaccard.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
  *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -38,11 +39,11 @@
 
 create index ngram_index on DBLP(title) type ngram(3);
 
-write output to nc1:"rttest/index-join_inverted-index-ngram-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard.adm";
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
 where similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) >= 0.5f 
       and $a.id < $b.id
 order by $a.id, $b.id
-return { "arec": $a.title, "brec": $b.title }
\ No newline at end of file
+return { "a": $a.title, "b": $b.title }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql
similarity index 67%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql
index 601d1b8..3b46c7d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance-inline.aql
@@ -1,6 +1,8 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
  *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -37,10 +39,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-olist-edit-distance.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-edit-distance-inline.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where len($a.interests) > 2 and len($b.interests) > 2 and edit-distance($a.interests, $b.interests) <= 1 and $a.cid < $b.cid
-order by $a.cid, $b.cid
-return { "arec": $a, "brec": $b }
\ No newline at end of file
+let $ed := edit-distance($a.interests, $b.interests)
+where len($a.interests) > 2 and len($b.interests) > 2 and $ed <= 1 and $a.cid < $b.cid
+order by $ed, $a.cid, $b.cid
+return { "a": $a.interests, "b": $b.interests, "ed": $ed }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql
similarity index 83%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql
index 601d1b8..3f025ed 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-edit-distance.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
  *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -37,10 +38,10 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-olist-edit-distance.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-edit-distance.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
 where len($a.interests) > 2 and len($b.interests) > 2 and edit-distance($a.interests, $b.interests) <= 1 and $a.cid < $b.cid
 order by $a.cid, $b.cid
-return { "arec": $a, "brec": $b }
\ No newline at end of file
+return { "a": $a.interests, "b": $b.interests }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql
similarity index 66%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql
index 91fcd80..ea28721 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard-inline.aql
@@ -1,6 +1,8 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
  *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -37,11 +39,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-olist-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-jaccard-inline.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where similarity-jaccard($a.interests, $b.interests) >= 0.9f 
-      and $a.cid < $b.cid
-order by $a.cid, $b.cid
-return { "a": $a.interests, "b": $b.interests }
\ No newline at end of file
+let $jacc := /*+ indexnl */similarity-jaccard($a.interests, $b.interests)
+where $jacc >= 0.9f  and $a.cid < $b.cid and len($a.interests) > 1 and len($b.interests) > 1
+order by $jacc, $a.cid, $b.cid
+return { "a": $a.interests, "b": $b.interests, "jacc": $jacc }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard.aql
similarity index 77%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard.aql
index 91fcd80..458d31c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/olist-jaccard.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
  *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -37,11 +38,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-olist-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-jaccard.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where similarity-jaccard($a.interests, $b.interests) >= 0.9f 
-      and $a.cid < $b.cid
+where /*+ indexnl */ similarity-jaccard($a.interests, $b.interests) >= 0.9f 
+      and $a.cid < $b.cid and len($a.interests) > 1 and len($b.interests) > 1
 order by $a.cid, $b.cid
 return { "a": $a.interests, "b": $b.interests }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql
similarity index 66%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql
index 2b2d52c..e11b2f0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard-inline.aql
@@ -1,6 +1,8 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
  *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -37,11 +39,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-ulist-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ulist-jaccard-inline.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where similarity-jaccard($a.interests, $b.interests) >= 0.9f 
-      and $a.cid < $b.cid
-order by $a.cid, $b.cid
-return { "a": $a.interests, "b": $b.interests }
\ No newline at end of file
+let $jacc := /*+ indexnl */ similarity-jaccard($a.interests, $b.interests)
+where $jacc >= 0.9f and $a.cid < $b.cid and len($a.interests) > 1 and len($b.interests) > 1
+order by $jacc, $a.cid, $b.cid
+return { "a": $a.interests, "b": $b.interests, "jacc": $jacc }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql
similarity index 77%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql
index 2b2d52c..9732a51 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/ulist-jaccard.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
  *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -37,11 +38,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-ulist-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ulist-jaccard.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where similarity-jaccard($a.interests, $b.interests) >= 0.9f 
-      and $a.cid < $b.cid
+where /*+ indexnl */ similarity-jaccard($a.interests, $b.interests) >= 0.9f 
+      and $a.cid < $b.cid and len($a.interests) > 1 and len($b.interests) > 1
 order by $a.cid, $b.cid
 return { "a": $a.interests, "b": $b.interests }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql
similarity index 67%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql
index 228dfd2..1985878 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard-inline.aql
@@ -1,6 +1,8 @@
 /*
  * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
  *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -38,11 +40,11 @@
 
 create index keyword_index on DBLP(title) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-word-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_word-jaccard-inline.adm";
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
-where similarity-jaccard(word-tokens($a.title), word-tokens($b.title)) >= 0.5f 
-      and $a.id < $b.id
-order by $a.id, $b.id
-return { "arec": $a.title, "brec": $b.title }
\ No newline at end of file
+let $jacc := similarity-jaccard(word-tokens($a.title), word-tokens($b.title))
+where $jacc >= 0.5f and $a.id < $b.id
+order by $jacc, $a.id, $b.id
+return { "a": $a.title, "b": $b.title, "jacc": $jacc }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard.aql
similarity index 83%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard.aql
index 228dfd2..013b51e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join-noeqjoin/word-jaccard.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
  *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
  * Success        : Yes
  */
 
@@ -38,11 +39,11 @@
 
 create index keyword_index on DBLP(title) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-word-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join-noeqjoin_word-jaccard.adm";
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
 where similarity-jaccard(word-tokens($a.title), word-tokens($b.title)) >= 0.5f 
       and $a.id < $b.id
 order by $a.id, $b.id
-return { "arec": $a.title, "brec": $b.title }
\ No newline at end of file
+return { "a": $a.title, "b": $b.title }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance-inline.aql
similarity index 76%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance-inline.aql
index dfd86e3..a602ca1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance-inline.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
  *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
  * Success        : Yes
  */
 
@@ -37,10 +38,11 @@
 
 create index ngram_index on Customers(name) type ngram(3);
 
-write output to nc1:"rttest/index-join_inverted-index-ngram-edit-distance.adm";
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-inline.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where edit-distance($a.name, $b.name) <= 4 and $a.cid < $b.cid
-order by $a.cid, $b.cid
-return { "arec": $a, "brec": $b }
\ No newline at end of file
+let $ed := edit-distance($a.name, $b.name)
+where $ed <= 4 and $a.cid < $b.cid
+order by $ed, $a.cid, $b.cid
+return { "arec": $a, "brec": $b, "ed": $ed }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance.aql
similarity index 94%
rename from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql
rename to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance.aql
index dfd86e3..1c88536 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-edit-distance.aql
@@ -37,7 +37,7 @@
 
 create index ngram_index on Customers(name) type ngram(3);
 
-write output to nc1:"rttest/index-join_inverted-index-ngram-edit-distance.adm";
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline.aql
similarity index 73%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline.aql
index 6f69866..cd88072 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard-inline.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
  *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
  * Success        : Yes
  */
 
@@ -38,11 +39,11 @@
 
 create index ngram_index on DBLP(title) type ngram(3);
 
-write output to nc1:"rttest/index-join_inverted-index-ngram-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-inline.adm";
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
-where similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) >= 0.5f 
-      and $a.id < $b.id
-order by $a.id, $b.id
-return { "arec": $a.title, "brec": $b.title }
\ No newline at end of file
+let $jacc := similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false))
+where $jacc >= 0.5f and $a.id < $b.id
+order by $jacc, $a.id, $b.id
+return { "arec": $a, "brec": $b, "jacc": $jacc }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard.aql
similarity index 91%
rename from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql
rename to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard.aql
index 6f69866..abb5e33 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ngram-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ngram-jaccard.aql
@@ -38,11 +38,11 @@
 
 create index ngram_index on DBLP(title) type ngram(3);
 
-write output to nc1:"rttest/index-join_inverted-index-ngram-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard.adm";
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
 where similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) >= 0.5f 
       and $a.id < $b.id
 order by $a.id, $b.id
-return { "arec": $a.title, "brec": $b.title }
\ No newline at end of file
+return { "arec": $a, "brec": $b }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance-inline.aql
similarity index 73%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance-inline.aql
index 601d1b8..bdac6f1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance-inline.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
  *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
  * Success        : Yes
  */
 
@@ -37,10 +38,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-olist-edit-distance.adm";
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance-inline.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where len($a.interests) > 2 and len($b.interests) > 2 and edit-distance($a.interests, $b.interests) <= 1 and $a.cid < $b.cid
-order by $a.cid, $b.cid
-return { "arec": $a, "brec": $b }
\ No newline at end of file
+let $ed := edit-distance($a.interests, $b.interests)
+where len($a.interests) > 2 and len($b.interests) > 2 and $ed <= 1 and $a.cid < $b.cid
+order by $ed, $a.cid, $b.cid
+return { "arec": $a, "brec": $b, "ed": $ed }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance.aql
similarity index 94%
rename from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql
rename to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance.aql
index 601d1b8..5e679e4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-edit-distance.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-edit-distance.aql
@@ -37,7 +37,7 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-olist-edit-distance.adm";
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard-inline.aql
similarity index 72%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard-inline.aql
index 91fcd80..8fd8632 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard-inline.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
  *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
  * Success        : Yes
  */
 
@@ -37,11 +38,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-olist-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join_olist-jaccard-inline.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where similarity-jaccard($a.interests, $b.interests) >= 0.9f 
-      and $a.cid < $b.cid
-order by $a.cid, $b.cid
-return { "a": $a.interests, "b": $b.interests }
\ No newline at end of file
+let $jacc := /*+ indexnl */similarity-jaccard($a.interests, $b.interests)
+where $jacc >= 0.9f  and $a.cid < $b.cid and len($a.interests) > 1 and len($b.interests) > 1
+order by $jacc, $a.cid, $b.cid
+return { "a": $a, "b": $b, "jacc": $jacc }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard.aql
similarity index 83%
rename from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql
rename to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard.aql
index 91fcd80..50d13f1 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-olist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/olist-jaccard.aql
@@ -37,11 +37,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-olist-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join_olist-jaccard.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where similarity-jaccard($a.interests, $b.interests) >= 0.9f 
-      and $a.cid < $b.cid
+where /*+ indexnl */ similarity-jaccard($a.interests, $b.interests) >= 0.9f 
+      and $a.cid < $b.cid and len($a.interests) > 1 and len($b.interests) > 1
 order by $a.cid, $b.cid
-return { "a": $a.interests, "b": $b.interests }
\ No newline at end of file
+return { "a": $a, "b": $b }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard-inline.aql
similarity index 72%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard-inline.aql
index 2b2d52c..a62c66d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard-inline.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
  *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
  * Success        : Yes
  */
 
@@ -37,11 +38,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-ulist-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard-inline.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where similarity-jaccard($a.interests, $b.interests) >= 0.9f 
-      and $a.cid < $b.cid
-order by $a.cid, $b.cid
-return { "a": $a.interests, "b": $b.interests }
\ No newline at end of file
+let $jacc := /*+ indexnl */ similarity-jaccard($a.interests, $b.interests)
+where $jacc >= 0.9f and $a.cid < $b.cid and len($a.interests) > 1 and len($b.interests) > 1
+order by $jacc, $a.cid, $b.cid
+return { "a": $a, "b": $b, "jacc": $jacc }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard.aql
similarity index 83%
rename from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql
rename to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard.aql
index 2b2d52c..8c6570f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-ulist-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/ulist-jaccard.aql
@@ -37,11 +37,11 @@
 
 create index interests_index on Customers(interests) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-ulist-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard.adm";
 
 for $a in dataset('Customers')
 for $b in dataset('Customers2')
-where similarity-jaccard($a.interests, $b.interests) >= 0.9f 
-      and $a.cid < $b.cid
+where /*+ indexnl */ similarity-jaccard($a.interests, $b.interests) >= 0.9f 
+      and $a.cid < $b.cid and len($a.interests) > 1 and len($b.interests) > 1
 order by $a.cid, $b.cid
-return { "a": $a.interests, "b": $b.interests }
\ No newline at end of file
+return { "a": $a, "b": $b }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard-inline.aql
similarity index 74%
copy from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql
copy to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard-inline.aql
index 228dfd2..3ac3583 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard-inline.aql
@@ -1,6 +1,7 @@
 /*
  * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
  *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
  * Success        : Yes
  */
 
@@ -38,11 +39,11 @@
 
 create index keyword_index on DBLP(title) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-word-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join_word-jaccard-inline.adm";
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
-where similarity-jaccard(word-tokens($a.title), word-tokens($b.title)) >= 0.5f 
-      and $a.id < $b.id
-order by $a.id, $b.id
-return { "arec": $a.title, "brec": $b.title }
\ No newline at end of file
+let $jacc := similarity-jaccard(word-tokens($a.title), word-tokens($b.title))
+where $jacc >= 0.5f and $a.id < $b.id
+order by $jacc, $a.id, $b.id
+return { "arec": $a, "brec": $b, "jacc": $jacc }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard.aql
similarity index 91%
rename from asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql
rename to asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard.aql
index 228dfd2..7060fe6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/index-join/inverted-index-word-jaccard.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/inverted-index-join/word-jaccard.aql
@@ -38,11 +38,11 @@
 
 create index keyword_index on DBLP(title) type keyword;
 
-write output to nc1:"rttest/index-join_inverted-index-word-jaccard.adm";
+write output to nc1:"rttest/inverted-index-join_word-jaccard.adm";
 
 for $a in dataset('DBLP')
 for $b in dataset('CSX')
 where similarity-jaccard(word-tokens($a.title), word-tokens($b.title)) >= 0.5f 
       and $a.id < $b.id
 order by $a.id, $b.id
-return { "arec": $a.title, "brec": $b.title }
\ No newline at end of file
+return { "arec": $a, "brec": $b }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/listify_01.aql b/asterix-app/src/test/resources/runtimets/queries/list/listify_01.aql
index fe89111..3f08bcb 100644
--- a/asterix-app/src/test/resources/runtimets/queries/list/listify_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/list/listify_01.aql
@@ -7,8 +7,3 @@
 let $token_list := 
   for $token in [1, 2, 3] return $token
 return $token_list
-
-
-
-
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/listify_02.aql b/asterix-app/src/test/resources/runtimets/queries/list/listify_02.aql
index 4fe1e0d..1dae103 100644
--- a/asterix-app/src/test/resources/runtimets/queries/list/listify_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/list/listify_02.aql
@@ -7,8 +7,3 @@
 let $token_list := 
   for $token in ["foo", "bar"] return $token
 return $token_list
-
-
-
-
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/listify_03.aql b/asterix-app/src/test/resources/runtimets/queries/list/listify_03.aql
new file mode 100644
index 0000000..e034069
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/list/listify_03.aql
@@ -0,0 +1,16 @@
+/*
+ * Description      :  Test that a listify on a nullable type creates a homogeneous list of type ANY.
+ *                     Guards against regression to issue 186.
+ * Expected Result  :  Success
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/list_listify_03.adm";
+
+// The for prohibits the subplan from being eliminated.
+for $x in [1, 2]
+let $y := (for $i in [[1,2,3],[10,20,30],[-2,-5,0]] return min($i))
+return min($y)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_03.aql b/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_03.aql
new file mode 100644
index 0000000..81eaf8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/list/ordered-list-constructor_03.aql
@@ -0,0 +1,7 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/list_ordered-list-constructor_03.adm";
+
+[ null, null, null ]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_03.aql b/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_03.aql
new file mode 100644
index 0000000..e8b119e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/list/unordered-list-constructor_03.aql
@@ -0,0 +1,7 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/list_unordered-list-constructor_03.adm";
+
+{{ null, null, null }}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/load/issue14_query.aql b/asterix-app/src/test/resources/runtimets/queries/load/issue14_query.aql
new file mode 100644
index 0000000..9b25210
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/load/issue14_query.aql
@@ -0,0 +1,26 @@
+/*
+ * Description  : Create and load a dataset but with an unspecified data format.
+ * Expected Res : Failure
+ * Date         : 16 Jan 2012
+ */
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Schema as closed{
+id: int32,
+age: int32,
+name: string
+}
+
+create dataset onektup(Schema) 
+partitioned by key id;
+
+load dataset onektup 
+using "localfs"(("path"="nc1:///tmp/one.adm"));
+
+write output to nc1:"/tmp/foo.adm";
+
+for $l in dataset('onektup')
+return $l
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/float_01.aql b/asterix-app/src/test/resources/runtimets/queries/misc/float_01.aql
similarity index 72%
rename from asterix-app/src/test/resources/runtimets/queries/float_01.aql
rename to asterix-app/src/test/resources/runtimets/queries/misc/float_01.aql
index dea3790..ec0e8e5 100644
--- a/asterix-app/src/test/resources/runtimets/queries/float_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/float_01.aql
@@ -2,7 +2,7 @@
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/float_01.adm";
+write output to nc1:"rttest/misc_float_01.adm";
 
 for $f in [1f, 1F, 1.1f, 1.1F, .1f, .1F]
 return $f
diff --git a/asterix-app/src/test/resources/runtimets/queries/groupby-orderby-count.aql b/asterix-app/src/test/resources/runtimets/queries/misc/groupby-orderby-count.aql
similarity index 90%
rename from asterix-app/src/test/resources/runtimets/queries/groupby-orderby-count.aql
rename to asterix-app/src/test/resources/runtimets/queries/misc/groupby-orderby-count.aql
index ce4662d..e5887ae 100644
--- a/asterix-app/src/test/resources/runtimets/queries/groupby-orderby-count.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/groupby-orderby-count.aql
@@ -13,7 +13,7 @@
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
 (("path"="nc1://data/twitter/extrasmalltweets.txt"),("format"="adm"));
 
-write output to nc1:"rttest/groupby-orderby-count.adm";
+write output to nc1:"rttest/misc_groupby-orderby-count.adm";
 
 for $t in dataset('TwitterData')
 let $tokens := word-tokens($t.text)
diff --git a/asterix-app/src/test/resources/runtimets/queries/misc/ifthenelse_01.aql b/asterix-app/src/test/resources/runtimets/queries/misc/ifthenelse_01.aql
new file mode 100644
index 0000000..a65e675
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/ifthenelse_01.aql
@@ -0,0 +1,8 @@
+use dataverse test;
+
+write output to nc1:"rttest/misc_ifthenelse_01.adm";
+
+if (2>1) then
+    20
+else
+    10
diff --git a/asterix-app/src/test/resources/runtimets/queries/is-null_01.aql b/asterix-app/src/test/resources/runtimets/queries/misc/is-null_01.aql
similarity index 67%
rename from asterix-app/src/test/resources/runtimets/queries/is-null_01.aql
rename to asterix-app/src/test/resources/runtimets/queries/misc/is-null_01.aql
index ca6ac7a..9005392 100644
--- a/asterix-app/src/test/resources/runtimets/queries/is-null_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/is-null_01.aql
@@ -3,6 +3,6 @@
 
 use dataverse test;
 
-write output to nc1:"rttest/is-null_01.adm";
+write output to nc1:"rttest/misc_is-null_01.adm";
 
-[is-null(null), is-null(10)]
\ No newline at end of file
+[is-null(null), is-null(10)]
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-loop-join_01.aql b/asterix-app/src/test/resources/runtimets/queries/misc/nested-loop-join_01.aql
similarity index 94%
rename from asterix-app/src/test/resources/runtimets/queries/nested-loop-join_01.aql
rename to asterix-app/src/test/resources/runtimets/queries/misc/nested-loop-join_01.aql
index 79b3a9f..f148d2e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/nested-loop-join_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/nested-loop-join_01.aql
@@ -28,7 +28,7 @@
 using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
 (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
 
-write output to nc1:'rttest/nested-loop-join_01.adm';
+write output to nc1:'rttest/misc_nested-loop-join_01.adm';
 
 for $user in dataset('Users')
 for $visitor in dataset('Visitors')
diff --git a/asterix-app/src/test/resources/runtimets/queries/range_01.aql b/asterix-app/src/test/resources/runtimets/queries/misc/range_01.aql
similarity index 65%
rename from asterix-app/src/test/resources/runtimets/queries/range_01.aql
rename to asterix-app/src/test/resources/runtimets/queries/misc/range_01.aql
index 0f38113..9c5991d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/range_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/range_01.aql
@@ -1,7 +1,7 @@
 drop dataverse test if exists;
 create dataverse test;
 
-write output to nc1:"rttest/range_01.adm";
+write output to nc1:"rttest/misc_range_01.adm";
 
 for $x in range(20,30)
 return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/tid_01.aql b/asterix-app/src/test/resources/runtimets/queries/misc/tid_01.aql
similarity index 67%
rename from asterix-app/src/test/resources/runtimets/queries/tid_01.aql
rename to asterix-app/src/test/resources/runtimets/queries/misc/tid_01.aql
index 3cd8396..ff216ea 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tid_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/tid_01.aql
@@ -1,7 +1,7 @@
 drop dataverse test if exists;
 create dataverse test;
 
-write output to nc1:"rttest/tid_01.adm";
+write output to nc1:"rttest/misc_tid_01.adm";
 
 for $x at $i in ["a","b","c"]
 return $i
diff --git a/asterix-app/src/test/resources/runtimets/queries/year_01.aql b/asterix-app/src/test/resources/runtimets/queries/misc/year_01.aql
similarity index 61%
rename from asterix-app/src/test/resources/runtimets/queries/year_01.aql
rename to asterix-app/src/test/resources/runtimets/queries/misc/year_01.aql
index da93e96..f431a52 100644
--- a/asterix-app/src/test/resources/runtimets/queries/year_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/misc/year_01.aql
@@ -1,6 +1,6 @@
 drop dataverse test if exists;
 create dataverse test;
 
-write output to nc1:"rttest/year_01.adm";
+write output to nc1:"rttest/misc_year_01.adm";
 
 year("1996-12-01")
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue134.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue134.aql
new file mode 100644
index 0000000..62a9ed8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue134.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : This test case is to verify the fix for issue134
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=134
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+
+write output to nc1:"rttest/open-closed_query-issue134.adm";
+
+let $a:=true
+return {{[1,2,3,4,5],[6,5,3,8,9],[44,22,66,-1,0,99.9]}}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue166.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue166.aql
new file mode 100644
index 0000000..aa0d13b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue166.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : This test case is to verify the fix for issue166
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=166
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+ 
+write output to nc1:"rttest/open-closed_query-issue166.adm";
+
+let $a := [[1,2,3],[4,5,6,7]]
+return $a[1]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue208.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue208.aql
new file mode 100644
index 0000000..e46286c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue208.aql
@@ -0,0 +1,45 @@
+/*
+ * Description  : This test case is to verify the fix for issue208
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=208
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+
+drop dataverse OpenSocialNetworkData if exists;
+create dataverse OpenSocialNetworkData;
+
+use dataverse OpenSocialNetworkData;
+
+create type TwitterUserType as open {
+screen-name: string,
+lang: string,
+friends_count: int32,
+statuses_count: int32,
+name: string,
+followers_count: int32
+}
+
+create type TweetMessageType as open {
+tweetid: string,
+tweetid-copy: string,
+send-time-copy: datetime
+}
+
+create dataset TweetMessages(TweetMessageType)
+partitioned by key tweetid;
+
+load dataset TweetMessages
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/tw_messages.adm"),("format"="adm"));
+
+write output to nc1:"rttest/open-closed_query-issue208.adm"; 
+for $t in dataset('TweetMessages')
+where $t.send-time >= datetime('2005-04-13T17:17:22') and
+$t.send-time <= datetime('2011-04-13T17:18:22')
+group by $uid := $t.user.screen-name with $t
+order by $uid
+return {
+    "user": $uid,
+    "count": count($t)
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue29.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue29.aql
new file mode 100644
index 0000000..8b778ba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue29.aql
@@ -0,0 +1,70 @@
+/*
+ * Description  : This test case is to verify the fix for issue29
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=29
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+
+write output to nc1:"rttest/open-closed_query-issue29.adm";
+
+let $tweets := 
+{{
+   {
+      "tweetid": "1023",
+      "user": {
+         "screen-name": "dflynn24",
+         "lang": "en",
+         "friends_count": 46,
+         "statuses_count": 987,
+         "name": "danielle flynn",
+         "followers_count": 47
+      },
+      "sender-location": "40.904177,-72.958996",
+      "send-time": "2010-02-21T11:56:02-05:00",
+      "referred-topics": {{ "verizon" }},
+      "message-text": "i need a #verizon phone like nowwwww! :("
+   },
+   {
+      "tweetid": "1024",
+      "user": {
+         "screen-name": "miriamorous",
+         "lang": "en",
+         "friends_count": 69,
+         "statuses_count": 1068,
+         "name": "Miriam Songco",
+         "followers_count": 78
+      },
+      "send-time": "2010-02-21T11:11:43-08:00",
+      "referred-topics": {{ "commercials", "verizon", "att" }},
+      "message-text": "#verizon & #att #commercials, so competitive"
+   },
+   {
+      "tweetid": "1025",
+      "user": {
+         "screen-name": "dj33",
+         "lang": "en",
+         "friends_count": 96,
+         "statuses_count": 1696,
+         "name": "Don Jango",
+         "followers_count": 22
+      },
+      "send-time": "2010-02-21T12:38:44-05:00",
+      "referred-topics": {{ "charlotte" }},
+      "message-text": "Chillin at dca waiting for 900am flight to #charlotte and from there to providenciales"
+   },
+   {
+      "tweetid": "1026",
+      "user": {
+      "screen-name": "reallyleila",
+         "lang": "en",
+         "friends_count": 106,
+         "statuses_count": 107,
+         "name": "Leila Samii",
+         "followers_count": 52
+      },
+      "send-time": "2010-02-21T21:31:57-06:00",
+      "referred-topics": {{ "verizon", "at&t", "iphone" }},
+      "message-text": "I think a switch from #verizon to #at&t may be in my near future... my smartphone is like a land line compared to the #iphone!"
+   }
+}}
+return $tweets
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue55-1.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue55-1.aql
new file mode 100644
index 0000000..11b75d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue55-1.aql
@@ -0,0 +1,13 @@
+/*
+ * Description  : This test case is to verify the fix for issue55 query 1
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=55
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+
+write output to nc1:"rttest/open-closed_query-issue55-1.adm";
+
+let $l := [1.1f, 1.0f, 1.2f, 0.9, 1.3, 1, 2]
+for $i in $l
+for $j in $l
+return [$i, $j, "=", $i = $j, "<", $i < $j, "<=", $i <= $j, ">", $i > $j, ">=", $i >= $j]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue55.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue55.aql
new file mode 100644
index 0000000..b4e4572
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-issue55.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : This test case is to verify the fix for issue55 query 2
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=55
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+
+write output to nc1:"rttest/open-closed_query-issue55.adm";
+
+for $x in [[1,3],[4,5,2],[-1,-3,0],["a"]]
+return $x
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal.aql
new file mode 100644
index 0000000..a8d00f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal.aql
@@ -0,0 +1,107 @@
+/*
+ * Description     : Insert open data into internal dataset and query the open data
+ * Expected Result : Success
+ * Date            : 23rd October 2012
+ * Notes           : This test was written to cover the scenario which is used in the proposal.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type TweetMessageType as open {
+tweetid : string,
+user : {
+         screen-name: string,
+         lang: string,
+         friends_count: int32,
+         statuses_count: int32,
+         name: string,
+         followers_count: int32
+},    sender-location: point?,
+      send-time: datetime,
+      referred-topics: {{ string }},
+      message-text: string
+};
+
+create dataset TweetMessages(TweetMessageType)
+partitioned by key tweetid;
+
+insert into dataset TweetMessages(
+   {
+      "tweetid": "1023",
+      "user": {
+         "screen-name": "dflynn24",
+         "lang": "en",
+         "friends_count": 46,
+         "statuses_count": 987,
+         "name": "danielle flynn",
+         "followers_count": 47
+      },
+      "sender-location": create-point(40.904177,-72.958996),
+      "send-time": datetime("2010-02-21T11:56:02-05:00"),
+      "referred-topics": {{ "verizon" }},
+      "message-text": "i need a #verizon phone like nowwwww! : ("
+   });
+
+insert into dataset TweetMessages(
+   {
+      "tweetid": "1024",
+      "user": {
+         "screen-name": "miriamorous",
+         "lang": "en",
+         "friends_count": 69,
+         "statuses_count": 1068,
+         "name": "Miriam Songco",
+         "followers_count": 78
+      },
+      "send-time": datetime("2010-02-21T11:11:43-08:00"),
+      "referred-topics": {{ "commercials", "verizon", "att" }},
+      "message-text": "#verizon & #att #commercials, so competitive"
+   });
+
+insert into dataset TweetMessages(
+   {
+      "tweetid": "1025",
+      "user": {
+         "screen-name": "dj33",
+         "lang": "en",
+         "friends_count": 96,
+         "send-time": "2010-02-21T11:56:02-05:00",      
+         "statuses_count": 1696,
+         "name": "Don Jango",
+         "followers_count": 22
+      },
+      "send-time": datetime("2010-02-21T12:38:44-05:00"),
+      "referred-topics": {{ "charlotte" }},
+      "message-text": "Chillin at dca waiting for 900am flight to #charlotte and from there to providenciales"
+   });
+
+insert into dataset TweetMessages( 
+    { "tweetid": "1026", 
+      "user": { 
+         "screen-name": "reallyleila", 
+         "lang": "en", 
+         "friends_count": 106, 
+         "statuses_count": 107, 
+         "name": "Leila Samii", 
+         "followers_count": 52 
+       }, 
+       "send-time": datetime("2010-02-21T21:31:57-06:00"),
+       "referred-topics": {{ "verizon", "at&t", "iphone" }},
+       "message-text": "I think a switch from #verizon to #at&t may be in my near future... my smartphone is like a land line compared to the #iphone!"
+});
+
+write output to nc1:"rttest/open-closed_query-proposal.adm";
+
+for $tp1 in (
+    for $tweet in dataset('TweetMessages')
+        where some $topic in $tweet.referred-topics satisfies contains($topic, 'verizon')
+            for $tp in $tweet.referred-topics
+                return 
+                { "topic": $tp }
+)
+group by $tp2 := $tp1.topic with $tp1
+order by $tp2
+return { "topic": $tp2, "count": count($tp1) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal02.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal02.aql
new file mode 100644
index 0000000..36feac4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/query-proposal02.aql
@@ -0,0 +1,110 @@
+/*
+ * Description     : Insert open data into internal dataset and query the open data
+ * Expected Result : Success
+ * Date            : 23rd October 2012
+ * Notes           : This test was written to cover the scenario which is used in the proposal.
+ *                 : this is another variant of the test in query-proposal.aql
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type TweetMessageType as open {
+tweetid : string,
+user : {
+         screen-name: string,
+         lang: string,
+         friends_count: int32,
+         statuses_count: int32,
+         name: string,
+         followers_count: int32
+},    sender-location: point?,
+      send-time: datetime,
+      referred-topics: {{ string }},
+      message-text: string
+};
+
+create dataset TweetMessages(TweetMessageType)
+partitioned by key tweetid;
+
+insert into dataset TweetMessages(
+   {
+      "tweetid": "1023",
+      "user": {
+         "screen-name": "dflynn24",
+         "lang": "en",
+         "friends_count": 46,
+         "statuses_count": 987,
+         "name": "danielle flynn",
+         "followers_count": 47
+      },
+      "sender-location": create-point(40.904177,-72.958996),
+      "send-time": datetime("2010-02-21T11:56:02-05:00"),
+      "referred-topics": {{ "verizon" }},
+      "message-text": "i need a #verizon phone like nowwwww! : ("
+   });
+
+insert into dataset TweetMessages(
+   {
+      "tweetid": "1024",
+      "user": {
+         "screen-name": "miriamorous",
+         "lang": "en",
+         "friends_count": 69,
+         "statuses_count": 1068,
+         "name": "Miriam Songco",
+         "followers_count": 78
+      },
+      "send-time": datetime("2010-02-21T11:11:43-08:00"),
+      "referred-topics": {{ "commercials", "verizon", "att" }},
+      "message-text": "#verizon & #att #commercials, so competitive"
+   });
+
+insert into dataset TweetMessages(
+   {
+      "tweetid": "1025",
+      "user": {
+         "screen-name": "dj33",
+         "lang": "en",
+         "friends_count": 96,
+         "send-time": "2010-02-21T11:56:02-05:00",      
+         "statuses_count": 1696,
+         "name": "Don Jango",
+         "followers_count": 22
+      },
+      "send-time": datetime("2010-02-21T12:38:44-05:00"),
+      "referred-topics": {{ "charlotte" }},
+      "message-text": "Chillin at dca waiting for 900am flight to #charlotte and from there to providenciales"
+   });
+
+insert into dataset TweetMessages( 
+    { "tweetid": "1026", 
+      "user": { 
+         "screen-name": "reallyleila", 
+         "lang": "en", 
+         "friends_count": 106, 
+         "statuses_count": 107, 
+         "name": "Leila Samii", 
+         "followers_count": 52 
+       }, 
+       "send-time": datetime("2010-02-21T21:31:57-06:00"),
+       "referred-topics": {{ "verizon", "at&t", "iphone" }},
+       "message-text": "I think a switch from #verizon to #at&t may be in my near future... my smartphone is like a land line compared to the #iphone!"
+});
+
+write output to nc1:"rttest/open-closed_query-proposal02.adm";
+
+for $tweet in dataset('TweetMessages')
+    where some $reftopic in $tweet.referred-topics
+        satisfies contains($reftopic, 'verizon')
+            for $reftopic in $tweet.referred-topics
+            group by $topic := $reftopic with $tweet
+            order by $topic 
+            return 
+            {
+                "topic": $topic,
+                "count": count($tweet)
+            }
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_02.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_02.aql
index fad06ba..bd52181 100644
--- a/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_02.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_02.aql
@@ -5,10 +5,6 @@
  * Date             : 5th July 2012
  */
 
-drop dataverse test if exists;
-create dataverse test;
-use dataverse test;
-
 write output to nc1:"rttest/quantifiers_everysat_02.adm";
 
 let $a := [
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_03.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_03.aql
index 7f9824e..99b4844 100644
--- a/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_03.aql
@@ -5,24 +5,20 @@
  * Date             : 5th July 2012
  */
 
-drop dataverse test if exists;
-create dataverse test;
-use dataverse test;
-
 write output to nc1:"rttest/quantifiers_everysat_02.adm";
 
 let $a := [
 every $x in [1, 2] satisfies avg([$x, 1]) = 1,
-every $x in [1, 2] satisfies string($x) = "1",
-every $x in [1, 2] satisfies string-length(string($x)) = 1,
+every $x in ["1", "2"] satisfies string($x) = "1",
+every $x in ["1", "2"] satisfies string-length($x) = 1,
 every $x in [[1, 2],[10],[1,5,7,8]] satisfies count($x) = 1,
 every $x in [[2],[10],[8]] satisfies count($x) = 1,
-every $x in [1, 2] satisfies boolean("true"),
-every $x in [1, 2] satisfies not($x),
+every $x in [true, false] satisfies boolean("true"),
+every $x in [true,true] satisfies not($x),
 every $x in [1,2,3], $y in [4,5,6] satisfies $x + $y = 5,
 every $x in [1,2,3], $y in [4,5,6] satisfies $x - $y = 5,
 every $x in [1,2,3], $y in [4,5,6] satisfies $x * $y = 10,
-every $x in [1,2,3], $y in [4,5,6] satisfies string($x) = string($y),
+every $x in ["ab","cd"], $y in ["ab","de"] satisfies string($x) = string($y),
 every $x in [1,2,3], $y in [4,5,6] satisfies int32($x) = int32($y),
 every $x in [1,2,3], $y in [4,5,6] satisfies float($x) = float($y),
 every $x in [1,2,3], $y in [4,5,6] satisfies double($x) = double($y),
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_04.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_04.aql
new file mode 100644
index 0000000..b9eccfd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/everysat_04.aql
@@ -0,0 +1,23 @@
+/*
+ * Description    : Tests that universal quantification returns true/false correctly.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/quantifiers_everysat_04.adm";
+
+let $x := [
+every $x in [false,false] satisfies $x,
+every $x in [true,false] satisfies $x,
+every $x in [false,true] satisfies $x,
+every $x in [true,true] satisfies $x,
+every $x in [false,false] satisfies not($x),
+every $x in [true,false] satisfies not($x),
+every $x in [false,true] satisfies not($x),
+every $x in [true,true] satisfies not($x)
+]
+for $i in $x
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_03.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_03.aql
index 5995b9b..7178156 100644
--- a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_03.aql
@@ -1,13 +1,9 @@
 /*
- * Description     :  Test quantified expressions; some variable in [ordered list] satisfies expression.
+ * Description     : Test quantified expressions; some variable in [ordered list] satisfies expression.
  * Expected Result : Success
  * Date            : 6th July 2012
  */
 
-drop dataverse test if exists;
-create dataverse test;
-use dataverse test;
-
 write output to nc1:"rttest/quantifiers_somesat_03.adm";
 
 let $a := [
@@ -20,7 +16,7 @@
 some $x in [1, 2] satisfies avg([$x,1]) = 1,
 some $x in [1, 2] satisfies boolean("true"),
 some $x in [1, 2] satisfies boolean("false"),
-some $x in [1, 2] satisfies not($x),
+some $x in [true,false] satisfies not($x),
 some $x in [1, 2] satisfies $x = 1 or $x = 2,
 some $x in [1, 2] satisfies $x = 1 and ($x +1) = 2 
 ]
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_04.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_04.aql
index 8d92cbb..b308aa2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_04.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_04.aql
@@ -6,16 +6,11 @@
  * Date             : 5th July 2012
  */
 
-
-drop dataverse test if exists;
-create dataverse test;
-use dataverse test;
-
 write output to nc1:"rttest/quantifiers_somesat_04.adm";
 
 let $a := [
-some $x in ["foo","foobar","foot","fox"] satisfies string-length($x) = 1,
-some $x in [1,2,3,4,5,6,7,8] satisfies count($x) = 8,
+some $x in ["foo","foobar","foot","fox"] satisfies string-length($x) = 3,
+some $x in [[5,4,3,2],[1,2,3,4,5,6,7,8],[4,2,3,4]] satisfies count($x) = 8,
 some $x in [1, 2] satisfies $x = 1 or $x = 2,
 some $x in [1, 2] satisfies $x = 1 and ($x +1) = 2,
 some $x in ["A","B","C"] satisfies $x = "A",
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_05.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_05.aql
index fefd86d..4d802c7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_05.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_05.aql
@@ -5,10 +5,6 @@
  * Date             :  5th July 2012
  */
 
-drop dataverse test if exists;
-create dataverse test;
-use dataverse test;
-
 write output to nc1:"rttest/quantifiers_somesat_05.adm";
 
 let $a := [
diff --git a/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_06.aql b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_06.aql
new file mode 100644
index 0000000..6e8892c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/quantifiers/somesat_06.aql
@@ -0,0 +1,23 @@
+/*
+ * Description    : Tests that existential quantification returns true/false correctly.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/quantifiers_somesat_06.adm";
+
+let $x := [
+some $x in [false,false] satisfies $x,
+some $x in [true,false] satisfies $x,
+some $x in [false,true] satisfies $x,
+some $x in [true,true] satisfies $x,
+some $x in [false,false] satisfies not($x),
+some $x in [true,false] satisfies not($x),
+some $x in [false,true] satisfies not($x),
+some $x in [true,true] satisfies not($x)
+]
+for $i in $x
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/field-access-on-open-field.aql b/asterix-app/src/test/resources/runtimets/queries/records/field-access-on-open-field.aql
new file mode 100644
index 0000000..2592c67
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/records/field-access-on-open-field.aql
@@ -0,0 +1,24 @@
+/*
+ * Description    : Tests whether a field access on an open field (statically of type ANY) succeeds.
+ *                  Guards against regression to issue 207.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+  id : int32,
+  name : string
+}
+
+create dataset testds(TestType) partitioned by key id;
+
+insert into dataset testds({"id": 123, "name": "John Doe", "address": { "zip": 92617} });
+
+write output to nc1:"rttest/records_field-access-on-open-field.adm";
+
+for $l in dataset("testds")
+let $a := $l.address
+return $a.zip
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_1.aql b/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_1.aql
new file mode 100644
index 0000000..ff04a36
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_1.aql
@@ -0,0 +1,35 @@
+/*
+* Description  : Create an  dataset and load it from two file splits 
+                 Include whitespace between the elements in the comma-separated list of file paths.
+* Expected Res : Success
+* Issue        : 238
+* Date         : 7th Jan 2013
+*/
+
+/* scan and print an ADM file as a dataset of closed records */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as closed {
+  id: int32, 
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLPadm(DBLPType) 
+  partitioned by key id;
+
+// drop dataset DBLPadm;
+load dataset DBLPadm 
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
+(("path"="nc1://data/dblp-small/part-00000.adm, nc1://data/dblp-small/part-00001.adm"),("format"="adm"));
+
+write output to nc1:"rttest/scan_issue238_query_1.adm";
+
+for $paper in dataset('DBLPadm')
+order by $paper.id
+return $paper
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_2.aql b/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_2.aql
new file mode 100644
index 0000000..297e2f2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/issue238_query_2.aql
@@ -0,0 +1,36 @@
+/*
+* Description  : Create an  dataset and load it from two file splits 
+                 Include newline between the elements in the comma-separated list of file paths.
+* Expected Res : Success
+* Issue        : 238
+* Date         : 7th Jan 2013
+*/
+
+/* scan and print an ADM file as a dataset of closed records */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as closed {
+  id: int32, 
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLPadm(DBLPType) 
+  partitioned by key id;
+
+// drop dataset DBLPadm;
+load dataset DBLPadm 
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" 
+(("path"="nc1://data/dblp-small/part-00000.adm, 
+ nc1://data/dblp-small/part-00001.adm"),("format"="adm"));
+
+write output to nc1:"rttest/scan_issue238_query_2.adm";
+
+for $paper in dataset('DBLPadm')
+order by $paper.id
+return $paper
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/circle_accessor.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/circle_accessor.aql
new file mode 100644
index 0000000..1d48ebd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/circle_accessor.aql
@@ -0,0 +1,14 @@
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/spatial_circle_accessor.adm";
+
+let $circle := create-circle(create-point(6.0,3.0), 1.0)
+return {"circle-radius": get-radius($circle), "circle-center": get-center($circle)}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/create-rtree-index.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/create-rtree-index.aql
new file mode 100644
index 0000000..e755aa9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/create-rtree-index.aql
@@ -0,0 +1,34 @@
+/*
+ * Description    : Create r-tree indexes for all spatial data types.
+ * Success        : Yes
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type SpatialType as open {
+  id: int32,
+  point: point,
+  line1: line,
+  poly1: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData(SpatialType) partitioned by key id;
+create index rtree_index1 on MyData(point) type rtree;
+create index rtree_index2 on MyData(line1) type rtree;
+create index rtree_index3 on MyData(poly1) type rtree;
+create index rtree_index5 on MyData(rec) type rtree;
+create index rtree_index4 on MyData(circle) type rtree;
+
+write output to nc1:"rttest/spatial_create-rtree-index.adm";
+
+load dataset MyData 
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+for $a in dataset('MyData')
+return $a.id
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/line_accessor.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/line_accessor.aql
new file mode 100644
index 0000000..2085436
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/line_accessor.aql
@@ -0,0 +1,16 @@
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/spatial_line_accessor.adm";
+
+let $line := create-line(create-point(100.6,999.4), create-point(-872.0,-876.9))
+let $line_list := get-points($line)
+for $p in $line_list
+return $p
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/point_accessor.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/point_accessor.aql
new file mode 100644
index 0000000..c408630
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/point_accessor.aql
@@ -0,0 +1,14 @@
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/spatial_point_accessor.adm";
+
+let $point := create-point(2.3,5.0)
+return {"x-coordinate": get-x($point), "y-coordinate": get-y($point)}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/polygon_accessor.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/polygon_accessor.aql
new file mode 100644
index 0000000..a181648
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/polygon_accessor.aql
@@ -0,0 +1,16 @@
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/spatial_polygon_accessor.adm";
+
+let $polygon := create-polygon(create-point(1.0,1.0), create-point(2.0,2.0), create-point(3.0,3.0), create-point(4.0,4.0))
+let $polygon_list := get-points($polygon)
+for $p in $polygon_list
+return $p
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-rectangle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-rectangle.aql
index 90c9f77..b32b6a3 100644
--- a/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-rectangle.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-rectangle.aql
@@ -15,7 +15,7 @@
 write output to nc1:"rttest/spatial_rectangle-intersect-rectangle.adm";
 
 for $o in dataset('MyData')
-where spatial-intersect($o.rec, create-rectangle(create-point(-1.0,5.0), create-point(4.5,9.0)))
+where spatial-intersect($o.rec, create-rectangle(create-point(4.5,9.0), create-point(-1.0,5.0)))
 order by $o.id
 return {"id":$o.id}
  
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle_accessor.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle_accessor.aql
new file mode 100644
index 0000000..676888c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle_accessor.aql
@@ -0,0 +1,16 @@
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/spatial_rectangle_accessor.adm";
+
+let $rectangle := create-rectangle(create-point(9.2,49.0), create-point(77.8,111.1))
+let $rectangle_list := get-points($rectangle)
+for $p in $rectangle_list
+return $p
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/concat1.aql b/asterix-app/src/test/resources/runtimets/queries/string/concat_01.aql
similarity index 81%
rename from asterix-app/src/test/resources/runtimets/queries/string/concat1.aql
rename to asterix-app/src/test/resources/runtimets/queries/string/concat_01.aql
index a6ce63b..2a0b1ab 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/concat1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/concat_01.aql
@@ -2,7 +2,7 @@
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/string_concat1.adm";
+write output to nc1:"rttest/string_concat_01.adm";
 
 let $x :=  ["aa", "25991", "bb", "31526"]
 let $c := string-concat($x)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/concat_02.aql b/asterix-app/src/test/resources/runtimets/queries/string/concat_02.aql
new file mode 100644
index 0000000..c716fcb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/concat_02.aql
@@ -0,0 +1,15 @@
+/*
+ * Description    : Test concat-string function with nulls in the list which is passed as an argument.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/string_concat_02.adm";
+
+let $a := string-concat([null])
+let $b := string-concat([null, "foo"])
+let $c := string-concat(["foo", null])
+return {"a": $a, "b": $b, "c": $c}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql
new file mode 100644
index 0000000..a66b00f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql
@@ -0,0 +1,28 @@
+/*
+ * Test case Name : cpttostr01.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Pass the codepoints which are in the internal dataset to the function. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open{
+id:int32,
+cpt:[int32]
+}
+
+create dataset testds(TestType) partitioned by key id;
+
+// insert codepoint data into internal dataset testds here into the cpt attribute
+
+insert into dataset testds({"id":123,"cpt":[0048,0045,0057,0044,0065,0045,0090]});
+
+write output to nc1:"rttest/string_cpttostr01.adm";
+
+for $l in dataset('testds')
+return codepoint-to-string($l.cpt)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/cpttostr02.aql b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr02.aql
new file mode 100644
index 0000000..1e99989
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr02.aql
@@ -0,0 +1,17 @@
+/*
+ * Test case Name : cpttostr02.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Inputs are codepoint values for lowecase, uppercase and special characters
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+write output to nc1:"rttest/string_cpttostr02.adm";
+
+let $c1 := codepoint-to-string([0065,0066,0067,0068,0069,0070,0071,0072,0073,0074,0075,0076,0077,0078,0079,0080,0081,0082,0083,0084,0085,0086,0087,0088,0089,0090]) 
+
+let $c2 := codepoint-to-string([0097,0098,0099,0100,0101,0102,0103,0104,0105,0106,0107,0108,0109,0110,0111,0112,0113,0114,0115,0116,0117,0118,0119,0120,0121,0122]) 
+
+let $c3 := codepoint-to-string([0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0052,0053,0054,0055,0063,0064]) 
+
+return {"c1":$c1,"c2":$c2,"c3":$c3}
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/cpttostr04.aql b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr04.aql
new file mode 100644
index 0000000..9e177c0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr04.aql
@@ -0,0 +1,13 @@
+/*
+ * Test case Name : cpttostr04.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+//Input = Output
+
+write output to nc1:"rttest/string_cpttostr04.adm";
+
+let $c1 := codepoint-to-string(string-to-codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"))
+return { "c1":$c1 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/endwith02.aql b/asterix-app/src/test/resources/runtimets/queries/string/endwith02.aql
new file mode 100644
index 0000000..cfca775
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/endwith02.aql
@@ -0,0 +1,16 @@
+/*
+ * Testcase Name : endwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
+write output to nc1:"rttest/string_endwith02.adm";
+
+for $a in [end-with("aBCDEFghIa",codepoint-to-string([0041])),
+end-with("AbCDEFghIA",codepoint-to-string([0041])),
+end-with("AbCdEfGhIjKlMnOpQrStUvWxYz","xYz"),
+end-with("abcdef",lowercase("ABCDEf")),
+end-with("abcdef","abcdef"),
+end-with("abcdef123","ef123")]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql b/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql
new file mode 100644
index 0000000..832efbc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql
@@ -0,0 +1,33 @@
+/*
+ * Testcase Name : endwith03.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
+// create internal dataset, insert string data into string field and pass the string filed as input to end-with function
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as {
+name:string
+}
+
+create dataset testds(TestType) partitioned by key name;
+
+insert into dataset testds({"name":"Jim Jones"});
+insert into dataset testds({"name":"Ravi Kumar"});
+insert into dataset testds({"name":"Bruce Li"});
+insert into dataset testds({"name":"Marian Jones"});
+insert into dataset testds({"name":"Phil Jones"});
+insert into dataset testds({"name":"I am Jones"});
+
+write output to nc1:"rttest/string_endwith03.adm";
+
+for $l in dataset('testds')
+order by $l.name
+where end-with($l.name,"Jones")
+return $l
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/length.aql b/asterix-app/src/test/resources/runtimets/queries/string/length_01.aql
similarity index 81%
rename from asterix-app/src/test/resources/runtimets/queries/string/length.aql
rename to asterix-app/src/test/resources/runtimets/queries/string/length_01.aql
index d78d986..8186f6b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/length.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/length_01.aql
@@ -2,7 +2,7 @@
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/string_length.adm";
+write output to nc1:"rttest/string_length_01.adm";
 
 let $c1 := string-length("hellow")
 let $c2 := string-length("")
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/length_02.aql b/asterix-app/src/test/resources/runtimets/queries/string/length_02.aql
new file mode 100644
index 0000000..3cc33e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/length_02.aql
@@ -0,0 +1,8 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/string_length_02.adm";
+
+for $x in ["ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "ninety"]
+return string-length($x)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches02.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches02.aql
new file mode 100644
index 0000000..1018f02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches02.aql
@@ -0,0 +1,23 @@
+/*
+ * Testcase Name  :  matches02.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
+write output to nc1:"rttest/string_matches02.adm";
+
+let $c1:="Hello World"
+let $c2:="Hello World"
+let $c3:=matches($c1,$c2)
+let $c4:=matches("Asterix for Dummies","Asterix for Dummies")
+let $c5:=matches("semistructured data",lowercase("SEMISTRUCTURED DATA"))
+let $c6:=matches("Mega Living!","Mega")
+let $c7:=matches("Mega Living!","ving!")
+let $c8:=matches("Mega Living!"," ")
+let $c9:=matches("Mega Living!","a l")
+let $c10:=matches("Mega Living!","")
+let $c11:=matches(" "," ")
+let $c12:=matches("aaaa","aaaaa")
+return {"c3":$c3,"c4":$c4,"c5":$c5,"c6":$c6,"c7":$c7,"c8":$c8,"c9":$c9,"c10":$c10,"c11":$c11,"c12":$c12}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches03.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches03.aql
new file mode 100644
index 0000000..7f4623c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches03.aql
@@ -0,0 +1,26 @@
+/*
+ * Testcase Name  :  matches03.aql
+ * Description    :  Positive tests
+ *                :  Test matches functions with regular expressions as third input parameter
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
+
+write output to nc1:"rttest/string_matches03.adm";
+
+for $a in [matches("1234567890","[^a-z]"),
+matches("1234567890","[^a-zA-Z]"),
+matches("abcdefghABCDEFGH","[^a-zA-Z]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[^a-zA-Z]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[^A-Z]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[^a-z]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[^0-9]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[0-9]"),
+matches("adefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[a-z&&[^bc]]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[a-z&&[^bc]]"),
+matches("bc","[a-z&&[^bc]]"),
+matches("mnop","[a-z&&[^m-p]]"),
+matches("abcdmnop","[a-z&&[^m-p]]")]
+return $a
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches04.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches04.aql
new file mode 100644
index 0000000..829a176
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches04.aql
@@ -0,0 +1,17 @@
+/*
+ * Testcase Name  :  matches04.aql
+ * Description    :  Positive tests
+ * Success        :  Yes (tests to check for patterns using regular expressions)
+ * Date           :  20th April 2012
+ */
+
+write output to nc1:"rttest/string_matches04.adm";
+
+for $a in [matches("UCI UCI UCI UCI UCI UCI","[UCI{6}]"),
+matches("UCI UCI UCI UCI UCI UCI","[UCI{3,6}]"),
+matches("UCI UCI UCI UCI UCI UCI","[UCI{7}]"),
+matches("UCI UCI UCI UCI UCI UCI","[UCI{1}]"),
+matches("UCI UCI UCI","[UCI+]"),
+matches("false","[true|false]"),
+matches("YX","[XY]")]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql
new file mode 100644
index 0000000..2f7b83e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql
@@ -0,0 +1,34 @@
+/*
+ * Testcase Name  :  matches05.aql
+ * Description    :  Positive tests
+ *                :  Create two internal datasets and insert string data and perform match of fname using matches function.
+ * Success        :  Yes
+ * Date           :  25th April 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType1 as{
+fname:string,
+lname:string,
+id:int32
+}
+
+create dataset testds1(TestType1) partitioned by key id;
+
+insert into dataset testds1({"fname":"Test","lname":"Test","id":123});
+insert into dataset testds1({"fname":"Testa","lname":"Test","id":124});
+insert into dataset testds1({"fname":"Test1","lname":"Test1","id":125});
+insert into dataset testds1({"fname":"Test","lname":"Testb","id":126});
+insert into dataset testds1({"fname":"Test2","lname":"Test2","id":127});
+
+write output to nc1:"rttest/string_matches05.adm";
+
+//Perform the match for fname and lname
+for $l in dataset('testds1')
+order by $l.id
+where matches($l.fname,$l.lname)
+return $l
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches06.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches06.aql
new file mode 100644
index 0000000..0e18a84
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches06.aql
@@ -0,0 +1,25 @@
+/*
+ * Description  : Test matches string function using regular expressions
+ * Expected Res : Success
+ * Date         : May 21 2012
+ */
+
+write output to nc1:"rttest/string_matches06.adm";
+
+for $a in [matches("mnop","."),
+matches("abcdefABCDEF","/d"),
+matches("12345","\d"),
+matches("abcdefGHIJK","\D"),
+matches("       ","\s"),
+matches("       ","\S"),
+matches("Welcome to pattern matching!","[a-zA-Z_0-9]"),
+matches("!@#$%^&*()","[a-zA-Z_0-9]"),
+matches("!@#$%^&*()","[^\W]"),
+matches("!@#$%^&*","[^\w]"),
+matches("0xffff","[\p{XDigit}]"),
+matches("FFFFFFFF","[\p{XDigit}]"),
+matches("abcdefgh","[\p{javaLowerCase}]"),
+matches("ABCDEF","[\p{javaLowerCase}]"),
+matches(codepoint-to-string([0163]),"[\p{Sc}]")]
+return $a
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql
new file mode 100644
index 0000000..1e96b5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql
@@ -0,0 +1,16 @@
+/*
+ * Testcase Name  :  matches11.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  20th April 2012
+ */
+
+write output to nc1:"rttest/string_matches11.adm";
+
+for $a in [matches("hello",null),
+matches("hello","helllo"),
+matches("hello"," "),
+matches(null,"hello"),
+matches("hello","[^a-z]")]
+return $a
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/startwith02.aql b/asterix-app/src/test/resources/runtimets/queries/string/startwith02.aql
new file mode 100644
index 0000000..b4ab93a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/startwith02.aql
@@ -0,0 +1,26 @@
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+write output to nc1:"rttest/string_startwith02.adm";
+
+for $a in [start-with("Hello","H"),
+start-with("Hello",lowercase("He")),
+start-with("Hello",""),
+start-with("Hello"," "),
+start-with("Hello",null),
+start-with("abcdef",lowercase("ABCDEf")),
+start-with("abcdef","abcdef"),
+start-with("abcdef","abc "),
+start-with("abc\tdef","abc\t"),
+start-with(" abcdef","abc"),
+start-with("0x1FF","0"),
+start-with("<ID>","<"),
+start-with("aBCDEFghI",codepoint-to-string([0041])),
+start-with("AbCDEFghI",codepoint-to-string([0041]))]
+return $a
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql b/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql
new file mode 100644
index 0000000..8aed603
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql
@@ -0,0 +1,35 @@
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+// Create internal dataset, insert string data into string field and pass the string field as first input to start-with function
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as {
+name:string
+}
+
+create dataset testds(TestType) partitioned by key name;
+
+insert into dataset testds({"name":"John Smith"});
+insert into dataset testds({"name":"John Doe"});
+insert into dataset testds({"name":"John Wayne"});
+insert into dataset testds({"name":"Johnson Ben"});
+insert into dataset testds({"name":"Johnny Walker"});
+insert into dataset testds({"name":"David Smith"});
+insert into dataset testds({"name":"Not a Name"});
+
+write output to nc1:"rttest/string_startwith03.adm";
+
+// Return all names that start with John
+
+for $l in dataset('testds')
+order by $l.name
+where start-with($l.name,"John")
+return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql b/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql
new file mode 100644
index 0000000..0b3941d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql
@@ -0,0 +1,38 @@
+/*
+ * Test case Name : strconcat01.aql
+ * Description    : Test string-concat([string]) function.
+ *                : Pass the strings(which are in internal dataset) to string-concat function for concatenation. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open{
+id:int32,
+fname:string,
+lname:string
+}
+
+create dataset testds(TestType) partitioned by key id;
+
+// insert string data into internal dataset testds into the name attribute
+
+insert into dataset testds({"id":123,"fname":"John","lname":"Smith"});
+insert into dataset testds({"id":124,"fname":"Bob","lname":"Jones"});
+insert into dataset testds({"id":125,"fname":"Mike","lname":"Carey"});
+insert into dataset testds({"id":126,"fname":"Chen","lname":"Li"});
+insert into dataset testds({"id":121,"fname":"Young Seok","lname":"Kim"});
+insert into dataset testds({"id":122,"fname":"Alex","lname":"Behm"});
+insert into dataset testds({"id":127,"fname":"Raman","lname":"Grover"});
+insert into dataset testds({"id":128,"fname":"Yingyi","lname":"Bu"});
+insert into dataset testds({"id":129,"fname":"Vinayak","lname":"Borkar"});
+
+write output to nc1:"rttest/string_strconcat01.adm";
+
+for $l in dataset('testds')
+order by $l.id
+return { "Full Name": string-concat([$l.fname,$l.lname]) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strconcat02.aql b/asterix-app/src/test/resources/runtimets/queries/string/strconcat02.aql
new file mode 100644
index 0000000..4991bde
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strconcat02.aql
@@ -0,0 +1,11 @@
+/*
+ * Description    : Test string-concat([string]) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+
+write output to nc1:"rttest/string_strconcat02.adm";
+
+for $a in [string-concat([codepoint-to-string(string-to-codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")),codepoint-to-string(string-to-codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")),codepoint-to-string(string-to-codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"))]),string-concat([" ","a","b","  ","c","d","e","f","g","p","o","q","r","s","t"," "]),string-concat(["This is a test","and all tests must pass","and life is good..."])]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strlen02.aql b/asterix-app/src/test/resources/runtimets/queries/string/strlen02.aql
new file mode 100644
index 0000000..852570f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strlen02.aql
@@ -0,0 +1,27 @@
+/*
+ * Description    : Test string-length(string) function 
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+
+/*
+for $a in [ string-length("abcdefghijklmnopqrstu"),
+string-length("ABCDEFGHIJKLMNOPQRSTU"),
+string-length("abcdEFGHijklMNOPqrstu"),
+string-length("abcd EFGH ijkl MNOP qrstu"),
+string-length("   Hello World    !!!!....:-)"),
+string-length(string-concat(["test string to","concatenate"])),
+string-length("~!@#$%^&*()_+{}:?<>/.,';`][\")]
+return $a
+*/
+
+write output to nc1:"rttest/string_strlen02.adm";
+
+for $a in [ string-length("abcdefghijklmnopqrstu"),
+string-length("ABCDEFGHIJKLMNOPQRSTU"),
+string-length("abcdEFGHijklMNOPqrstu"),
+string-length("abcd EFGH ijkl MNOP qrstu"),
+string-length("   Hello World    !!!!....:-)"),
+string-length("~!@#$%^&*()_+{}:?<>/.,';`][\")]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql b/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql
new file mode 100644
index 0000000..bba2a7f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql
@@ -0,0 +1,37 @@
+/*
+ * Description    : Test string-length(string) function 
+ * Expected Res   : Success
+ * Date           : 19th April 2012
+ */
+
+
+// Create internal dataset, insert string data and pass the string attribute to string-length function, and verify results.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as {
+name:string
+}
+
+create dataset testds(TestType) partitioned by key name;
+
+insert into dataset testds({"name":"Maradona"});
+insert into dataset testds({"name":"Pele"});
+insert into dataset testds({"name":"Roberto Baggio"});
+insert into dataset testds({"name":"Beckham David"});
+insert into dataset testds({"name":"Rooney"});
+insert into dataset testds({"name":"Ronaldinho"});
+insert into dataset testds({"name":"Ronaldo"});
+insert into dataset testds({"name":"Zinadine Zidane"});
+insert into dataset testds({"name":"Cristiano Ronaldo"});
+insert into dataset testds({"name":"Messi"});
+insert into dataset testds({"name":"Tevez"});
+insert into dataset testds({"name":"Henry"});
+
+write output to nc1:"rttest/string_strlen03.adm";
+
+for $l in dataset('testds')
+order by $l.name
+return string-length($l.name)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strtocpt01.aql b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt01.aql
new file mode 100644
index 0000000..fdbf014
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt01.aql
@@ -0,0 +1,10 @@
+/*
+ * Description  : Test string to codepoint function with valid inputs
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
+write output to nc1:"rttest/string_strtocpt01.adm";
+
+let $x := "ABCDEFGHIJKLMNOPQRSTUVWXYZ-01234567890"
+return string-to-codepoint($x)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02.aql b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02.aql
new file mode 100644
index 0000000..b203f6d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02.aql
@@ -0,0 +1,10 @@
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
+write output to nc1:"rttest/string_strtocpt02.adm";
+
+let $x := "\"'-=_+|\,./<>?:;~`"
+return string-to-codepoint($x)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strtocpt03.aql b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt03.aql
new file mode 100644
index 0000000..6daf0fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt03.aql
@@ -0,0 +1,10 @@
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
+write output to nc1:"rttest/string_strtocpt03.adm";
+
+let $x := "!@#$%^&*()"
+return string-to-codepoint($x)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr01.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr01.aql
new file mode 100644
index 0000000..791e7c0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr01.aql
@@ -0,0 +1,30 @@
+/*
+ * Testcase Name  : substr01.aql
+ * Description    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
+write output to nc1:"rttest/string_substr01.adm";
+
+let $str1:="Hello World"
+let $str2:=substring2($str1,10)
+
+let $str3:="This is a test string"
+let $str4:=substring2($str3,21)
+
+let $str5:="This is a test string"
+let $str6:=substring2($str5,22)
+
+let $str7:="This is a test string"
+let $str8:=substring2($str7,0)
+
+let $str9:="This is a test string"
+let $str10:=substring2($str9,-1)
+
+let $str11:="This is a test string"
+let $str12:="This is a another test string"
+let $str13:=substring2(string-concat([$str11,$str12]),21)
+
+let $str14:=substring2("UC Irvine",string-length("UC Irvine")/2)
+return { "str2":$str2,"str4":$str4,"str6":$str6,"str8":$str8,"str10":$str10,"str13":$str13,"str14":$str14}
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr04.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr04.aql
new file mode 100644
index 0000000..880499c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr04.aql
@@ -0,0 +1,21 @@
+/*
+ * Testcase Name  : substr04.aql
+ * Description    : Test substring2(string,position,position) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
+write output to nc1:"rttest/string_substr04.adm";
+
+for $a in [ substring2("hello world",7,11),
+substring2("hello world",1,11),
+substring2("hello world",3,7),
+substring2("ABCD",3,6),
+substring2("ABCD",0,4),
+substring2("UC Irvine",4,string-length("UC Irvine")),
+substring2("UC Irvine",0,string-length("UC Irvine")),
+substring2("UC Irvine",1,string-length("UC Irvine")),
+substring2(substring2("UC Irvine",4),0,string-length("Irvine")),
+substring2(substring2("UC Irvine",4),0,(string-length("Irvine")/2))
+]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql
new file mode 100644
index 0000000..fbdcba4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql
@@ -0,0 +1,33 @@
+/*
+ * Testcase Name  : substr05.aql
+ * Description    : Test substring2(string,position,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+// To test substring2 function with string data stored in an internal dataset.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+name : string
+}
+
+create dataset testdst(TestType) partitioned by key name;
+
+insert into dataset testdst({"name":"UC Berkeley"});
+insert into dataset testdst({"name":"UC Irvine"});
+insert into dataset testdst({"name":"UC LA"});
+insert into dataset testdst({"name":"UC Riverside"});
+insert into dataset testdst({"name":"UC San Diego"});
+insert into dataset testdst({"name":"UC Santa Barbara"});
+insert into dataset testdst({"name":"UT Austin "});
+insert into dataset testdst({"name":"UT Dallas"});
+
+write output to nc1:"rttest/string_substr05.adm";
+
+for $a in dataset('testdst')
+order by $a.name
+return substring2($a.name,4,string-length($a.name));
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql
new file mode 100644
index 0000000..82d21c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql
@@ -0,0 +1,32 @@
+/*
+ * Description    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+// To test substring function with string data stored in an internal dataset.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+name : string
+}
+
+create dataset testdst(TestType) partitioned by key name;
+
+insert into dataset testdst({"name":"UC Berkeley"});
+insert into dataset testdst({"name":"UC Irvine"});
+insert into dataset testdst({"name":"UC LA"});
+insert into dataset testdst({"name":"UC Riverside"});
+insert into dataset testdst({"name":"UC San Diego"});
+insert into dataset testdst({"name":"UC Santa Barbara"});
+insert into dataset testdst({"name":"UT Austin "});
+insert into dataset testdst({"name":"UT Dallas"});
+
+write output to nc1:"rttest/string_substr06.adm";
+
+for $a in dataset('testdst')
+order by $a.name
+return substring2($a.name,4);
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase02.aql b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase02.aql
new file mode 100644
index 0000000..2c16e01
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase02.aql
@@ -0,0 +1,23 @@
+/*
+ * Testcase Name : toLowerCas02.aql
+ * Description   : Test lowercase(string) function
+ *               : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+write output to nc1:"rttest/string_toLowerCase02.adm";
+
+for $a in [lowercase("a   b  c  d  e  f  g"),
+    lowercase("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"),
+    lowercase("abcdefghij KLMNOP qrstu VWXYZ"),
+    lowercase("abcdefghijklmnopqrstuvwxyz"),
+    lowercase("this is a test string"),
+    lowercase("smaller string"),
+    lowercase("ABCD"),
+    lowercase("AbCdEfGhIjKlMnOpQrStUvWxYz"),
+    lowercase("abcdefghijkABCDEFGHIJK"),
+    lowercase("HIJKLMNOPQRhijklmnopqr"),
+    lowercase(substring2("ABCDEFghIJKLMnopQRSTuvwxYZ01234",0)),
+    lowercase("A33B2CD1EF78GHijk123LMNopqrstUVW3x2y01035Z")]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql
new file mode 100644
index 0000000..411dacf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql
@@ -0,0 +1,39 @@
+/*
+ * Test case Name : toLowerCas03.aql
+ * Description    : Test lowercase(string) function 
+ *                : This test case covers Positive tests
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+
+// Create internal dataset, insert string data and pass the string attribute to lowercase function, and verify results.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as {
+name:string
+}
+
+create dataset testds(TestType) partitioned by key name;
+
+insert into dataset testds({"name":"Maradona"});
+insert into dataset testds({"name":"Pele"});
+insert into dataset testds({"name":"Roberto Baggio"});
+insert into dataset testds({"name":"Beckham David"});
+insert into dataset testds({"name":"Rooney"});
+insert into dataset testds({"name":"Ronaldinho"});
+insert into dataset testds({"name":"Ronaldo"});
+insert into dataset testds({"name":"Zinadine Zidane"});
+insert into dataset testds({"name":"Cristiano Ronaldo"});
+insert into dataset testds({"name":"Messi"});
+insert into dataset testds({"name":"Tevez"});
+insert into dataset testds({"name":"Henry"});
+
+write output to nc1:"rttest/string_toLowerCase03.adm";
+
+for $l in dataset('testds')
+order by $l.name
+return lowercase($l.name)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase04.aql b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase04.aql
new file mode 100644
index 0000000..3d99aab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase04.aql
@@ -0,0 +1,12 @@
+/*
+ * Test case Name : toLowerCas04.aql
+ * Description    : Test lowercase(string) function 
+ *                : Convert all upper case english alphabets A-Z to lower case a-z
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+write output to nc1:"rttest/string_toLowerCase04.adm";
+
+for $a in[lowercase(codepoint-to-string([0065,0066,0067,0068,0069,0070,0071,0072,0073,0074,0075,0076,0077,0078,0079,0080,0081,0082,0083,0084,0085,0086,0087,0088,0089,0090])),lowercase(string-concat(["ABCDEFGHIJKLMNOP","QRSTUVWXYZ"]))]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt.aql b/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt.aql
index b53fc877..af39b3f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/tpch/q1_pricing_summary_report_nt.aql
@@ -1,7 +1,5 @@
 drop dataverse tpch if exists;
 create dataverse tpch;
-  
-
 use dataverse tpch;
 
 create type LineItemType as closed {
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/f01.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/f01.aql
new file mode 100644
index 0000000..7f87de7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/f01.aql
@@ -0,0 +1,14 @@
+/*
+ * Description  : Invoke a built-in function with incorrect number of arguments
+ * Expected Res : Failure
+ * Date         : Nov 13th 2012
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_f01.adm";
+
+let $c1 := int8()
+return $c1
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue201.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue201.aql
new file mode 100644
index 0000000..0505179
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-issue201.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : This test case is to verify the fix for issue201
+ 				: https://code.google.com/p/asterixdb/issues/detail?id=201
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+ 
+write output to nc1:"rttest/user-defined-functions_query-issue201.adm";
+
+let $x:=range(1,100)
+for $i in $x
+return $i
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf01.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf01.aql
new file mode 100644
index 0000000..35718b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf01.aql
@@ -0,0 +1,18 @@
+/*
+ * Description  : Pass an ordered list as input to UDF
+ *              : and return that ordered list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf01.adm";
+
+create function test.echo($list){
+$list
+}
+
+for $a in [1,2,3,4,5,6,7,8,9,10]
+return test.echo($a)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf02.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf02.aql
new file mode 100644
index 0000000..2605f7a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf02.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Pass an ordered list as input to UDF and return the zeroth element of that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf02.adm";
+
+create function test.getFirst($list){
+$list[0]
+}
+
+for $a in [[1,2],[3,4]]
+return test.getFirst($a)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf03.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf03.aql
new file mode 100644
index 0000000..747f29d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf03.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : Pass an ordered list as input to UDF and return the zeroth element of that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ * Ignored      : Not part of test build due to Issue 200
+ */
+
+// This test is returning NPE... Issue 200 
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf03.adm";
+
+create function test.echo($list){
+$list
+}
+
+for $a in [[1,2],["A","B"],["UCLA","UCSD","UCR","UCI"]]
+return test.echo($a)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf04.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf04.aql
new file mode 100644
index 0000000..bd6544f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf04.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Pass as input an ordered list of Records as input to UDF and return the list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf04.adm";
+
+create function test.echo($list){
+$list
+}
+
+for $a in [{"name":"John","age":45,"id":123},{"name":"Jim","age":55,"id":103},{"name":"Bill","age":35,"id":125}]
+return test.echo($a)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf05.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf05.aql
new file mode 100644
index 0000000..2429f1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf05.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Create UDF and bind its return value to a variable and return that variable
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf05.adm";
+
+create function test.echo($a){
+$a
+}
+
+let $b:=1234
+return test.echo($b)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf06.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf06.aql
new file mode 100644
index 0000000..3301d5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf06.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Pass input of type double to UDF
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf06.adm";
+
+create function test.echo($a){
+$a
+}
+
+let $b:=1234.1
+return test.echo($b)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf07.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf07.aql
new file mode 100644
index 0000000..0280e92
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf07.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Pass value of type float to UDF
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf07.adm";
+
+create function test.echo($a){
+$a
+}
+
+let $b:=1234.1f
+return test.echo($b)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf08.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf08.aql
new file mode 100644
index 0000000..5dfb9a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf08.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Pass a sting as input to UDF
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf08.adm";
+
+create function test.echo($a){
+$a
+}
+
+let $a:="This is a test string"
+return test.echo($a)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf09.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf09.aql
new file mode 100644
index 0000000..b16e2dd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf09.aql
@@ -0,0 +1,31 @@
+/*
+ * Description  : Create UDF to read from internal dataset 
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf09.adm";
+
+create type test.TestType as open {
+id : int32
+}
+
+create dataset test.t1(TestType) partitioned by key id;
+
+insert into dataset test.t1({"id":345});
+insert into dataset test.t1({"id":315});
+insert into dataset test.t1({"id":245});
+insert into dataset test.t1({"id":385});
+insert into dataset test.t1({"id":241});
+insert into dataset test.t1({"id":745});
+insert into dataset test.t1({"id":349});
+insert into dataset test.t1({"id":845});
+
+create function test.readDataset($a) {
+$a
+}
+   
+test.readDataset(for $a in dataset('test.t1') order by $a.id return $a);
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf10.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf10.aql
new file mode 100644
index 0000000..d0da4e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf10.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Create UDF and pass an unordered list as input and return that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf10.adm";
+
+create function test.echo($uolist){
+$uolist
+}
+
+let $a:={{"this is optional data","this is extra data","open types are good"}}
+return test.echo($a)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf11.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf11.aql
new file mode 100644
index 0000000..b842c93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf11.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Create UDF to return ordered list of integers
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf11.adm";
+
+create function test.OList(){
+[1,2,3,4,5,6,7,8,9,10]
+}
+
+for $a in test.OList()
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf12.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf12.aql
new file mode 100644
index 0000000..e3f8122
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf12.aql
@@ -0,0 +1,16 @@
+/*
+ * Description  : Create UDF to add two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf12.adm";
+
+create function test.foo($a,$b) {
+$a+$b
+}
+
+test.foo(100,200)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf13.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf13.aql
new file mode 100644
index 0000000..533def7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf13.aql
@@ -0,0 +1,16 @@
+/*
+ * Description  : Create UDF to subtract two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf13.adm";
+
+create function test.foo($a,$b) {
+$a - $b
+}
+
+test.foo(400,200)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf14.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf14.aql
new file mode 100644
index 0000000..fc3447d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf14.aql
@@ -0,0 +1,16 @@
+/*
+ * Description  : Create UDF to multiply two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf14.adm";
+
+create function test.foo($a,$b) {
+$a*$b
+}
+
+test.foo(400,200)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf15.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf15.aql
new file mode 100644
index 0000000..4b4992a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf15.aql
@@ -0,0 +1,21 @@
+/*
+ * Description  : Create UDF that returns a heterogeneous ordered list
+ *              : invoke the UDF in the FOR expression of FLWOR
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ * Ignored      : Not part of current tests because of Issue 200
+ */
+
+// this test resturns NPE:Issue 166
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf15.adm";
+
+create function test.OList2(){
+[[1,2,3,4,5,6,7,8,9,10],["a","b","c","d","e","f","g","h","y"]]
+}
+
+for $a in test.OList2()
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf16.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf16.aql
new file mode 100644
index 0000000..e9f0742
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf16.aql
@@ -0,0 +1,18 @@
+/*
+ * Description  : Create UDF that returns string
+ *              : compute the string lenght of the string
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf16.adm";
+
+create function test.fn02(){
+"Welcome to the world of Asterix"
+}
+
+let $str := test.fn02()
+return string-length($str)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf17.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf17.aql
new file mode 100644
index 0000000..b98d123
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf17.aql
@@ -0,0 +1,22 @@
+/*
+ * Description  : Create UDF and invoke it from another UDF and 
+ *              : child UDF returns a string to the parent.
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf17.adm";
+
+create function test.parent(){
+test.child()
+}
+
+create function test.child() {
+"This data is from the child function"
+}
+
+let $str := test.parent()
+return $str
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf18.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf18.aql
new file mode 100644
index 0000000..aa6a57b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf18.aql
@@ -0,0 +1,17 @@
+/*
+ * Description  : Create UDF and invoke the UDF from with in asterix built-in function
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf18.adm";
+
+create function test.fn06(){
+false
+}
+
+let $val := not(test.fn06())
+return $val
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf19.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf19.aql
new file mode 100644
index 0000000..87c39a5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf19.aql
@@ -0,0 +1,23 @@
+/*
+ * Description  : Create UDF and invoke in the WHERE clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf19.adm";
+
+create function test.pie(){
+3.14
+}
+
+create function test.area($radius){
+test.pie() * $radius * $radius
+}
+
+for $a in [2,4,6,8,10,12]
+where test.area($a) > 100
+return test.area($a)
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf20.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf20.aql
new file mode 100644
index 0000000..e0a16a1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf20.aql
@@ -0,0 +1,23 @@
+/*
+ * Description  : Create UDF and invoke in the WHERE clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf20.adm";
+
+create function test.pie(){
+3.14
+}
+
+create function test.area($radius){
+test.pie() * $radius * $radius
+}
+
+for $a in [2,4,6,8,10,12]
+where test.area($a) > 100
+return { "radius" : $a,"area" : test.area($a) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf21.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf21.aql
new file mode 100644
index 0000000..7e943c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf21.aql
@@ -0,0 +1,18 @@
+/*
+ * Description  : Create UDF to verify if input is odd
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf21.adm";
+
+create function test.isOdd($b){
+$b%2 != 0
+}
+
+for $a in [10,20,2,30,4,3,6,44,5,7,9,1,13,17,992,19,40,50,60,25,45,65,75]
+where test.isOdd($a)
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf22.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf22.aql
new file mode 100644
index 0000000..83e19e6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf22.aql
@@ -0,0 +1,18 @@
+/*
+ * Description  : Create UDF to concatenate two input strings.
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf22.adm";
+
+create function test.getFullName($fname,$lname){
+string-concat([$fname,$lname])
+}
+
+let $fn := "Bob"
+let $ln := "Harbus"
+return test.getFullName($fn,$ln)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf23.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf23.aql
new file mode 100644
index 0000000..a2d8ec5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf23.aql
@@ -0,0 +1,18 @@
+/*
+ * Description  : Create UDF and invoke it in limit clause
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf23.adm";
+
+create function test.numRows(){
+6
+}
+   
+for $l in dataset('Metadata.Dataset')
+limit test.numRows()
+return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf24.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf24.aql
new file mode 100644
index 0000000..eef906d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf24.aql
@@ -0,0 +1,21 @@
+/*
+ * Description  : Create UDF that returns a range
+ * Expected Res : Success
+ * Date         : Sep 5 2012
+ * Ignored      : Not part of current test build because of Issue 201
+ */
+
+// Returns java.lang.ClassCastException : Issue 195
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf24.adm";
+
+create function test.myRangeFn($n)
+{
+   range(1,$n)
+}
+
+for $i in test.myRangeFn(100)
+return $i
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf25.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf25.aql
new file mode 100644
index 0000000..fefc07e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf25.aql
@@ -0,0 +1,23 @@
+/*
+ * Description  : Create UDF and invoke with negative inputs.
+ * Expected Res : Failure
+ * Date         : 5th Sep 2012
+ */
+
+// This one returns NPE...
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf25.adm";
+
+create function test.computeBonus($pbcRating,$salary)
+{
+   if ($pbcRating = 1) then
+        $salary * 0.25
+   else
+        $salary * 0.10
+}
+
+test.computeBonus(-1,-1)
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf26.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf26.aql
new file mode 100644
index 0000000..95420b7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf26.aql
@@ -0,0 +1,16 @@
+/*
+ * Description  : Create UDF and define with missing references.
+ * Expected Res : Failure
+ * Date         : Sep 6th 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf26.adm";
+
+create function test.needs_f1($x){
+ $x + f1()
+}
+
+test.needs_f1(12345)
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf27.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf27.aql
new file mode 100644
index 0000000..b9db17f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf27.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : Create UDF and invoke UDF from a quantified expression
+ * Expected Res : Success
+ * Date         : Sep 6th 2012
+ */
+
+// this test is not giving expected results.
+// issue 194 reported to track this
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/user-defined-functions_udf27.adm";
+
+create function test.f1(){
+100
+}
+
+let $a := true
+return some $i in [100,200] satisfies test.f1()