Fix issue785 -- using the algebricks fixes for subplans.
Fix RemoveRedundantListifyRule -- listify/scan-collection pair within a nested plan can be removed.
Fix issue550.
Add a regression test for issue638.

Change-Id: Id56539cd5ab7ed0cc05897b468c26aec169102fd
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/150
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Preston Carman <ecarm002@ucr.edu>
Reviewed-by: Till Westmann <westmann@gmail.com>
diff --git a/asterix-app/src/test/resources/optimizerts/queries/query-issue550.aql b/asterix-app/src/test/resources/optimizerts/queries/query-issue550.aql
new file mode 100644
index 0000000..7a01a3b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/query-issue550.aql
@@ -0,0 +1,22 @@
+/*
+ * Description     : This test case is to verify the fix for issue550
+ * https://code.google.com/p/asterixdb/issues/detail?id=550
+ * Expected Result : Success
+ * Date            : 25th October 2014
+ */
+
+let $sample :=
+{{ 
+   {"r": 1, "uid": "1a2b", "t": datetime("2000-01-01T01:00:00"), "event": "e1"},
+   {"r": 2, "uid": "1a2b", "t": datetime("2000-01-01T01:01:00"), "event": "e2"},
+   {"r": 3, "uid": "3c4d", "t": datetime("2000-01-01T01:02:00"), "event": "e1"},
+   {"r": 4, "uid": "3c4d", "t": datetime("2000-01-01T01:03:00"), "event": "e3"},
+   {"r": 5, "uid": "1a2b", "t": datetime("2000-01-01T01:04:00"), "event": "e1"},
+   {"r": 6, "uid": "1a2b", "t": datetime("2000-01-01T01:05:00"), "event": "e4"}
+}}
+for $s in $sample
+group by $u := $s.uid with $s
+return {
+   "u": $u,
+   "recs": ( for $srec in $s return $srec )
+ };