move hivesterix codebase into hyracks fullstack

git-svn-id: https://hyracks.googlecode.com/svn/branches/fullstack_staging@2420 123451ca-8445-de46-9d55-352943316053
diff --git a/src/test/resources/optimizerts/results/h11_share_scan.plan b/src/test/resources/optimizerts/results/h11_share_scan.plan
new file mode 100644
index 0000000..867bfaf
--- /dev/null
+++ b/src/test/resources/optimizerts/results/h11_share_scan.plan
@@ -0,0 +1,34 @@
+write [%0->$$1, %0->$$2]
+-- SINK_WRITE  |PARTITIONED|
+  select (function-call: algebricks:lt, Args:[%0->$$1, 5])
+  -- STREAM_SELECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      replicate 
+      -- SPLIT  |PARTITIONED|
+        exchange 
+        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          data-scan []<-[$$1, $$2] <- default.src
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$1]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$1])
+  -- STREAM_PROJECT  |PARTITIONED|
+    select (function-call: algebricks:gt, Args:[%0->$$1, 10])
+    -- STREAM_SELECT  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        replicate 
+        -- SPLIT  |PARTITIONED|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            data-scan []<-[$$1, $$2] <- default.src
+            -- DATASOURCE_SCAN  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                empty-tuple-source
+                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/h12_select_struct.plan b/src/test/resources/optimizerts/results/h12_select_struct.plan
new file mode 100644
index 0000000..8bbfb61
--- /dev/null
+++ b/src/test/resources/optimizerts/results/h12_select_struct.plan
@@ -0,0 +1,10 @@
+write [%0->$$2]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    data-scan [$$2]<-[$$1, $$2] <- default.src
+    -- DATASOURCE_SCAN  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        empty-tuple-source
+        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q10_returned_item.plan b/src/test/resources/optimizerts/results/q10_returned_item.plan
new file mode 100644
index 0000000..05b3718
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q10_returned_item.plan
@@ -0,0 +1,102 @@
+write [%0->$$38, %0->$$39, %0->$$45, %0->$$40, %0->$$42, %0->$$43, %0->$$41, %0->$$44]
+-- SINK_WRITE  |UNPARTITIONED|
+  project ([$$38, $$39, $$45, $$40, $$42, $$43, $$41, $$44])
+  -- STREAM_PROJECT  |PARTITIONED|
+    limit 20
+    -- STREAM_LIMIT  |UNPARTITIONED|
+      limit 20
+      -- STREAM_LIMIT  |UNPARTITIONED|
+        exchange 
+        -- SORT_MERGE_EXCHANGE [$$45(DESC) ]  |PARTITIONED|
+          limit 20
+          -- STREAM_LIMIT  |LOCAL|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+              order (DESC, %0->$$45) 
+              -- STABLE_SORT [$$45(DESC)]  |LOCAL|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  group by ([$$38 := %0->$$48; $$39 := %0->$$49; $$40 := %0->$$50; $$41 := %0->$$51; $$42 := %0->$$52; $$43 := %0->$$53; $$44 := %0->$$54]) decor ([]) {
+                            aggregate [$$45] <- [function-call: hive:sum(FINAL), Args:[%0->$$47]]
+                            -- AGGREGATE  |LOCAL|
+                              nested tuple source
+                              -- NESTED_TUPLE_SOURCE  |LOCAL|
+                         }
+                  -- EXTERNAL_GROUP_BY[$$48, $$49, $$50, $$51, $$52, $$53, $$54]  |PARTITIONED|
+                    exchange 
+                    -- HASH_PARTITION_EXCHANGE [$$48, $$49, $$50, $$51, $$52, $$53, $$54]  |PARTITIONED|
+                      group by ([$$48 := %0->$$21; $$49 := %0->$$22; $$50 := %0->$$26; $$51 := %0->$$25; $$52 := %0->$$18; $$53 := %0->$$23; $$54 := %0->$$28]) decor ([]) {
+                                aggregate [$$47] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$6, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$7]]]]
+                                -- AGGREGATE  |LOCAL|
+                                  nested tuple source
+                                  -- NESTED_TUPLE_SOURCE  |LOCAL|
+                             }
+                      -- EXTERNAL_GROUP_BY[$$21, $$22, $$26, $$25, $$18, $$23, $$28]  |LOCAL|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          project ([$$21, $$22, $$23, $$25, $$26, $$28, $$18, $$6, $$7])
+                          -- STREAM_PROJECT  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              join (function-call: algebricks:eq, Args:[%0->$$1, %0->$$29])
+                              -- HYBRID_HASH_JOIN [$$1][$$29]  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                                  project ([$$1, $$6, $$7])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    select (function-call: algebricks:eq, Args:[%0->$$9, R])
+                                    -- STREAM_SELECT  |PARTITIONED|
+                                      exchange 
+                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                        data-scan [$$1, $$6, $$7, $$9]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                          exchange 
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            empty-tuple-source
+                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$29]  |PARTITIONED|
+                                  project ([$$29, $$21, $$22, $$23, $$25, $$26, $$28, $$18])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      join (function-call: algebricks:eq, Args:[%0->$$17, %0->$$24])
+                                      -- HYBRID_HASH_JOIN [$$17][$$24]  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$17]  |PARTITIONED|
+                                          data-scan [$$17, $$18]<-[$$17, $$18, $$19, $$20] <- default.nation
+                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              empty-tuple-source
+                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$24]  |PARTITIONED|
+                                          project ([$$24, $$21, $$22, $$23, $$25, $$26, $$28, $$29])
+                                          -- STREAM_PROJECT  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              join (function-call: algebricks:eq, Args:[%0->$$30, %0->$$21])
+                                              -- HYBRID_HASH_JOIN [$$30][$$21]  |PARTITIONED|
+                                                exchange 
+                                                -- HASH_PARTITION_EXCHANGE [$$30]  |PARTITIONED|
+                                                  project ([$$30, $$29])
+                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                    select (function-call: algebricks:and, Args:[function-call: algebricks:lt, Args:[%0->$$33, 1994-01-01], function-call: algebricks:ge, Args:[%0->$$33, 1993-10-01], function-call: algebricks:lt, Args:[%0->$$33, 1994-01-01]])
+                                                    -- STREAM_SELECT  |PARTITIONED|
+                                                      exchange 
+                                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                        data-scan [$$33, $$29, $$30]<-[$$29, $$30, $$31, $$32, $$33, $$34, $$35, $$36, $$37] <- default.orders
+                                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                                          exchange 
+                                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                            empty-tuple-source
+                                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                exchange 
+                                                -- HASH_PARTITION_EXCHANGE [$$21]  |PARTITIONED|
+                                                  data-scan [$$21, $$22, $$23, $$24, $$25, $$26, $$28]<-[$$21, $$22, $$23, $$24, $$25, $$26, $$27, $$28] <- default.customer
+                                                  -- DATASOURCE_SCAN  |PARTITIONED|
+                                                    exchange 
+                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                      empty-tuple-source
+                                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q11_important_stock.plan b/src/test/resources/optimizerts/results/q11_important_stock.plan
new file mode 100644
index 0000000..70ad7ee
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q11_important_stock.plan
@@ -0,0 +1,126 @@
+write [%0->$$17, %0->$$18]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$17, $$18])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      group by ([$$17 := %0->$$21]) decor ([]) {
+                aggregate [$$18] <- [function-call: hive:sum(FINAL), Args:[%0->$$20]]
+                -- AGGREGATE  |LOCAL|
+                  nested tuple source
+                  -- NESTED_TUPLE_SOURCE  |LOCAL|
+             }
+      -- EXTERNAL_GROUP_BY[$$21]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$21]  |PARTITIONED|
+          group by ([$$21 := %0->$$1]) decor ([]) {
+                    aggregate [$$20] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$4, %0->$$3]]]
+                    -- AGGREGATE  |LOCAL|
+                      nested tuple source
+                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                 }
+          -- EXTERNAL_GROUP_BY[$$1]  |LOCAL|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              project ([$$1, $$3, $$4])
+              -- STREAM_PROJECT  |PARTITIONED|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  join (function-call: algebricks:eq, Args:[%0->$$2, %0->$$6])
+                  -- HYBRID_HASH_JOIN [$$2][$$6]  |PARTITIONED|
+                    exchange 
+                    -- HASH_PARTITION_EXCHANGE [$$2]  |PARTITIONED|
+                      data-scan [$$2, $$1, $$3, $$4]<-[$$1, $$2, $$3, $$4, $$5] <- default.partsupp
+                      -- DATASOURCE_SCAN  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          empty-tuple-source
+                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                    exchange 
+                    -- HASH_PARTITION_EXCHANGE [$$6]  |PARTITIONED|
+                      project ([$$6])
+                      -- STREAM_PROJECT  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          join (function-call: algebricks:eq, Args:[%0->$$9, %0->$$13])
+                          -- HYBRID_HASH_JOIN [$$9][$$13]  |PARTITIONED|
+                            exchange 
+                            -- HASH_PARTITION_EXCHANGE [$$9]  |PARTITIONED|
+                              data-scan [$$9, $$6]<-[$$6, $$7, $$8, $$9, $$10, $$11, $$12] <- default.supplier
+                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  empty-tuple-source
+                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                            exchange 
+                            -- HASH_PARTITION_EXCHANGE [$$13]  |PARTITIONED|
+                              project ([$$13])
+                              -- STREAM_PROJECT  |PARTITIONED|
+                                select (function-call: algebricks:eq, Args:[%0->$$14, GERMANY])
+                                -- STREAM_SELECT  |PARTITIONED|
+                                  exchange 
+                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                    data-scan [$$13, $$14]<-[$$13, $$14, $$15, $$16] <- default.nation
+                                    -- DATASOURCE_SCAN  |PARTITIONED|
+                                      exchange 
+                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                        empty-tuple-source
+                                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$3]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    group by ([]) decor ([]) {
+              aggregate [$$3] <- [function-call: hive:sum(FINAL), Args:[%0->$$5]]
+              -- AGGREGATE  |LOCAL|
+                nested tuple source
+                -- NESTED_TUPLE_SOURCE  |LOCAL|
+           }
+    -- EXTERNAL_GROUP_BY[]  |PARTITIONED|
+      exchange 
+      -- HASH_PARTITION_EXCHANGE []  |PARTITIONED|
+        group by ([]) decor ([]) {
+                  aggregate [$$5] <- [function-call: hive:sum(PARTIAL1), Args:[%0->$$2]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- EXTERNAL_GROUP_BY[]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            data-scan [$$2]<-[$$1, $$2] <- default.q11_part_tmp
+            -- DATASOURCE_SCAN  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                empty-tuple-source
+                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$2, %0->$$3]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- SORT_MERGE_EXCHANGE [$$3(DESC) ]  |PARTITIONED|
+    order (DESC, %0->$$3) 
+    -- STABLE_SORT [$$3(DESC)]  |LOCAL|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        project ([$$2, $$3])
+        -- STREAM_PROJECT  |PARTITIONED|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            join (function-call: algebricks:and, Args:[function-call: algebricks:gt, Args:[%0->$$3, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$1, 1.0E-4]], true])
+            -- NESTED_LOOP  |PARTITIONED|
+              exchange 
+              -- BROADCAST_EXCHANGE  |PARTITIONED|
+                data-scan []<-[$$1] <- default.q11_sum_tmp
+                -- DATASOURCE_SCAN  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    empty-tuple-source
+                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                data-scan [$$2, $$3]<-[$$2, $$3] <- default.q11_part_tmp
+                -- DATASOURCE_SCAN  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    empty-tuple-source
+                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q12_shipping.plan b/src/test/resources/optimizerts/results/q12_shipping.plan
new file mode 100644
index 0000000..5c240e2
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q12_shipping.plan
@@ -0,0 +1,58 @@
+write [%0->$$26, %0->$$29, %0->$$30]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$26, $$29, $$30])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$29, $$30] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToDouble, Args:[%0->$$27], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToDouble, Args:[%0->$$28]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- SORT_MERGE_EXCHANGE [$$26(ASC) ]  |PARTITIONED|
+        order (ASC, %0->$$26) 
+        -- STABLE_SORT [$$26(ASC)]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            group by ([$$26 := %0->$$34]) decor ([]) {
+                      aggregate [$$27, $$28] <- [function-call: hive:sum(FINAL), Args:[%0->$$32], function-call: hive:sum(FINAL), Args:[%0->$$33]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[$$34]  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$34]  |PARTITIONED|
+                group by ([$$34 := %0->$$24]) decor ([]) {
+                          aggregate [$$32, $$33] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen, Args:[function-call: algebricks:or, Args:[function-call: algebricks:eq, Args:[%0->$$6, 1-URGENT], function-call: algebricks:eq, Args:[%0->$$6, 2-HIGH]], 1, 0]], function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen, Args:[function-call: algebricks:and, Args:[function-call: algebricks:neq, Args:[%0->$$6, 1-URGENT], function-call: algebricks:neq, Args:[%0->$$6, 2-HIGH]], 1, 0]]]
+                          -- AGGREGATE  |LOCAL|
+                            nested tuple source
+                            -- NESTED_TUPLE_SOURCE  |LOCAL|
+                       }
+                -- EXTERNAL_GROUP_BY[$$24]  |LOCAL|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    project ([$$6, $$24])
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        join (function-call: algebricks:eq, Args:[%0->$$10, %0->$$1])
+                        -- HYBRID_HASH_JOIN [$$10][$$1]  |PARTITIONED|
+                          exchange 
+                          -- HASH_PARTITION_EXCHANGE [$$10]  |PARTITIONED|
+                            project ([$$10, $$24])
+                            -- STREAM_PROJECT  |PARTITIONED|
+                              select (function-call: algebricks:and, Args:[function-call: algebricks:lt, Args:[%0->$$22, 1995-01-01], function-call: algebricks:ge, Args:[%0->$$22, 1994-01-01], function-call: algebricks:lt, Args:[%0->$$20, %0->$$21], function-call: algebricks:lt, Args:[%0->$$21, %0->$$22], function-call: algebricks:lt, Args:[%0->$$20, %0->$$21], function-call: algebricks:ge, Args:[%0->$$22, 1994-01-01], function-call: algebricks:lt, Args:[%0->$$22, 1995-01-01], function-call: algebricks:or, Args:[function-call: algebricks:eq, Args:[%0->$$24, MAIL], function-call: algebricks:eq, Args:[%0->$$24, SHIP]], function-call: algebricks:or, Args:[function-call: algebricks:eq, Args:[%0->$$24, MAIL], function-call: algebricks:eq, Args:[%0->$$24, SHIP]]])
+                              -- STREAM_SELECT  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  data-scan [$$21, $$20, $$22, $$24, $$10]<-[$$10, $$11, $$12, $$13, $$14, $$15, $$16, $$17, $$18, $$19, $$20, $$21, $$22, $$23, $$24, $$25] <- default.lineitem
+                                  -- DATASOURCE_SCAN  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      empty-tuple-source
+                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                          exchange 
+                          -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                            data-scan [$$1, $$6]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.orders
+                            -- DATASOURCE_SCAN  |PARTITIONED|
+                              exchange 
+                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                empty-tuple-source
+                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q13_customer_distribution.plan b/src/test/resources/optimizerts/results/q13_customer_distribution.plan
new file mode 100644
index 0000000..19bcd24
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q13_customer_distribution.plan
@@ -0,0 +1,80 @@
+write [%0->$$22, %0->$$23]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$22, $$23])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$22, $$23] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToInteger, Args:[%0->$$20], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToInteger, Args:[%0->$$21]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- SORT_MERGE_EXCHANGE [$$21(DESC), $$20(DESC) ]  |PARTITIONED|
+        order (DESC, %0->$$21) (DESC, %0->$$20) 
+        -- STABLE_SORT [$$21(DESC), $$20(DESC)]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            group by ([$$20 := %0->$$28]) decor ([]) {
+                      aggregate [$$21] <- [function-call: hive:count(FINAL), Args:[%0->$$27]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[$$28]  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$28]  |PARTITIONED|
+                group by ([$$28 := %0->$$19]) decor ([]) {
+                          aggregate [$$27] <- [function-call: hive:count(PARTIAL1), Args:[1]]
+                          -- AGGREGATE  |LOCAL|
+                            nested tuple source
+                            -- NESTED_TUPLE_SOURCE  |LOCAL|
+                       }
+                -- EXTERNAL_GROUP_BY[$$19]  |LOCAL|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    project ([$$19])
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        group by ([$$18 := %0->$$26]) decor ([]) {
+                                  aggregate [$$19] <- [function-call: hive:count(FINAL), Args:[%0->$$25]]
+                                  -- AGGREGATE  |LOCAL|
+                                    nested tuple source
+                                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+                               }
+                        -- EXTERNAL_GROUP_BY[$$26]  |PARTITIONED|
+                          exchange 
+                          -- HASH_PARTITION_EXCHANGE [$$26]  |PARTITIONED|
+                            group by ([$$26 := %0->$$10]) decor ([]) {
+                                      aggregate [$$25] <- [function-call: hive:count(PARTIAL1), Args:[%0->$$1]]
+                                      -- AGGREGATE  |LOCAL|
+                                        nested tuple source
+                                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                   }
+                            -- EXTERNAL_GROUP_BY[$$10]  |LOCAL|
+                              exchange 
+                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                project ([$$10, $$1])
+                                -- STREAM_PROJECT  |PARTITIONED|
+                                  exchange 
+                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                    left outer join (function-call: algebricks:eq, Args:[%0->$$2, %0->$$10])
+                                    -- HYBRID_HASH_JOIN [$$10][$$2]  |PARTITIONED|
+                                      exchange 
+                                      -- HASH_PARTITION_EXCHANGE [$$10]  |PARTITIONED|
+                                        data-scan [$$10]<-[$$10, $$11, $$12, $$13, $$14, $$15, $$16, $$17] <- default.customer
+                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                          exchange 
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            empty-tuple-source
+                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                      exchange 
+                                      -- HASH_PARTITION_EXCHANGE [$$2]  |PARTITIONED|
+                                        project ([$$2, $$1])
+                                        -- STREAM_PROJECT  |PARTITIONED|
+                                          select (function-call: algebricks:not, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFLike, Args:[%0->$$9, %special%requests%]])
+                                          -- STREAM_SELECT  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              data-scan [$$1, $$2, $$9]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.orders
+                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                exchange 
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  empty-tuple-source
+                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q14_promotion_effect.plan b/src/test/resources/optimizerts/results/q14_promotion_effect.plan
new file mode 100644
index 0000000..21b90bd
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q14_promotion_effect.plan
@@ -0,0 +1,54 @@
+write [%0->$$28]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$28])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$28] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPDivide, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[100.0, %0->$$26], %0->$$27]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        group by ([]) decor ([]) {
+                  aggregate [$$26, $$27] <- [function-call: hive:sum(FINAL), Args:[%0->$$30], function-call: hive:sum(FINAL), Args:[%0->$$31]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- EXTERNAL_GROUP_BY[]  |PARTITIONED|
+          exchange 
+          -- HASH_PARTITION_EXCHANGE []  |PARTITIONED|
+            group by ([]) decor ([]) {
+                      aggregate [$$30, $$31] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFLike, Args:[%0->$$5, PROMO%], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$15, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$16]], 0.0]], function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$15, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$16]]]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[]  |LOCAL|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                project ([$$5, $$15, $$16])
+                -- STREAM_PROJECT  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    join (function-call: algebricks:eq, Args:[%0->$$11, %0->$$1])
+                    -- HYBRID_HASH_JOIN [$$11][$$1]  |PARTITIONED|
+                      exchange 
+                      -- HASH_PARTITION_EXCHANGE [$$11]  |PARTITIONED|
+                        project ([$$11, $$15, $$16])
+                        -- STREAM_PROJECT  |PARTITIONED|
+                          select (function-call: algebricks:and, Args:[function-call: algebricks:lt, Args:[%0->$$20, 1995-10-01], function-call: algebricks:ge, Args:[%0->$$20, 1995-09-01], function-call: algebricks:lt, Args:[%0->$$20, 1995-10-01]])
+                          -- STREAM_SELECT  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              data-scan [$$16, $$20, $$11, $$15]<-[$$10, $$11, $$12, $$13, $$14, $$15, $$16, $$17, $$18, $$19, $$20, $$21, $$22, $$23, $$24, $$25] <- default.lineitem
+                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  empty-tuple-source
+                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                      exchange 
+                      -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                        data-scan [$$1, $$5]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.part
+                        -- DATASOURCE_SCAN  |PARTITIONED|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            empty-tuple-source
+                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q15_top_supplier.plan b/src/test/resources/optimizerts/results/q15_top_supplier.plan
new file mode 100644
index 0000000..a5bd27a
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q15_top_supplier.plan
@@ -0,0 +1,110 @@
+write [%0->$$17, %0->$$18]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$17, $$18])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      group by ([$$17 := %0->$$21]) decor ([]) {
+                aggregate [$$18] <- [function-call: hive:sum(FINAL), Args:[%0->$$20]]
+                -- AGGREGATE  |LOCAL|
+                  nested tuple source
+                  -- NESTED_TUPLE_SOURCE  |LOCAL|
+             }
+      -- EXTERNAL_GROUP_BY[$$21]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$21]  |PARTITIONED|
+          group by ([$$21 := %0->$$3]) decor ([]) {
+                    aggregate [$$20] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$6, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$7]]]]
+                    -- AGGREGATE  |LOCAL|
+                      nested tuple source
+                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                 }
+          -- EXTERNAL_GROUP_BY[$$3]  |LOCAL|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              project ([$$3, $$6, $$7])
+              -- STREAM_PROJECT  |PARTITIONED|
+                select (function-call: algebricks:and, Args:[function-call: algebricks:ge, Args:[%0->$$11, 1996-01-01], function-call: algebricks:lt, Args:[%0->$$11, 1996-04-01], function-call: algebricks:ge, Args:[%0->$$11, 1996-01-01], function-call: algebricks:lt, Args:[%0->$$11, 1996-04-01]])
+                -- STREAM_SELECT  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    data-scan [$$3, $$6, $$7, $$11]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                    -- DATASOURCE_SCAN  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        empty-tuple-source
+                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$3]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    group by ([]) decor ([]) {
+              aggregate [$$3] <- [function-call: hive:max(FINAL), Args:[%0->$$5]]
+              -- AGGREGATE  |LOCAL|
+                nested tuple source
+                -- NESTED_TUPLE_SOURCE  |LOCAL|
+           }
+    -- PRE_CLUSTERED_GROUP_BY[]  |PARTITIONED|
+      exchange 
+      -- HASH_PARTITION_EXCHANGE []  |PARTITIONED|
+        group by ([]) decor ([]) {
+                  aggregate [$$5] <- [function-call: hive:max(PARTIAL1), Args:[%0->$$2]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- PRE_CLUSTERED_GROUP_BY[]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            data-scan [$$2]<-[$$1, $$2] <- default.revenue
+            -- DATASOURCE_SCAN  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                empty-tuple-source
+                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$2, %0->$$3, %0->$$4, %0->$$6, %0->$$10]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- SORT_MERGE_EXCHANGE [$$2(ASC) ]  |PARTITIONED|
+    order (ASC, %0->$$2) 
+    -- STABLE_SORT [$$2(ASC)]  |LOCAL|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        project ([$$2, $$3, $$4, $$6, $$10])
+        -- STREAM_PROJECT  |PARTITIONED|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            join (function-call: algebricks:eq, Args:[%0->$$1, %0->$$10])
+            -- HYBRID_HASH_JOIN [$$1][$$10]  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                data-scan []<-[$$1] <- default.max_revenue
+                -- DATASOURCE_SCAN  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    empty-tuple-source
+                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$10]  |PARTITIONED|
+                project ([$$10, $$2, $$3, $$4, $$6])
+                -- STREAM_PROJECT  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    join (function-call: algebricks:eq, Args:[%0->$$9, %0->$$2])
+                    -- HYBRID_HASH_JOIN [$$9][$$2]  |PARTITIONED|
+                      exchange 
+                      -- HASH_PARTITION_EXCHANGE [$$9]  |PARTITIONED|
+                        data-scan []<-[$$9, $$10] <- default.revenue
+                        -- DATASOURCE_SCAN  |PARTITIONED|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            empty-tuple-source
+                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                      exchange 
+                      -- HASH_PARTITION_EXCHANGE [$$2]  |PARTITIONED|
+                        data-scan [$$2, $$3, $$4, $$6]<-[$$2, $$3, $$4, $$5, $$6, $$7, $$8] <- default.supplier
+                        -- DATASOURCE_SCAN  |PARTITIONED|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            empty-tuple-source
+                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q16_parts_supplier_relationship.plan b/src/test/resources/optimizerts/results/q16_parts_supplier_relationship.plan
new file mode 100644
index 0000000..9835346
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q16_parts_supplier_relationship.plan
@@ -0,0 +1,98 @@
+write [%0->$$1]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$1])
+  -- STREAM_PROJECT  |PARTITIONED|
+    select (function-call: algebricks:not, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFLike, Args:[%0->$$7, %Customer%Complaints%]])
+    -- STREAM_SELECT  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        data-scan [$$1, $$7]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7] <- default.supplier
+        -- DATASOURCE_SCAN  |PARTITIONED|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            empty-tuple-source
+            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$5, %0->$$6, %0->$$7, %0->$$12]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$5, $$6, $$7, $$12])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      join (function-call: algebricks:eq, Args:[%0->$$1, %0->$$12])
+      -- HYBRID_HASH_JOIN [$$1][$$12]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+          data-scan []<-[$$1] <- default.supplier_tmp
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$12]  |PARTITIONED|
+          project ([$$12, $$5, $$6, $$7])
+          -- STREAM_PROJECT  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              join (function-call: algebricks:eq, Args:[%0->$$2, %0->$$11])
+              -- HYBRID_HASH_JOIN [$$2][$$11]  |PARTITIONED|
+                exchange 
+                -- HASH_PARTITION_EXCHANGE [$$2]  |PARTITIONED|
+                  select (function-call: algebricks:and, Args:[function-call: algebricks:not, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFLike, Args:[%0->$$6, MEDIUM POLISHED%]], function-call: algebricks:neq, Args:[%0->$$5, Brand#45], function-call: algebricks:not, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFLike, Args:[%0->$$6, MEDIUM POLISHED%]]])
+                  -- STREAM_SELECT  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      data-scan [$$2, $$5, $$6, $$7]<-[$$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10] <- default.part
+                      -- DATASOURCE_SCAN  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          empty-tuple-source
+                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                exchange 
+                -- HASH_PARTITION_EXCHANGE [$$11]  |PARTITIONED|
+                  data-scan [$$11, $$12]<-[$$11, $$12, $$13, $$14, $$15] <- default.partsupp
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$10, %0->$$11, %0->$$12, %0->$$14]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$10, $$11, $$12, $$14])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$14] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToInteger, Args:[%0->$$13]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- SORT_MERGE_EXCHANGE [$$13(DESC), $$10(ASC), $$11(ASC), $$12(ASC) ]  |PARTITIONED|
+        order (DESC, %0->$$13) (ASC, %0->$$10) (ASC, %0->$$11) (ASC, %0->$$12) 
+        -- STABLE_SORT [$$13(DESC), $$10(ASC), $$11(ASC), $$12(ASC)]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            group by ([$$10 := %0->$$5; $$11 := %0->$$6; $$12 := %0->$$7]) decor ([]) {
+                      aggregate [$$13] <- [function-call: hive:count(COMPLETE), Args:[%0->$$8]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[$$5, $$6, $$7]  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$5, $$6, $$7]  |PARTITIONED|
+                group by ([$$5 := %0->$$1; $$6 := %0->$$2; $$7 := %0->$$3; $$8 := %0->$$4]) decor ([]) {
+                          aggregate [] <- []
+                          -- AGGREGATE  |LOCAL|
+                            nested tuple source
+                            -- NESTED_TUPLE_SOURCE  |LOCAL|
+                       }
+                -- EXTERNAL_GROUP_BY[$$1, $$2, $$3, $$4]  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    select (function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:eq, Args:[%0->$$3, 49], function-call: algebricks:eq, Args:[%0->$$3, 14]], function-call: algebricks:eq, Args:[%0->$$3, 23]], function-call: algebricks:eq, Args:[%0->$$3, 45]], function-call: algebricks:eq, Args:[%0->$$3, 19]], function-call: algebricks:eq, Args:[%0->$$3, 3]], function-call: algebricks:eq, Args:[%0->$$3, 36]], function-call: algebricks:eq, Args:[%0->$$3, 9]])
+                    -- STREAM_SELECT  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        data-scan []<-[$$1, $$2, $$3, $$4] <- default.q16_tmp
+                        -- DATASOURCE_SCAN  |PARTITIONED|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            empty-tuple-source
+                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q17_small_quantity_order_revenue.plan b/src/test/resources/optimizerts/results/q17_small_quantity_order_revenue.plan
new file mode 100644
index 0000000..a827007
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q17_small_quantity_order_revenue.plan
@@ -0,0 +1,104 @@
+write [%0->$$17, %0->$$19]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$17, $$19])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$19] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[0.2, %0->$$18]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        group by ([$$17 := %0->$$22]) decor ([]) {
+                  aggregate [$$18] <- [function-call: hive:avg(FINAL), Args:[%0->$$21]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- EXTERNAL_GROUP_BY[$$22]  |PARTITIONED|
+          exchange 
+          -- HASH_PARTITION_EXCHANGE [$$22]  |PARTITIONED|
+            group by ([$$22 := %0->$$2]) decor ([]) {
+                      aggregate [$$21] <- [function-call: hive:avg(PARTIAL1), Args:[%0->$$5]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[$$2]  |LOCAL|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                data-scan [$$2, $$5]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                -- DATASOURCE_SCAN  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    empty-tuple-source
+                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$29]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$29])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$29] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPDivide, Args:[%0->$$28, 7.0]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        group by ([]) decor ([]) {
+                  aggregate [$$28] <- [function-call: hive:sum(FINAL), Args:[%0->$$31]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- EXTERNAL_GROUP_BY[]  |PARTITIONED|
+          exchange 
+          -- HASH_PARTITION_EXCHANGE []  |PARTITIONED|
+            group by ([]) decor ([]) {
+                      aggregate [$$31] <- [function-call: hive:sum(PARTIAL1), Args:[%0->$$17]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[]  |LOCAL|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                project ([$$17])
+                -- STREAM_PROJECT  |PARTITIONED|
+                  select (function-call: algebricks:lt, Args:[%0->$$16, %0->$$2])
+                  -- STREAM_SELECT  |UNPARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      join (function-call: algebricks:eq, Args:[%0->$$13, %0->$$1])
+                      -- HYBRID_HASH_JOIN [$$13][$$1]  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          project ([$$13, $$16, $$17])
+                          -- STREAM_PROJECT  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              join (function-call: algebricks:eq, Args:[%0->$$13, %0->$$3])
+                              -- HYBRID_HASH_JOIN [$$13][$$3]  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$13]  |PARTITIONED|
+                                  data-scan [$$13, $$16, $$17]<-[$$12, $$13, $$14, $$15, $$16, $$17, $$18, $$19, $$20, $$21, $$22, $$23, $$24, $$25, $$26, $$27] <- default.lineitem
+                                  -- DATASOURCE_SCAN  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      empty-tuple-source
+                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$3]  |PARTITIONED|
+                                  project ([$$3])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    select (function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$9, MED BOX], function-call: algebricks:eq, Args:[%0->$$6, Brand#23], function-call: algebricks:eq, Args:[%0->$$9, MED BOX]])
+                                    -- STREAM_SELECT  |PARTITIONED|
+                                      exchange 
+                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                        data-scan [$$3, $$6, $$9]<-[$$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11] <- default.part
+                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                          exchange 
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            empty-tuple-source
+                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                        exchange 
+                        -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                          data-scan [$$1, $$2]<-[$$1, $$2] <- default.lineitem_tmp
+                          -- DATASOURCE_SCAN  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              empty-tuple-source
+                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q18_large_volume_customer.plan b/src/test/resources/optimizerts/results/q18_large_volume_customer.plan
new file mode 100644
index 0000000..ea47ea0
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q18_large_volume_customer.plan
@@ -0,0 +1,126 @@
+write [%0->$$17, %0->$$18]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$17, $$18])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      group by ([$$17 := %0->$$21]) decor ([]) {
+                aggregate [$$18] <- [function-call: hive:sum(FINAL), Args:[%0->$$20]]
+                -- AGGREGATE  |LOCAL|
+                  nested tuple source
+                  -- NESTED_TUPLE_SOURCE  |LOCAL|
+             }
+      -- EXTERNAL_GROUP_BY[$$21]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$21]  |PARTITIONED|
+          group by ([$$21 := %0->$$1]) decor ([]) {
+                    aggregate [$$20] <- [function-call: hive:sum(PARTIAL1), Args:[%0->$$5]]
+                    -- AGGREGATE  |LOCAL|
+                      nested tuple source
+                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                 }
+          -- EXTERNAL_GROUP_BY[$$1]  |LOCAL|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              data-scan [$$1, $$5]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+              -- DATASOURCE_SCAN  |PARTITIONED|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  empty-tuple-source
+                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$36, %0->$$37, %0->$$38, %0->$$39, %0->$$40, %0->$$41]
+-- SINK_WRITE  |UNPARTITIONED|
+  project ([$$36, $$37, $$38, $$39, $$40, $$41])
+  -- STREAM_PROJECT  |PARTITIONED|
+    limit 100
+    -- STREAM_LIMIT  |UNPARTITIONED|
+      limit 100
+      -- STREAM_LIMIT  |UNPARTITIONED|
+        exchange 
+        -- SORT_MERGE_EXCHANGE [$$40(DESC), $$39(ASC) ]  |PARTITIONED|
+          limit 100
+          -- STREAM_LIMIT  |LOCAL|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+              order (DESC, %0->$$40) (ASC, %0->$$39) 
+              -- STABLE_SORT [$$40(DESC), $$39(ASC)]  |LOCAL|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  group by ([$$36 := %0->$$44; $$37 := %0->$$45; $$38 := %0->$$46; $$39 := %0->$$47; $$40 := %0->$$48]) decor ([]) {
+                            aggregate [$$41] <- [function-call: hive:sum(FINAL), Args:[%0->$$43]]
+                            -- AGGREGATE  |LOCAL|
+                              nested tuple source
+                              -- NESTED_TUPLE_SOURCE  |LOCAL|
+                         }
+                  -- EXTERNAL_GROUP_BY[$$44, $$45, $$46, $$47, $$48]  |PARTITIONED|
+                    exchange 
+                    -- HASH_PARTITION_EXCHANGE [$$44, $$45, $$46, $$47, $$48]  |PARTITIONED|
+                      group by ([$$44 := %0->$$20; $$45 := %0->$$19; $$46 := %0->$$27; $$47 := %0->$$31; $$48 := %0->$$30]) decor ([]) {
+                                aggregate [$$43] <- [function-call: hive:sum(PARTIAL1), Args:[%0->$$7]]
+                                -- AGGREGATE  |LOCAL|
+                                  nested tuple source
+                                  -- NESTED_TUPLE_SOURCE  |LOCAL|
+                             }
+                      -- EXTERNAL_GROUP_BY[$$20, $$19, $$27, $$31, $$30]  |LOCAL|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          project ([$$19, $$20, $$27, $$30, $$31, $$7])
+                          -- STREAM_PROJECT  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              join (function-call: algebricks:eq, Args:[%0->$$27, %0->$$1])
+                              -- HYBRID_HASH_JOIN [$$1][$$27]  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                                  project ([$$1, $$7])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      join (function-call: algebricks:eq, Args:[%0->$$3, %0->$$1])
+                                      -- HYBRID_HASH_JOIN [$$3][$$1]  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$3]  |PARTITIONED|
+                                          data-scan [$$3, $$7]<-[$$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16, $$17, $$18] <- default.lineitem
+                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              empty-tuple-source
+                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                                          project ([$$1])
+                                          -- STREAM_PROJECT  |PARTITIONED|
+                                            select (function-call: algebricks:gt, Args:[%0->$$2, 300])
+                                            -- STREAM_SELECT  |PARTITIONED|
+                                              exchange 
+                                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                data-scan []<-[$$1, $$2] <- default.q18_tmp
+                                                -- DATASOURCE_SCAN  |PARTITIONED|
+                                                  exchange 
+                                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                    empty-tuple-source
+                                                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$27]  |PARTITIONED|
+                                  project ([$$27, $$19, $$20, $$30, $$31])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      join (function-call: algebricks:eq, Args:[%0->$$28, %0->$$19])
+                                      -- HYBRID_HASH_JOIN [$$28][$$19]  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$28]  |PARTITIONED|
+                                          data-scan [$$28, $$27, $$30, $$31]<-[$$27, $$28, $$29, $$30, $$31, $$32, $$33, $$34, $$35] <- default.orders
+                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              empty-tuple-source
+                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$19]  |PARTITIONED|
+                                          data-scan [$$19, $$20]<-[$$19, $$20, $$21, $$22, $$23, $$24, $$25, $$26] <- default.customer
+                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              empty-tuple-source
+                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q19_discounted_revenue.plan b/src/test/resources/optimizerts/results/q19_discounted_revenue.plan
new file mode 100644
index 0000000..1827729
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q19_discounted_revenue.plan
@@ -0,0 +1,46 @@
+write [%0->$$26]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    group by ([]) decor ([]) {
+              aggregate [$$26] <- [function-call: hive:sum(FINAL), Args:[%0->$$28]]
+              -- AGGREGATE  |LOCAL|
+                nested tuple source
+                -- NESTED_TUPLE_SOURCE  |LOCAL|
+           }
+    -- EXTERNAL_GROUP_BY[]  |PARTITIONED|
+      exchange 
+      -- HASH_PARTITION_EXCHANGE []  |PARTITIONED|
+        group by ([]) decor ([]) {
+                  aggregate [$$28] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$15, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$16]]]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- EXTERNAL_GROUP_BY[]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            project ([$$15, $$16])
+            -- STREAM_PROJECT  |PARTITIONED|
+              select (function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$4, Brand#12], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFRegExp, Args:[%0->$$7, SM CASE||SM BOX||SM PACK||SM PKG]], function-call: algebricks:ge, Args:[%0->$$14, 1]], function-call: algebricks:le, Args:[%0->$$14, 11]], function-call: algebricks:ge, Args:[%0->$$6, 1]], function-call: algebricks:le, Args:[%0->$$6, 5]], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFRegExp, Args:[%0->$$24, AIR||AIR REG]], function-call: algebricks:eq, Args:[%0->$$23, DELIVER IN PERSON]], function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$4, Brand#23], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFRegExp, Args:[%0->$$7, MED BAG||MED BOX||MED PKG||MED PACK]], function-call: algebricks:ge, Args:[%0->$$14, 10]], function-call: algebricks:le, Args:[%0->$$14, 20]], function-call: algebricks:ge, Args:[%0->$$6, 1]], function-call: algebricks:le, Args:[%0->$$6, 10]], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFRegExp, Args:[%0->$$24, AIR||AIR REG]], function-call: algebricks:eq, Args:[%0->$$23, DELIVER IN PERSON]]], function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$4, Brand#34], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFRegExp, Args:[%0->$$7, LG CASE||LG BOX||LG PACK||LG PKG]], function-call: algebricks:ge, Args:[%0->$$14, 20]], function-call: algebricks:le, Args:[%0->$$14, 30]], function-call: algebricks:ge, Args:[%0->$$6, 1]], function-call: algebricks:le, Args:[%0->$$6, 15]], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFRegExp, Args:[%0->$$24, AIR||AIR REG]], function-call: algebricks:eq, Args:[%0->$$23, DELIVER IN PERSON]]])
+              -- STREAM_SELECT  |UNPARTITIONED|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  join (function-call: algebricks:eq, Args:[%0->$$11, %0->$$1])
+                  -- HYBRID_HASH_JOIN [$$11][$$1]  |PARTITIONED|
+                    exchange 
+                    -- HASH_PARTITION_EXCHANGE [$$11]  |PARTITIONED|
+                      data-scan [$$11, $$14, $$15, $$16, $$23, $$24]<-[$$10, $$11, $$12, $$13, $$14, $$15, $$16, $$17, $$18, $$19, $$20, $$21, $$22, $$23, $$24, $$25] <- default.lineitem
+                      -- DATASOURCE_SCAN  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          empty-tuple-source
+                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                    exchange 
+                    -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                      data-scan [$$1, $$4, $$6, $$7]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.part
+                      -- DATASOURCE_SCAN  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          empty-tuple-source
+                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q1_pricing_summary_report.plan b/src/test/resources/optimizerts/results/q1_pricing_summary_report.plan
new file mode 100644
index 0000000..0e9c90f
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q1_pricing_summary_report.plan
@@ -0,0 +1,42 @@
+write [%0->$$17, %0->$$18, %0->$$19, %0->$$20, %0->$$21, %0->$$22, %0->$$23, %0->$$24, %0->$$25, %0->$$27]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$17, $$18, $$19, $$20, $$21, $$22, $$23, $$24, $$25, $$27])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$27] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToInteger, Args:[%0->$$26]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- SORT_MERGE_EXCHANGE [$$17(ASC), $$18(ASC) ]  |PARTITIONED|
+        order (ASC, %0->$$17) (ASC, %0->$$18) 
+        -- STABLE_SORT [$$17(ASC), $$18(ASC)]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            group by ([$$17 := %0->$$37; $$18 := %0->$$38]) decor ([]) {
+                      aggregate [$$19, $$20, $$21, $$22, $$23, $$24, $$25, $$26] <- [function-call: hive:sum(FINAL), Args:[%0->$$29], function-call: hive:sum(FINAL), Args:[%0->$$30], function-call: hive:sum(FINAL), Args:[%0->$$31], function-call: hive:sum(FINAL), Args:[%0->$$32], function-call: hive:avg(FINAL), Args:[%0->$$33], function-call: hive:avg(FINAL), Args:[%0->$$34], function-call: hive:avg(FINAL), Args:[%0->$$35], function-call: hive:count(FINAL), Args:[%0->$$36]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[$$37, $$38]  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$37, $$38]  |PARTITIONED|
+                group by ([$$37 := %0->$$9; $$38 := %0->$$10]) decor ([]) {
+                          aggregate [$$29, $$30, $$31, $$32, $$33, $$34, $$35, $$36] <- [function-call: hive:sum(PARTIAL1), Args:[%0->$$5], function-call: hive:sum(PARTIAL1), Args:[%0->$$6], function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$6, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$7]]], function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$6, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$7]], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPPlus, Args:[1, %0->$$8]]], function-call: hive:avg(PARTIAL1), Args:[%0->$$5], function-call: hive:avg(PARTIAL1), Args:[%0->$$6], function-call: hive:avg(PARTIAL1), Args:[%0->$$7], function-call: hive:count(PARTIAL1), Args:[1]]
+                          -- AGGREGATE  |LOCAL|
+                            nested tuple source
+                            -- NESTED_TUPLE_SOURCE  |LOCAL|
+                       }
+                -- EXTERNAL_GROUP_BY[$$9, $$10]  |LOCAL|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    project ([$$9, $$10, $$5, $$6, $$7, $$8])
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      select (function-call: algebricks:le, Args:[%0->$$11, 1998-09-02])
+                      -- STREAM_SELECT  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          data-scan [$$5, $$6, $$7, $$8, $$9, $$10, $$11]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                          -- DATASOURCE_SCAN  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              empty-tuple-source
+                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q20_potential_part_promotion.plan b/src/test/resources/optimizerts/results/q20_potential_part_promotion.plan
new file mode 100644
index 0000000..eddfca5
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q20_potential_part_promotion.plan
@@ -0,0 +1,178 @@
+write [%0->$$1]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    distinct ([%0->$$1])
+    -- PRE_SORTED_DISTINCT_BY  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+        order (ASC, %0->$$1) 
+        -- STABLE_SORT [$$1(ASC)]  |LOCAL|
+          exchange 
+          -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+            project ([$$1])
+            -- STREAM_PROJECT  |PARTITIONED|
+              select (function-call: hive:org.apache.hadoop.hive.ql.udf.UDFLike, Args:[%0->$$2, forest%])
+              -- STREAM_SELECT  |PARTITIONED|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  data-scan [$$1, $$2]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.part
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$17, %0->$$18, %0->$$20]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$17, $$18, $$20])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$20] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[0.5, %0->$$19]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        group by ([$$17 := %0->$$23; $$18 := %0->$$24]) decor ([]) {
+                  aggregate [$$19] <- [function-call: hive:sum(FINAL), Args:[%0->$$22]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- EXTERNAL_GROUP_BY[$$23, $$24]  |PARTITIONED|
+          exchange 
+          -- HASH_PARTITION_EXCHANGE [$$23, $$24]  |PARTITIONED|
+            group by ([$$23 := %0->$$2; $$24 := %0->$$3]) decor ([]) {
+                      aggregate [$$22] <- [function-call: hive:sum(PARTIAL1), Args:[%0->$$5]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[$$2, $$3]  |LOCAL|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                project ([$$2, $$3, $$5])
+                -- STREAM_PROJECT  |PARTITIONED|
+                  select (function-call: algebricks:and, Args:[function-call: algebricks:ge, Args:[%0->$$11, 1994-01-01], function-call: algebricks:lt, Args:[%0->$$11, 1995-01-01], function-call: algebricks:ge, Args:[%0->$$11, 1994-01-01], function-call: algebricks:lt, Args:[%0->$$11, 1995-01-01]])
+                  -- STREAM_SELECT  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      data-scan [$$2, $$3, $$5, $$11]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                      -- DATASOURCE_SCAN  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          empty-tuple-source
+                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$6, %0->$$7, %0->$$3]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$6, $$7, $$3])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      join (function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$1, %0->$$5], function-call: algebricks:eq, Args:[%0->$$2, %0->$$6]])
+      -- HYBRID_HASH_JOIN [$$1, $$2][$$5, $$6]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$1, $$2]  |PARTITIONED|
+          data-scan []<-[$$1, $$2, $$3] <- default.q20_tmp2
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$5, $$6]  |PARTITIONED|
+          project ([$$5, $$6, $$7])
+          -- STREAM_PROJECT  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              join (function-call: algebricks:eq, Args:[%0->$$4, %0->$$5])
+              -- HYBRID_HASH_JOIN [$$4][$$5]  |PARTITIONED|
+                exchange 
+                -- HASH_PARTITION_EXCHANGE [$$4]  |PARTITIONED|
+                  data-scan []<-[$$4] <- default.q20_tmp1
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                exchange 
+                -- HASH_PARTITION_EXCHANGE [$$5]  |PARTITIONED|
+                  data-scan [$$5, $$6, $$7]<-[$$5, $$6, $$7, $$8, $$9] <- default.partsupp
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$1]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    distinct ([%0->$$1])
+    -- PRE_SORTED_DISTINCT_BY  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+        order (ASC, %0->$$1) 
+        -- STABLE_SORT [$$1(ASC)]  |LOCAL|
+          exchange 
+          -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+            project ([$$1])
+            -- STREAM_PROJECT  |PARTITIONED|
+              select (function-call: algebricks:gt, Args:[%0->$$2, %0->$$3])
+              -- STREAM_SELECT  |PARTITIONED|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  data-scan []<-[$$1, $$2, $$3] <- default.q20_tmp3
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$3, %0->$$4]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- SORT_MERGE_EXCHANGE [$$3(ASC) ]  |PARTITIONED|
+    order (ASC, %0->$$3) 
+    -- STABLE_SORT [$$3(ASC)]  |LOCAL|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        project ([$$3, $$4])
+        -- STREAM_PROJECT  |PARTITIONED|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            join (function-call: algebricks:eq, Args:[%0->$$1, %0->$$2])
+            -- HYBRID_HASH_JOIN [$$1][$$2]  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                data-scan []<-[$$1] <- default.q20_tmp4
+                -- DATASOURCE_SCAN  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    empty-tuple-source
+                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$2]  |PARTITIONED|
+                project ([$$2, $$3, $$4])
+                -- STREAM_PROJECT  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    join (function-call: algebricks:eq, Args:[%0->$$9, %0->$$5])
+                    -- HYBRID_HASH_JOIN [$$9][$$5]  |PARTITIONED|
+                      exchange 
+                      -- HASH_PARTITION_EXCHANGE [$$9]  |PARTITIONED|
+                        project ([$$9])
+                        -- STREAM_PROJECT  |PARTITIONED|
+                          select (function-call: algebricks:eq, Args:[%0->$$10, CANADA])
+                          -- STREAM_SELECT  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              data-scan [$$9, $$10]<-[$$9, $$10, $$11, $$12] <- default.nation
+                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  empty-tuple-source
+                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                      exchange 
+                      -- HASH_PARTITION_EXCHANGE [$$5]  |PARTITIONED|
+                        data-scan [$$5, $$2, $$3, $$4]<-[$$2, $$3, $$4, $$5, $$6, $$7, $$8] <- default.supplier
+                        -- DATASOURCE_SCAN  |PARTITIONED|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            empty-tuple-source
+                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q21_suppliers_who_kept_orders_waiting.plan b/src/test/resources/optimizerts/results/q21_suppliers_who_kept_orders_waiting.plan
new file mode 100644
index 0000000..cc47cf3
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q21_suppliers_who_kept_orders_waiting.plan
@@ -0,0 +1,224 @@
+write [%0->$$21, %0->$$24, %0->$$23]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$21, $$24, $$23])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$24] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToInteger, Args:[%0->$$22]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        group by ([$$21 := %0->$$17]) decor ([]) {
+                  aggregate [$$22, $$23] <- [function-call: hive:count(COMPLETE), Args:[%0->$$18], function-call: hive:max(FINAL), Args:[%0->$$20]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- PRE_CLUSTERED_GROUP_BY[$$17]  |PARTITIONED|
+          exchange 
+          -- HASH_PARTITION_MERGE_EXCHANGE MERGE:[$$17(ASC)] HASH:[$$17]  |PARTITIONED|
+            group by ([$$17 := %0->$$1; $$18 := %0->$$3]) decor ([]) {
+                      aggregate [$$20] <- [function-call: hive:max(PARTIAL1), Args:[%0->$$3]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- PRE_CLUSTERED_GROUP_BY[$$1, $$3]  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+                order (ASC, %0->$$1) (ASC, %0->$$3) 
+                -- STABLE_SORT [$$1(ASC), $$3(ASC)]  |LOCAL|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    data-scan [$$1, $$3]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                    -- DATASOURCE_SCAN  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        empty-tuple-source
+                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$21, %0->$$24, %0->$$23]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$21, $$24, $$23])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$24] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToInteger, Args:[%0->$$22]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        group by ([$$21 := %0->$$17]) decor ([]) {
+                  aggregate [$$22, $$23] <- [function-call: hive:count(COMPLETE), Args:[%0->$$18], function-call: hive:max(FINAL), Args:[%0->$$20]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- PRE_CLUSTERED_GROUP_BY[$$17]  |PARTITIONED|
+          exchange 
+          -- HASH_PARTITION_MERGE_EXCHANGE MERGE:[$$17(ASC)] HASH:[$$17]  |PARTITIONED|
+            group by ([$$17 := %0->$$1; $$18 := %0->$$3]) decor ([]) {
+                      aggregate [$$20] <- [function-call: hive:max(PARTIAL1), Args:[%0->$$3]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- PRE_CLUSTERED_GROUP_BY[$$1, $$3]  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+                order (ASC, %0->$$1) (ASC, %0->$$3) 
+                -- STABLE_SORT [$$1(ASC), $$3(ASC)]  |LOCAL|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    project ([$$1, $$3])
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      select (function-call: algebricks:gt, Args:[%0->$$13, %0->$$12])
+                      -- STREAM_SELECT  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          data-scan [$$1, $$3, $$12, $$13]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                          -- DATASOURCE_SCAN  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              empty-tuple-source
+                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$43, %0->$$45]
+-- SINK_WRITE  |UNPARTITIONED|
+  project ([$$43, $$45])
+  -- STREAM_PROJECT  |UNPARTITIONED|
+    assign [$$45] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToInteger, Args:[%0->$$44]]
+    -- ASSIGN  |UNPARTITIONED|
+      limit 100
+      -- STREAM_LIMIT  |UNPARTITIONED|
+        limit 100
+        -- STREAM_LIMIT  |UNPARTITIONED|
+          exchange 
+          -- SORT_MERGE_EXCHANGE [$$44(DESC), $$43(ASC) ]  |PARTITIONED|
+            limit 100
+            -- STREAM_LIMIT  |LOCAL|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+                order (DESC, %0->$$44) (ASC, %0->$$43) 
+                -- STABLE_SORT [$$44(DESC), $$43(ASC)]  |LOCAL|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    group by ([$$43 := %0->$$48]) decor ([]) {
+                              aggregate [$$44] <- [function-call: hive:count(FINAL), Args:[%0->$$47]]
+                              -- AGGREGATE  |LOCAL|
+                                nested tuple source
+                                -- NESTED_TUPLE_SOURCE  |LOCAL|
+                           }
+                    -- EXTERNAL_GROUP_BY[$$48]  |PARTITIONED|
+                      exchange 
+                      -- HASH_PARTITION_EXCHANGE [$$48]  |PARTITIONED|
+                        group by ([$$48 := %0->$$37]) decor ([]) {
+                                  aggregate [$$47] <- [function-call: hive:count(PARTIAL1), Args:[1]]
+                                  -- AGGREGATE  |LOCAL|
+                                    nested tuple source
+                                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+                               }
+                        -- EXTERNAL_GROUP_BY[$$37]  |LOCAL|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            project ([$$37])
+                            -- STREAM_PROJECT  |PARTITIONED|
+                              select (function-call: algebricks:or, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNull, Args:[%0->$$2], function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$2, 1], function-call: algebricks:eq, Args:[%0->$$18, %0->$$3]]])
+                              -- STREAM_SELECT  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  left outer join (function-call: algebricks:eq, Args:[%0->$$4, %0->$$1])
+                                  -- HYBRID_HASH_JOIN [$$4][$$1]  |PARTITIONED|
+                                    exchange 
+                                    -- HASH_PARTITION_EXCHANGE [$$4]  |PARTITIONED|
+                                      project ([$$37, $$4, $$18])
+                                      -- STREAM_PROJECT  |PARTITIONED|
+                                        select (function-call: algebricks:or, Args:[function-call: algebricks:gt, Args:[%0->$$5, 1], function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$5, 1], function-call: algebricks:neq, Args:[%0->$$18, %0->$$6]]])
+                                        -- STREAM_SELECT  |UNPARTITIONED|
+                                          exchange 
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            join (function-call: algebricks:eq, Args:[%0->$$16, %0->$$4])
+                                            -- HYBRID_HASH_JOIN [$$16][$$4]  |PARTITIONED|
+                                              exchange 
+                                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                project ([$$37, $$16, $$18])
+                                                -- STREAM_PROJECT  |PARTITIONED|
+                                                  exchange 
+                                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                    join (function-call: algebricks:eq, Args:[%0->$$16, %0->$$7])
+                                                    -- HYBRID_HASH_JOIN [$$16][$$7]  |PARTITIONED|
+                                                      exchange 
+                                                      -- HASH_PARTITION_EXCHANGE [$$16]  |PARTITIONED|
+                                                        project ([$$37, $$16, $$18])
+                                                        -- STREAM_PROJECT  |PARTITIONED|
+                                                          exchange 
+                                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                            join (function-call: algebricks:eq, Args:[%0->$$18, %0->$$36])
+                                                            -- HYBRID_HASH_JOIN [$$18][$$36]  |PARTITIONED|
+                                                              exchange 
+                                                              -- HASH_PARTITION_EXCHANGE [$$18]  |PARTITIONED|
+                                                                project ([$$16, $$18])
+                                                                -- STREAM_PROJECT  |PARTITIONED|
+                                                                  select (function-call: algebricks:and, Args:[function-call: algebricks:gt, Args:[%0->$$28, %0->$$27], function-call: algebricks:gt, Args:[%0->$$28, %0->$$27]])
+                                                                  -- STREAM_SELECT  |PARTITIONED|
+                                                                    exchange 
+                                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                      data-scan [$$16, $$18, $$27, $$28]<-[$$16, $$17, $$18, $$19, $$20, $$21, $$22, $$23, $$24, $$25, $$26, $$27, $$28, $$29, $$30, $$31] <- default.lineitem
+                                                                      -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                        exchange 
+                                                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                          empty-tuple-source
+                                                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                              exchange 
+                                                              -- HASH_PARTITION_EXCHANGE [$$36]  |PARTITIONED|
+                                                                project ([$$36, $$37])
+                                                                -- STREAM_PROJECT  |PARTITIONED|
+                                                                  exchange 
+                                                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                    join (function-call: algebricks:eq, Args:[%0->$$39, %0->$$32])
+                                                                    -- HYBRID_HASH_JOIN [$$39][$$32]  |PARTITIONED|
+                                                                      exchange 
+                                                                      -- HASH_PARTITION_EXCHANGE [$$39]  |PARTITIONED|
+                                                                        data-scan [$$39, $$36, $$37]<-[$$36, $$37, $$38, $$39, $$40, $$41, $$42] <- default.supplier
+                                                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                          exchange 
+                                                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                            empty-tuple-source
+                                                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                                      exchange 
+                                                                      -- HASH_PARTITION_EXCHANGE [$$32]  |PARTITIONED|
+                                                                        project ([$$32])
+                                                                        -- STREAM_PROJECT  |PARTITIONED|
+                                                                          select (function-call: algebricks:eq, Args:[%0->$$33, SAUDI ARABIA])
+                                                                          -- STREAM_SELECT  |PARTITIONED|
+                                                                            exchange 
+                                                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                              data-scan [$$32, $$33]<-[$$32, $$33, $$34, $$35] <- default.nation
+                                                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                                exchange 
+                                                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                                  empty-tuple-source
+                                                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                      exchange 
+                                                      -- HASH_PARTITION_EXCHANGE [$$7]  |PARTITIONED|
+                                                        project ([$$7])
+                                                        -- STREAM_PROJECT  |PARTITIONED|
+                                                          select (function-call: algebricks:eq, Args:[%0->$$9, F])
+                                                          -- STREAM_SELECT  |PARTITIONED|
+                                                            exchange 
+                                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                              data-scan [$$7, $$9]<-[$$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15] <- default.orders
+                                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                exchange 
+                                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                  empty-tuple-source
+                                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                              exchange 
+                                              -- HASH_PARTITION_EXCHANGE [$$4]  |PARTITIONED|
+                                                data-scan [$$4, $$5, $$6]<-[$$4, $$5, $$6] <- default.q21_tmp1
+                                                -- DATASOURCE_SCAN  |PARTITIONED|
+                                                  exchange 
+                                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                    empty-tuple-source
+                                                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                    exchange 
+                                    -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                                      data-scan [$$1, $$2, $$3]<-[$$1, $$2, $$3] <- default.q21_tmp2
+                                      -- DATASOURCE_SCAN  |PARTITIONED|
+                                        exchange 
+                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                          empty-tuple-source
+                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q22_global_sales_opportunity.plan b/src/test/resources/optimizerts/results/q22_global_sales_opportunity.plan
new file mode 100644
index 0000000..591576b
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q22_global_sales_opportunity.plan
@@ -0,0 +1,136 @@
+write [%0->$$6, %0->$$1, %0->$$9]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$6, $$1, $$9])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$9] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFSubstr, Args:[%0->$$5, 1, 2]]
+    -- ASSIGN  |PARTITIONED|
+      select (function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:or, Args:[function-call: algebricks:eq, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFSubstr, Args:[%0->$$5, 1, 2], 13], function-call: algebricks:eq, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFSubstr, Args:[%0->$$5, 1, 2], 31]], function-call: algebricks:eq, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFSubstr, Args:[%0->$$5, 1, 2], 23]], function-call: algebricks:eq, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFSubstr, Args:[%0->$$5, 1, 2], 29]], function-call: algebricks:eq, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFSubstr, Args:[%0->$$5, 1, 2], 30]], function-call: algebricks:eq, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFSubstr, Args:[%0->$$5, 1, 2], 18]], function-call: algebricks:eq, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFSubstr, Args:[%0->$$5, 1, 2], 17]])
+      -- STREAM_SELECT  |PARTITIONED|
+        exchange 
+        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          data-scan []<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8] <- default.customer
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$4]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    group by ([]) decor ([]) {
+              aggregate [$$4] <- [function-call: hive:avg(FINAL), Args:[%0->$$6]]
+              -- AGGREGATE  |LOCAL|
+                nested tuple source
+                -- NESTED_TUPLE_SOURCE  |LOCAL|
+           }
+    -- EXTERNAL_GROUP_BY[]  |PARTITIONED|
+      exchange 
+      -- HASH_PARTITION_EXCHANGE []  |PARTITIONED|
+        group by ([]) decor ([]) {
+                  aggregate [$$6] <- [function-call: hive:avg(PARTIAL1), Args:[%0->$$1]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- EXTERNAL_GROUP_BY[]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            select (function-call: algebricks:gt, Args:[%0->$$1, 0.0])
+            -- STREAM_SELECT  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                data-scan [$$1]<-[$$1, $$2, $$3] <- default.q22_customer_tmp
+                -- DATASOURCE_SCAN  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    empty-tuple-source
+                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$2]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    distinct ([%0->$$2])
+    -- PRE_SORTED_DISTINCT_BY  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+        order (ASC, %0->$$2) 
+        -- STABLE_SORT [$$2(ASC)]  |LOCAL|
+          exchange 
+          -- HASH_PARTITION_EXCHANGE [$$2]  |PARTITIONED|
+            data-scan [$$2]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.orders
+            -- DATASOURCE_SCAN  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                empty-tuple-source
+                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$6, %0->$$9, %0->$$8]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$6, $$9, $$8])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$9] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToInteger, Args:[%0->$$7]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- SORT_MERGE_EXCHANGE [$$6(ASC) ]  |PARTITIONED|
+        order (ASC, %0->$$6) 
+        -- STABLE_SORT [$$6(ASC)]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            group by ([$$6 := %0->$$13]) decor ([]) {
+                      aggregate [$$7, $$8] <- [function-call: hive:count(FINAL), Args:[%0->$$11], function-call: hive:sum(FINAL), Args:[%0->$$12]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[$$13]  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$13]  |PARTITIONED|
+                group by ([$$13 := %0->$$5]) decor ([]) {
+                          aggregate [$$11, $$12] <- [function-call: hive:count(PARTIAL1), Args:[1], function-call: hive:sum(PARTIAL1), Args:[%0->$$3]]
+                          -- AGGREGATE  |LOCAL|
+                            nested tuple source
+                            -- NESTED_TUPLE_SOURCE  |LOCAL|
+                       }
+                -- EXTERNAL_GROUP_BY[$$5]  |LOCAL|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    project ([$$5, $$3])
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        join (function-call: algebricks:and, Args:[function-call: algebricks:gt, Args:[%0->$$3, %0->$$1], true])
+                        -- NESTED_LOOP  |PARTITIONED|
+                          exchange 
+                          -- BROADCAST_EXCHANGE  |PARTITIONED|
+                            project ([$$5, $$3])
+                            -- STREAM_PROJECT  |PARTITIONED|
+                              select (function-call: hive:org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNull, Args:[%0->$$2])
+                              -- STREAM_SELECT  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  left outer join (function-call: algebricks:eq, Args:[%0->$$4, %0->$$2])
+                                  -- HYBRID_HASH_JOIN [$$4][$$2]  |PARTITIONED|
+                                    exchange 
+                                    -- HASH_PARTITION_EXCHANGE [$$4]  |PARTITIONED|
+                                      data-scan []<-[$$3, $$4, $$5] <- default.q22_customer_tmp
+                                      -- DATASOURCE_SCAN  |PARTITIONED|
+                                        exchange 
+                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                          empty-tuple-source
+                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                    exchange 
+                                    -- HASH_PARTITION_EXCHANGE [$$2]  |PARTITIONED|
+                                      data-scan [$$2]<-[$$2] <- default.q22_orders_tmp
+                                      -- DATASOURCE_SCAN  |PARTITIONED|
+                                        exchange 
+                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                          empty-tuple-source
+                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            data-scan [$$1]<-[$$1] <- default.q22_customer_tmp1
+                            -- DATASOURCE_SCAN  |PARTITIONED|
+                              exchange 
+                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                empty-tuple-source
+                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q2_minimum_cost_supplier.plan b/src/test/resources/optimizerts/results/q2_minimum_cost_supplier.plan
new file mode 100644
index 0000000..151f34d
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q2_minimum_cost_supplier.plan
@@ -0,0 +1,156 @@
+write [%0->$$20, %0->$$16, %0->$$26, %0->$$1, %0->$$13, %0->$$3, %0->$$17, %0->$$19, %0->$$21]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$20, $$16, $$26, $$1, $$13, $$3, $$17, $$19, $$21])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      join (function-call: algebricks:eq, Args:[%0->$$1, %0->$$10])
+      -- HYBRID_HASH_JOIN [$$1][$$10]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+          project ([$$1, $$3])
+          -- STREAM_PROJECT  |PARTITIONED|
+            select (function-call: algebricks:and, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFLike, Args:[%0->$$5, %BRASS], function-call: algebricks:eq, Args:[%0->$$6, 15], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFLike, Args:[%0->$$5, %BRASS]])
+            -- STREAM_SELECT  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                data-scan [$$1, $$3, $$5, $$6]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.part
+                -- DATASOURCE_SCAN  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    empty-tuple-source
+                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$10]  |PARTITIONED|
+          project ([$$10, $$16, $$17, $$19, $$20, $$21, $$26, $$13])
+          -- STREAM_PROJECT  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              join (function-call: algebricks:eq, Args:[%0->$$11, %0->$$15])
+              -- HYBRID_HASH_JOIN [$$11][$$15]  |PARTITIONED|
+                exchange 
+                -- HASH_PARTITION_EXCHANGE [$$11]  |PARTITIONED|
+                  data-scan [$$11, $$10, $$13]<-[$$10, $$11, $$12, $$13, $$14] <- default.partsupp
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                exchange 
+                -- HASH_PARTITION_EXCHANGE [$$15]  |PARTITIONED|
+                  project ([$$15, $$16, $$17, $$19, $$20, $$21, $$26])
+                  -- STREAM_PROJECT  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      join (function-call: algebricks:eq, Args:[%0->$$18, %0->$$25])
+                      -- HYBRID_HASH_JOIN [$$18][$$25]  |PARTITIONED|
+                        exchange 
+                        -- HASH_PARTITION_EXCHANGE [$$18]  |PARTITIONED|
+                          data-scan []<-[$$15, $$16, $$17, $$18, $$19, $$20, $$21] <- default.supplier
+                          -- DATASOURCE_SCAN  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              empty-tuple-source
+                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                        exchange 
+                        -- HASH_PARTITION_EXCHANGE [$$25]  |PARTITIONED|
+                          project ([$$25, $$26])
+                          -- STREAM_PROJECT  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              join (function-call: algebricks:eq, Args:[%0->$$22, %0->$$27])
+                              -- HYBRID_HASH_JOIN [$$22][$$27]  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$22]  |PARTITIONED|
+                                  project ([$$22])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    select (function-call: algebricks:eq, Args:[%0->$$23, EUROPE])
+                                    -- STREAM_SELECT  |PARTITIONED|
+                                      exchange 
+                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                        data-scan [$$23, $$22]<-[$$22, $$23, $$24] <- default.region
+                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                          exchange 
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            empty-tuple-source
+                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$27]  |PARTITIONED|
+                                  data-scan [$$27, $$25, $$26]<-[$$25, $$26, $$27, $$28] <- default.nation
+                                  -- DATASOURCE_SCAN  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      empty-tuple-source
+                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$10, %0->$$11]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$10, $$11])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      group by ([$$10 := %0->$$14]) decor ([]) {
+                aggregate [$$11] <- [function-call: hive:min(FINAL), Args:[%0->$$13]]
+                -- AGGREGATE  |LOCAL|
+                  nested tuple source
+                  -- NESTED_TUPLE_SOURCE  |LOCAL|
+             }
+      -- PRE_CLUSTERED_GROUP_BY[$$14]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_MERGE_EXCHANGE MERGE:[$$14(ASC)] HASH:[$$14]  |PARTITIONED|
+          group by ([$$14 := %0->$$4]) decor ([]) {
+                    aggregate [$$13] <- [function-call: hive:min(PARTIAL1), Args:[%0->$$5]]
+                    -- AGGREGATE  |LOCAL|
+                      nested tuple source
+                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                 }
+          -- PRE_CLUSTERED_GROUP_BY[$$4]  |LOCAL|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+              order (ASC, %0->$$4) 
+              -- STABLE_SORT [$$4(ASC)]  |LOCAL|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  data-scan [$$4, $$5]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.q2_minimum_cost_supplier_tmp1
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$3, %0->$$4, %0->$$5, %0->$$6, %0->$$8, %0->$$9, %0->$$10, %0->$$11]
+-- SINK_WRITE  |UNPARTITIONED|
+  limit 100
+  -- STREAM_LIMIT  |UNPARTITIONED|
+    limit 100
+    -- STREAM_LIMIT  |UNPARTITIONED|
+      exchange 
+      -- SORT_MERGE_EXCHANGE [$$3(DESC), $$5(ASC), $$4(ASC), $$6(ASC) ]  |PARTITIONED|
+        limit 100
+        -- STREAM_LIMIT  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+            order (DESC, %0->$$3) (ASC, %0->$$5) (ASC, %0->$$4) (ASC, %0->$$6) 
+            -- STABLE_SORT [$$3(DESC), $$5(ASC), $$4(ASC), $$6(ASC)]  |LOCAL|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                project ([$$3, $$4, $$5, $$6, $$8, $$9, $$10, $$11])
+                -- STREAM_PROJECT  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    join (function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$1, %0->$$6], function-call: algebricks:eq, Args:[%0->$$2, %0->$$7]])
+                    -- HYBRID_HASH_JOIN [$$1, $$2][$$6, $$7]  |PARTITIONED|
+                      exchange 
+                      -- HASH_PARTITION_EXCHANGE [$$1, $$2]  |PARTITIONED|
+                        data-scan []<-[$$1, $$2] <- default.q2_minimum_cost_supplier_tmp2
+                        -- DATASOURCE_SCAN  |PARTITIONED|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            empty-tuple-source
+                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                      exchange 
+                      -- HASH_PARTITION_EXCHANGE [$$6, $$7]  |PARTITIONED|
+                        data-scan [$$6, $$7, $$3, $$4, $$5, $$8, $$9, $$10, $$11]<-[$$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11] <- default.q2_minimum_cost_supplier_tmp1
+                        -- DATASOURCE_SCAN  |PARTITIONED|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            empty-tuple-source
+                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q3_shipping_priority.plan b/src/test/resources/optimizerts/results/q3_shipping_priority.plan
new file mode 100644
index 0000000..a1b8e42
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q3_shipping_priority.plan
@@ -0,0 +1,70 @@
+write [%0->$$1, %0->$$34, %0->$$29, %0->$$32]
+-- SINK_WRITE  |UNPARTITIONED|
+  limit 10
+  -- STREAM_LIMIT  |UNPARTITIONED|
+    limit 10
+    -- STREAM_LIMIT  |UNPARTITIONED|
+      exchange 
+      -- SORT_MERGE_EXCHANGE [$$34(DESC) ]  |PARTITIONED|
+        limit 10
+        -- STREAM_LIMIT  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+            order (DESC, %0->$$34) 
+            -- STABLE_SORT [$$34(DESC)]  |LOCAL|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                project ([$$1, $$34, $$29, $$32])
+                -- STREAM_PROJECT  |PARTITIONED|
+                  assign [$$34] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$6, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$7]]]
+                  -- ASSIGN  |PARTITIONED|
+                    project ([$$29, $$32, $$1, $$6, $$7])
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        join (function-call: algebricks:eq, Args:[%0->$$1, %0->$$25])
+                        -- HYBRID_HASH_JOIN [$$1][$$25]  |PARTITIONED|
+                          exchange 
+                          -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                            project ([$$1, $$6, $$7])
+                            -- STREAM_PROJECT  |PARTITIONED|
+                              select (function-call: algebricks:lt, Args:[%0->$$4, 3])
+                              -- STREAM_SELECT  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  data-scan [$$1, $$4, $$6, $$7]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                                  -- DATASOURCE_SCAN  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      empty-tuple-source
+                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                          exchange 
+                          -- HASH_PARTITION_EXCHANGE [$$25]  |PARTITIONED|
+                            project ([$$25, $$29, $$32])
+                            -- STREAM_PROJECT  |PARTITIONED|
+                              exchange 
+                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                join (function-call: algebricks:eq, Args:[%0->$$26, %0->$$17])
+                                -- HYBRID_HASH_JOIN [$$26][$$17]  |PARTITIONED|
+                                  exchange 
+                                  -- HASH_PARTITION_EXCHANGE [$$26]  |PARTITIONED|
+                                    data-scan [$$26, $$25, $$29, $$32]<-[$$25, $$26, $$27, $$28, $$29, $$30, $$31, $$32, $$33] <- default.orders
+                                    -- DATASOURCE_SCAN  |PARTITIONED|
+                                      exchange 
+                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                        empty-tuple-source
+                                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                  exchange 
+                                  -- HASH_PARTITION_EXCHANGE [$$17]  |PARTITIONED|
+                                    project ([$$17])
+                                    -- STREAM_PROJECT  |PARTITIONED|
+                                      select (function-call: algebricks:eq, Args:[%0->$$23, BUILDING])
+                                      -- STREAM_SELECT  |PARTITIONED|
+                                        exchange 
+                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                          data-scan [$$17, $$23]<-[$$17, $$18, $$19, $$20, $$21, $$22, $$23, $$24] <- default.customer
+                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              empty-tuple-source
+                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q4_order_priority.plan b/src/test/resources/optimizerts/results/q4_order_priority.plan
new file mode 100644
index 0000000..435fd7c
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q4_order_priority.plan
@@ -0,0 +1,82 @@
+write [%0->$$1]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    distinct ([%0->$$1])
+    -- PRE_SORTED_DISTINCT_BY  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+        order (ASC, %0->$$1) 
+        -- STABLE_SORT [$$1(ASC)]  |LOCAL|
+          exchange 
+          -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+            project ([$$1])
+            -- STREAM_PROJECT  |PARTITIONED|
+              select (function-call: algebricks:lt, Args:[%0->$$12, %0->$$13])
+              -- STREAM_SELECT  |PARTITIONED|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  data-scan [$$1, $$12, $$13]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$11, %0->$$13]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$11, $$13])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$13] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFToInteger, Args:[%0->$$12]]
+    -- ASSIGN  |PARTITIONED|
+      exchange 
+      -- SORT_MERGE_EXCHANGE [$$11(ASC) ]  |PARTITIONED|
+        order (ASC, %0->$$11) 
+        -- STABLE_SORT [$$11(ASC)]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            group by ([$$11 := %0->$$16]) decor ([]) {
+                      aggregate [$$12] <- [function-call: hive:count(FINAL), Args:[%0->$$15]]
+                      -- AGGREGATE  |LOCAL|
+                        nested tuple source
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- EXTERNAL_GROUP_BY[$$16]  |PARTITIONED|
+              exchange 
+              -- HASH_PARTITION_EXCHANGE [$$16]  |PARTITIONED|
+                group by ([$$16 := %0->$$7]) decor ([]) {
+                          aggregate [$$15] <- [function-call: hive:count(PARTIAL1), Args:[1]]
+                          -- AGGREGATE  |LOCAL|
+                            nested tuple source
+                            -- NESTED_TUPLE_SOURCE  |LOCAL|
+                       }
+                -- EXTERNAL_GROUP_BY[$$7]  |LOCAL|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    project ([$$7])
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        join (function-call: algebricks:eq, Args:[%0->$$1, %0->$$2])
+                        -- HYBRID_HASH_JOIN [$$1][$$2]  |PARTITIONED|
+                          exchange 
+                          -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                            data-scan []<-[$$1] <- default.q4_order_priority_tmp
+                            -- DATASOURCE_SCAN  |PARTITIONED|
+                              exchange 
+                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                empty-tuple-source
+                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                          exchange 
+                          -- HASH_PARTITION_EXCHANGE [$$2]  |PARTITIONED|
+                            project ([$$2, $$7])
+                            -- STREAM_PROJECT  |PARTITIONED|
+                              select (function-call: algebricks:and, Args:[function-call: algebricks:lt, Args:[%0->$$6, 1993-10-01], function-call: algebricks:ge, Args:[%0->$$6, 1993-07-01], function-call: algebricks:lt, Args:[%0->$$6, 1993-10-01]])
+                              -- STREAM_SELECT  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  data-scan [$$2, $$6, $$7]<-[$$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10] <- default.orders
+                                  -- DATASOURCE_SCAN  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      empty-tuple-source
+                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q5_local_supplier_volume.plan b/src/test/resources/optimizerts/results/q5_local_supplier_volume.plan
new file mode 100644
index 0000000..177d24c
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q5_local_supplier_volume.plan
@@ -0,0 +1,126 @@
+write [%0->$$48, %0->$$49]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$48, $$49])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- SORT_MERGE_EXCHANGE [$$49(DESC) ]  |PARTITIONED|
+      order (DESC, %0->$$49) 
+      -- STABLE_SORT [$$49(DESC)]  |LOCAL|
+        exchange 
+        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          group by ([$$48 := %0->$$52]) decor ([]) {
+                    aggregate [$$49] <- [function-call: hive:sum(FINAL), Args:[%0->$$51]]
+                    -- AGGREGATE  |LOCAL|
+                      nested tuple source
+                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                 }
+          -- EXTERNAL_GROUP_BY[$$52]  |PARTITIONED|
+            exchange 
+            -- HASH_PARTITION_EXCHANGE [$$52]  |PARTITIONED|
+              group by ([$$52 := %0->$$42]) decor ([]) {
+                        aggregate [$$51] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$23, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$24]]]]
+                        -- AGGREGATE  |LOCAL|
+                          nested tuple source
+                          -- NESTED_TUPLE_SOURCE  |LOCAL|
+                     }
+              -- EXTERNAL_GROUP_BY[$$42]  |LOCAL|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  project ([$$42, $$23, $$24])
+                  -- STREAM_PROJECT  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      join (function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$37, %0->$$4], function-call: algebricks:eq, Args:[%0->$$10, %0->$$1]])
+                      -- HYBRID_HASH_JOIN [$$37, $$10][$$4, $$1]  |PARTITIONED|
+                        exchange 
+                        -- HASH_PARTITION_EXCHANGE [$$37, $$10]  |PARTITIONED|
+                          project ([$$10, $$42, $$23, $$24, $$37])
+                          -- STREAM_PROJECT  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              join (function-call: algebricks:eq, Args:[%0->$$18, %0->$$9])
+                              -- HYBRID_HASH_JOIN [$$18][$$9]  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$18]  |PARTITIONED|
+                                  project ([$$18, $$23, $$24, $$42, $$37])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      join (function-call: algebricks:eq, Args:[%0->$$34, %0->$$20])
+                                      -- HYBRID_HASH_JOIN [$$34][$$20]  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$34]  |PARTITIONED|
+                                          project ([$$34, $$37, $$42])
+                                          -- STREAM_PROJECT  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              join (function-call: algebricks:eq, Args:[%0->$$41, %0->$$37])
+                                              -- HYBRID_HASH_JOIN [$$41][$$37]  |PARTITIONED|
+                                                exchange 
+                                                -- HASH_PARTITION_EXCHANGE [$$41]  |PARTITIONED|
+                                                  project ([$$41, $$42])
+                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                    exchange 
+                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                      join (function-call: algebricks:eq, Args:[%0->$$45, %0->$$43])
+                                                      -- HYBRID_HASH_JOIN [$$45][$$43]  |PARTITIONED|
+                                                        exchange 
+                                                        -- HASH_PARTITION_EXCHANGE [$$45]  |PARTITIONED|
+                                                          project ([$$45])
+                                                          -- STREAM_PROJECT  |PARTITIONED|
+                                                            select (function-call: algebricks:eq, Args:[%0->$$46, ASIA])
+                                                            -- STREAM_SELECT  |PARTITIONED|
+                                                              exchange 
+                                                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                data-scan [$$46, $$45]<-[$$45, $$46, $$47] <- default.region
+                                                                -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                  exchange 
+                                                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                    empty-tuple-source
+                                                                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                        exchange 
+                                                        -- HASH_PARTITION_EXCHANGE [$$43]  |PARTITIONED|
+                                                          data-scan [$$43, $$41, $$42]<-[$$41, $$42, $$43, $$44] <- default.nation
+                                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                                            exchange 
+                                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                              empty-tuple-source
+                                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                exchange 
+                                                -- HASH_PARTITION_EXCHANGE [$$37]  |PARTITIONED|
+                                                  data-scan [$$37, $$34]<-[$$34, $$35, $$36, $$37, $$38, $$39, $$40] <- default.supplier
+                                                  -- DATASOURCE_SCAN  |PARTITIONED|
+                                                    exchange 
+                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                      empty-tuple-source
+                                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$20]  |PARTITIONED|
+                                          data-scan [$$20, $$18, $$23, $$24]<-[$$18, $$19, $$20, $$21, $$22, $$23, $$24, $$25, $$26, $$27, $$28, $$29, $$30, $$31, $$32, $$33] <- default.lineitem
+                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              empty-tuple-source
+                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$9]  |PARTITIONED|
+                                  project ([$$9, $$10])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    select (function-call: algebricks:and, Args:[function-call: algebricks:lt, Args:[%0->$$13, 1995-01-01], function-call: algebricks:ge, Args:[%0->$$13, 1994-01-01], function-call: algebricks:lt, Args:[%0->$$13, 1995-01-01]])
+                                    -- STREAM_SELECT  |PARTITIONED|
+                                      exchange 
+                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                        data-scan [$$9, $$10, $$13]<-[$$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16, $$17] <- default.orders
+                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                          exchange 
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            empty-tuple-source
+                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                        exchange 
+                        -- HASH_PARTITION_EXCHANGE [$$4, $$1]  |PARTITIONED|
+                          data-scan [$$4, $$1]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8] <- default.customer
+                          -- DATASOURCE_SCAN  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              empty-tuple-source
+                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q6_forecast_revenue_change.plan b/src/test/resources/optimizerts/results/q6_forecast_revenue_change.plan
new file mode 100644
index 0000000..cd9ffcd
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q6_forecast_revenue_change.plan
@@ -0,0 +1,34 @@
+write [%0->$$17]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    group by ([]) decor ([]) {
+              aggregate [$$17] <- [function-call: hive:sum(FINAL), Args:[%0->$$19]]
+              -- AGGREGATE  |LOCAL|
+                nested tuple source
+                -- NESTED_TUPLE_SOURCE  |LOCAL|
+           }
+    -- EXTERNAL_GROUP_BY[]  |PARTITIONED|
+      exchange 
+      -- HASH_PARTITION_EXCHANGE []  |PARTITIONED|
+        group by ([]) decor ([]) {
+                  aggregate [$$19] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$6, %0->$$7]]]
+                  -- AGGREGATE  |LOCAL|
+                    nested tuple source
+                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+               }
+        -- EXTERNAL_GROUP_BY[]  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            project ([$$6, $$7])
+            -- STREAM_PROJECT  |PARTITIONED|
+              select (function-call: algebricks:and, Args:[function-call: algebricks:ge, Args:[%0->$$11, 1994-01-01], function-call: algebricks:lt, Args:[%0->$$11, 1995-01-01], function-call: algebricks:ge, Args:[%0->$$7, 0.05], function-call: algebricks:le, Args:[%0->$$7, 0.07], function-call: algebricks:lt, Args:[%0->$$5, 24], function-call: algebricks:ge, Args:[%0->$$11, 1994-01-01], function-call: algebricks:lt, Args:[%0->$$11, 1995-01-01], function-call: algebricks:ge, Args:[%0->$$7, 0.05], function-call: algebricks:le, Args:[%0->$$7, 0.07], function-call: algebricks:lt, Args:[%0->$$5, 24]])
+              -- STREAM_SELECT  |PARTITIONED|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  data-scan [$$5, $$6, $$7, $$11]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q7_volume_shipping.plan b/src/test/resources/optimizerts/results/q7_volume_shipping.plan
new file mode 100644
index 0000000..39f8301
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q7_volume_shipping.plan
@@ -0,0 +1,192 @@
+write [%0->$$17, %0->$$18, %0->$$19, %0->$$20]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    union ($$6, $$10, $$17) ($$2, $$14, $$18) ($$5, $$9, $$19) ($$1, $$13, $$20)
+    -- UNION_ALL  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+        project ([$$6, $$2, $$5, $$1])
+        -- STREAM_PROJECT  |UNPARTITIONED|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            join (true)
+            -- NESTED_LOOP  |PARTITIONED|
+              exchange 
+              -- BROADCAST_EXCHANGE  |PARTITIONED|
+                select (function-call: algebricks:eq, Args:[%0->$$2, GERMANY])
+                -- STREAM_SELECT  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    data-scan [$$1, $$2]<-[$$1, $$2, $$3, $$4] <- default.nation
+                    -- DATASOURCE_SCAN  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        empty-tuple-source
+                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                project ([$$5, $$6])
+                -- STREAM_PROJECT  |PARTITIONED|
+                  select (function-call: algebricks:eq, Args:[%0->$$6, FRANCE])
+                  -- STREAM_SELECT  |PARTITIONED|
+                    project ([$$5, $$6])
+                    -- STREAM_PROJECT  |UNPARTITIONED|
+                      assign [$$5, $$6] <- [%0->$$9, %0->$$10]
+                      -- ASSIGN  |UNPARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          replicate 
+                          -- SPLIT  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              data-scan [$$9, $$10]<-[$$9, $$10, $$11, $$12] <- default.nation
+                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  empty-tuple-source
+                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+        project ([$$10, $$14, $$9, $$13])
+        -- STREAM_PROJECT  |UNPARTITIONED|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            join (true)
+            -- NESTED_LOOP  |PARTITIONED|
+              exchange 
+              -- BROADCAST_EXCHANGE  |PARTITIONED|
+                select (function-call: algebricks:eq, Args:[%0->$$14, FRANCE])
+                -- STREAM_SELECT  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    data-scan [$$13, $$14]<-[$$13, $$14, $$15, $$16] <- default.nation
+                    -- DATASOURCE_SCAN  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        empty-tuple-source
+                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                project ([$$9, $$10])
+                -- STREAM_PROJECT  |PARTITIONED|
+                  select (function-call: algebricks:eq, Args:[%0->$$10, GERMANY])
+                  -- STREAM_SELECT  |PARTITIONED|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      replicate 
+                      -- SPLIT  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          data-scan [$$9, $$10]<-[$$9, $$10, $$11, $$12] <- default.nation
+                          -- DATASOURCE_SCAN  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              empty-tuple-source
+                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$47, %0->$$48, %0->$$49, %0->$$50]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$47, $$48, $$49, $$50])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- SORT_MERGE_EXCHANGE [$$47(ASC), $$48(ASC), $$49(ASC) ]  |PARTITIONED|
+      order (ASC, %0->$$47) (ASC, %0->$$48) (ASC, %0->$$49) 
+      -- STABLE_SORT [$$47(ASC), $$48(ASC), $$49(ASC)]  |LOCAL|
+        exchange 
+        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          group by ([$$47 := %0->$$53; $$48 := %0->$$54; $$49 := %0->$$55]) decor ([]) {
+                    aggregate [$$50] <- [function-call: hive:sum(FINAL), Args:[%0->$$52]]
+                    -- AGGREGATE  |LOCAL|
+                      nested tuple source
+                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                 }
+          -- EXTERNAL_GROUP_BY[$$53, $$54, $$55]  |PARTITIONED|
+            exchange 
+            -- HASH_PARTITION_EXCHANGE [$$53, $$54, $$55]  |PARTITIONED|
+              group by ([$$53 := %0->$$1; $$54 := %0->$$2; $$55 := %0->$$45]) decor ([]) {
+                        aggregate [$$52] <- [function-call: hive:sum(PARTIAL1), Args:[%0->$$46]]
+                        -- AGGREGATE  |LOCAL|
+                          nested tuple source
+                          -- NESTED_TUPLE_SOURCE  |LOCAL|
+                     }
+              -- EXTERNAL_GROUP_BY[$$1, $$2, $$45]  |LOCAL|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  project ([$$1, $$2, $$45, $$46])
+                  -- STREAM_PROJECT  |PARTITIONED|
+                    assign [$$45, $$46] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFYear, Args:[%0->$$30], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$25, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$26]]]
+                    -- ASSIGN  |PARTITIONED|
+                      project ([$$1, $$2, $$30, $$25, $$26])
+                      -- STREAM_PROJECT  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          join (function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$15, %0->$$4], function-call: algebricks:eq, Args:[%0->$$8, %0->$$3]])
+                          -- HYBRID_HASH_JOIN [$$15, $$8][$$4, $$3]  |PARTITIONED|
+                            exchange 
+                            -- HASH_PARTITION_EXCHANGE [$$15, $$8]  |PARTITIONED|
+                              project ([$$8, $$30, $$25, $$26, $$15])
+                              -- STREAM_PROJECT  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  join (function-call: algebricks:eq, Args:[%0->$$22, %0->$$5])
+                                  -- HYBRID_HASH_JOIN [$$22][$$5]  |PARTITIONED|
+                                    exchange 
+                                    -- HASH_PARTITION_EXCHANGE [$$22]  |PARTITIONED|
+                                      project ([$$15, $$30, $$25, $$26, $$22])
+                                      -- STREAM_PROJECT  |PARTITIONED|
+                                        exchange 
+                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                          join (function-call: algebricks:eq, Args:[%0->$$37, %0->$$12])
+                                          -- HYBRID_HASH_JOIN [$$37][$$12]  |PARTITIONED|
+                                            exchange 
+                                            -- HASH_PARTITION_EXCHANGE [$$37]  |PARTITIONED|
+                                              project ([$$37, $$22, $$25, $$26, $$30])
+                                              -- STREAM_PROJECT  |PARTITIONED|
+                                                exchange 
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  join (function-call: algebricks:eq, Args:[%0->$$20, %0->$$36])
+                                                  -- HYBRID_HASH_JOIN [$$20][$$36]  |PARTITIONED|
+                                                    exchange 
+                                                    -- HASH_PARTITION_EXCHANGE [$$20]  |PARTITIONED|
+                                                      select (function-call: algebricks:and, Args:[function-call: algebricks:le, Args:[%0->$$30, 1996-12-31], function-call: algebricks:ge, Args:[%0->$$30, 1995-01-01], function-call: algebricks:le, Args:[%0->$$30, 1996-12-31]])
+                                                      -- STREAM_SELECT  |PARTITIONED|
+                                                        exchange 
+                                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                          data-scan [$$20, $$22, $$25, $$26, $$30]<-[$$20, $$21, $$22, $$23, $$24, $$25, $$26, $$27, $$28, $$29, $$30, $$31, $$32, $$33, $$34, $$35] <- default.lineitem
+                                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                                            exchange 
+                                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                              empty-tuple-source
+                                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                    exchange 
+                                                    -- HASH_PARTITION_EXCHANGE [$$36]  |PARTITIONED|
+                                                      data-scan [$$36, $$37]<-[$$36, $$37, $$38, $$39, $$40, $$41, $$42, $$43, $$44] <- default.orders
+                                                      -- DATASOURCE_SCAN  |PARTITIONED|
+                                                        exchange 
+                                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                          empty-tuple-source
+                                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                            exchange 
+                                            -- HASH_PARTITION_EXCHANGE [$$12]  |PARTITIONED|
+                                              data-scan [$$12, $$15]<-[$$12, $$13, $$14, $$15, $$16, $$17, $$18, $$19] <- default.customer
+                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                exchange 
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  empty-tuple-source
+                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                    exchange 
+                                    -- HASH_PARTITION_EXCHANGE [$$5]  |PARTITIONED|
+                                      data-scan [$$5, $$8]<-[$$5, $$6, $$7, $$8, $$9, $$10, $$11] <- default.supplier
+                                      -- DATASOURCE_SCAN  |PARTITIONED|
+                                        exchange 
+                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                          empty-tuple-source
+                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                            exchange 
+                            -- HASH_PARTITION_EXCHANGE [$$4, $$3]  |PARTITIONED|
+                              data-scan [$$4, $$3, $$1, $$2]<-[$$1, $$2, $$3, $$4] <- default.q7_volume_shipping_tmp
+                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  empty-tuple-source
+                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q8_national_market_share.plan b/src/test/resources/optimizerts/results/q8_national_market_share.plan
new file mode 100644
index 0000000..b807a24
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q8_national_market_share.plan
@@ -0,0 +1,190 @@
+write [%0->$$63, %0->$$66]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- SORT_MERGE_EXCHANGE [$$63(ASC) ]  |PARTITIONED|
+    order (ASC, %0->$$63) 
+    -- STABLE_SORT [$$63(ASC)]  |LOCAL|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        project ([$$63, $$66])
+        -- STREAM_PROJECT  |PARTITIONED|
+          assign [$$66] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPDivide, Args:[%0->$$64, %0->$$65]]
+          -- ASSIGN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              group by ([$$63 := %0->$$70]) decor ([]) {
+                        aggregate [$$64, $$65] <- [function-call: hive:sum(FINAL), Args:[%0->$$68], function-call: hive:sum(FINAL), Args:[%0->$$69]]
+                        -- AGGREGATE  |LOCAL|
+                          nested tuple source
+                          -- NESTED_TUPLE_SOURCE  |LOCAL|
+                     }
+              -- EXTERNAL_GROUP_BY[$$70]  |PARTITIONED|
+                exchange 
+                -- HASH_PARTITION_EXCHANGE [$$70]  |PARTITIONED|
+                  group by ([$$70 := %0->$$61]) decor ([]) {
+                            aggregate [$$68, $$69] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen, Args:[function-call: algebricks:eq, Args:[%0->$$2, BRAZIL], %0->$$62, 0.0]], function-call: hive:sum(PARTIAL1), Args:[%0->$$62]]
+                            -- AGGREGATE  |LOCAL|
+                              nested tuple source
+                              -- NESTED_TUPLE_SOURCE  |LOCAL|
+                         }
+                  -- EXTERNAL_GROUP_BY[$$61]  |LOCAL|
+                    exchange 
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      project ([$$61, $$62, $$2])
+                      -- STREAM_PROJECT  |PARTITIONED|
+                        assign [$$61, $$62] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFYear, Args:[%0->$$41], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$26, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$27]]]
+                        -- ASSIGN  |PARTITIONED|
+                          project ([$$2, $$41, $$27, $$26])
+                          -- STREAM_PROJECT  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              join (function-call: algebricks:eq, Args:[%0->$$8, %0->$$1])
+                              -- HYBRID_HASH_JOIN [$$8][$$1]  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$8]  |PARTITIONED|
+                                  project ([$$8, $$41, $$27, $$26])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    exchange 
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      join (function-call: algebricks:eq, Args:[%0->$$23, %0->$$5])
+                                      -- HYBRID_HASH_JOIN [$$23][$$5]  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$23]  |PARTITIONED|
+                                          project ([$$41, $$27, $$26, $$23])
+                                          -- STREAM_PROJECT  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              join (function-call: algebricks:eq, Args:[%0->$$22, %0->$$12])
+                                              -- HYBRID_HASH_JOIN [$$22][$$12]  |PARTITIONED|
+                                                exchange 
+                                                -- HASH_PARTITION_EXCHANGE [$$22]  |PARTITIONED|
+                                                  project ([$$41, $$22, $$23, $$26, $$27])
+                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                    exchange 
+                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                      join (function-call: algebricks:eq, Args:[%0->$$21, %0->$$37])
+                                                      -- HYBRID_HASH_JOIN [$$21][$$37]  |PARTITIONED|
+                                                        exchange 
+                                                        -- HASH_PARTITION_EXCHANGE [$$21]  |PARTITIONED|
+                                                          data-scan [$$21, $$22, $$23, $$26, $$27]<-[$$21, $$22, $$23, $$24, $$25, $$26, $$27, $$28, $$29, $$30, $$31, $$32, $$33, $$34, $$35, $$36] <- default.lineitem
+                                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                                            exchange 
+                                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                              empty-tuple-source
+                                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                        exchange 
+                                                        -- HASH_PARTITION_EXCHANGE [$$37]  |PARTITIONED|
+                                                          project ([$$37, $$41])
+                                                          -- STREAM_PROJECT  |PARTITIONED|
+                                                            exchange 
+                                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                              join (function-call: algebricks:eq, Args:[%0->$$46, %0->$$38])
+                                                              -- HYBRID_HASH_JOIN [$$46][$$38]  |PARTITIONED|
+                                                                exchange 
+                                                                -- HASH_PARTITION_EXCHANGE [$$46]  |PARTITIONED|
+                                                                  project ([$$46])
+                                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                                    exchange 
+                                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                      join (function-call: algebricks:eq, Args:[%0->$$54, %0->$$49])
+                                                                      -- HYBRID_HASH_JOIN [$$54][$$49]  |PARTITIONED|
+                                                                        exchange 
+                                                                        -- HASH_PARTITION_EXCHANGE [$$54]  |PARTITIONED|
+                                                                          project ([$$54])
+                                                                          -- STREAM_PROJECT  |PARTITIONED|
+                                                                            exchange 
+                                                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                              join (function-call: algebricks:eq, Args:[%0->$$58, %0->$$56])
+                                                                              -- HYBRID_HASH_JOIN [$$58][$$56]  |PARTITIONED|
+                                                                                exchange 
+                                                                                -- HASH_PARTITION_EXCHANGE [$$58]  |PARTITIONED|
+                                                                                  project ([$$58])
+                                                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                                                    select (function-call: algebricks:eq, Args:[%0->$$59, AMERICA])
+                                                                                    -- STREAM_SELECT  |PARTITIONED|
+                                                                                      exchange 
+                                                                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                                        data-scan [$$59, $$58]<-[$$58, $$59, $$60] <- default.region
+                                                                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                                          exchange 
+                                                                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                                            empty-tuple-source
+                                                                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                                                exchange 
+                                                                                -- HASH_PARTITION_EXCHANGE [$$56]  |PARTITIONED|
+                                                                                  project ([$$56, $$54])
+                                                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                                                    exchange 
+                                                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                                      replicate 
+                                                                                      -- SPLIT  |PARTITIONED|
+                                                                                        exchange 
+                                                                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                                          data-scan []<-[$$54, $$55, $$56, $$57] <- default.nation
+                                                                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                                            exchange 
+                                                                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                                              empty-tuple-source
+                                                                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                                        exchange 
+                                                                        -- HASH_PARTITION_EXCHANGE [$$49]  |PARTITIONED|
+                                                                          data-scan [$$49, $$46]<-[$$46, $$47, $$48, $$49, $$50, $$51, $$52, $$53] <- default.customer
+                                                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                            exchange 
+                                                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                              empty-tuple-source
+                                                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                                exchange 
+                                                                -- HASH_PARTITION_EXCHANGE [$$38]  |PARTITIONED|
+                                                                  project ([$$38, $$37, $$41])
+                                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                                    select (function-call: algebricks:and, Args:[function-call: algebricks:lt, Args:[%0->$$41, 1996-12-31], function-call: algebricks:ge, Args:[%0->$$41, 1995-01-01]])
+                                                                    -- STREAM_SELECT  |PARTITIONED|
+                                                                      exchange 
+                                                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                        data-scan [$$38, $$37, $$41]<-[$$37, $$38, $$39, $$40, $$41, $$42, $$43, $$44, $$45] <- default.orders
+                                                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                          exchange 
+                                                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                            empty-tuple-source
+                                                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                exchange 
+                                                -- HASH_PARTITION_EXCHANGE [$$12]  |PARTITIONED|
+                                                  project ([$$12])
+                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                    select (function-call: algebricks:eq, Args:[%0->$$16, ECONOMY ANODIZED STEEL])
+                                                    -- STREAM_SELECT  |PARTITIONED|
+                                                      exchange 
+                                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                        data-scan [$$16, $$12]<-[$$12, $$13, $$14, $$15, $$16, $$17, $$18, $$19, $$20] <- default.part
+                                                        -- DATASOURCE_SCAN  |PARTITIONED|
+                                                          exchange 
+                                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                            empty-tuple-source
+                                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                        exchange 
+                                        -- HASH_PARTITION_EXCHANGE [$$5]  |PARTITIONED|
+                                          data-scan [$$5, $$8]<-[$$5, $$6, $$7, $$8, $$9, $$10, $$11] <- default.supplier
+                                          -- DATASOURCE_SCAN  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              empty-tuple-source
+                                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                exchange 
+                                -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                                  project ([$$1, $$2])
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    assign [$$1, $$2, $$3, $$4] <- [%0->$$54, %0->$$55, %0->$$56, %0->$$57]
+                                    -- ASSIGN  |UNPARTITIONED|
+                                      exchange 
+                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                        replicate 
+                                        -- SPLIT  |PARTITIONED|
+                                          exchange 
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            data-scan []<-[$$54, $$55, $$56, $$57] <- default.nation
+                                            -- DATASOURCE_SCAN  |PARTITIONED|
+                                              exchange 
+                                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                empty-tuple-source
+                                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/q9_product_type_profit.plan b/src/test/resources/optimizerts/results/q9_product_type_profit.plan
new file mode 100644
index 0000000..f57f4a3
--- /dev/null
+++ b/src/test/resources/optimizerts/results/q9_product_type_profit.plan
@@ -0,0 +1,124 @@
+write [%0->$$53, %0->$$54, %0->$$55]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$53, $$54, $$55])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- SORT_MERGE_EXCHANGE [$$53(ASC), $$54(DESC) ]  |PARTITIONED|
+      order (ASC, %0->$$53) (DESC, %0->$$54) 
+      -- STABLE_SORT [$$53(ASC), $$54(DESC)]  |LOCAL|
+        exchange 
+        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          group by ([$$53 := %0->$$58; $$54 := %0->$$59]) decor ([]) {
+                    aggregate [$$55] <- [function-call: hive:sum(FINAL), Args:[%0->$$57]]
+                    -- AGGREGATE  |LOCAL|
+                      nested tuple source
+                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                 }
+          -- EXTERNAL_GROUP_BY[$$58, $$59]  |PARTITIONED|
+            exchange 
+            -- HASH_PARTITION_EXCHANGE [$$58, $$59]  |PARTITIONED|
+              group by ([$$58 := %0->$$48; $$59 := %0->$$51]) decor ([]) {
+                        aggregate [$$57] <- [function-call: hive:sum(PARTIAL1), Args:[%0->$$52]]
+                        -- AGGREGATE  |LOCAL|
+                          nested tuple source
+                          -- NESTED_TUPLE_SOURCE  |LOCAL|
+                     }
+              -- EXTERNAL_GROUP_BY[$$48, $$51]  |LOCAL|
+                exchange 
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  project ([$$48, $$51, $$52])
+                  -- STREAM_PROJECT  |PARTITIONED|
+                    assign [$$51, $$52] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFYear, Args:[%0->$$5], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$29, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$30]], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$22, %0->$$28]]]
+                    -- ASSIGN  |PARTITIONED|
+                      project ([$$5, $$29, $$30, $$28, $$48, $$22])
+                      -- STREAM_PROJECT  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          join (function-call: algebricks:eq, Args:[%0->$$24, %0->$$1])
+                          -- HYBRID_HASH_JOIN [$$24][$$1]  |PARTITIONED|
+                            exchange 
+                            -- HASH_PARTITION_EXCHANGE [$$24]  |PARTITIONED|
+                              project ([$$29, $$30, $$28, $$24, $$48, $$22])
+                              -- STREAM_PROJECT  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  join (function-call: algebricks:eq, Args:[%0->$$25, %0->$$10])
+                                  -- HYBRID_HASH_JOIN [$$25][$$10]  |PARTITIONED|
+                                    exchange 
+                                    -- HASH_PARTITION_EXCHANGE [$$25]  |PARTITIONED|
+                                      project ([$$22, $$29, $$30, $$28, $$25, $$24, $$48])
+                                      -- STREAM_PROJECT  |PARTITIONED|
+                                        exchange 
+                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                          join (function-call: algebricks:and, Args:[function-call: algebricks:eq, Args:[%0->$$26, %0->$$20], function-call: algebricks:eq, Args:[%0->$$25, %0->$$19]])
+                                          -- HYBRID_HASH_JOIN [$$26, $$25][$$20, $$19]  |PARTITIONED|
+                                            exchange 
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              project ([$$48, $$24, $$25, $$26, $$28, $$29, $$30])
+                                              -- STREAM_PROJECT  |PARTITIONED|
+                                                exchange 
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  join (function-call: algebricks:eq, Args:[%0->$$26, %0->$$40])
+                                                  -- HYBRID_HASH_JOIN [$$26][$$40]  |PARTITIONED|
+                                                    exchange 
+                                                    -- HASH_PARTITION_EXCHANGE [$$26]  |PARTITIONED|
+                                                      data-scan [$$26, $$24, $$25, $$28, $$29, $$30]<-[$$24, $$25, $$26, $$27, $$28, $$29, $$30, $$31, $$32, $$33, $$34, $$35, $$36, $$37, $$38, $$39] <- default.lineitem
+                                                      -- DATASOURCE_SCAN  |PARTITIONED|
+                                                        exchange 
+                                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                          empty-tuple-source
+                                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                    exchange 
+                                                    -- HASH_PARTITION_EXCHANGE [$$40]  |PARTITIONED|
+                                                      project ([$$40, $$48])
+                                                      -- STREAM_PROJECT  |PARTITIONED|
+                                                        exchange 
+                                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                          join (function-call: algebricks:eq, Args:[%0->$$43, %0->$$47])
+                                                          -- HYBRID_HASH_JOIN [$$43][$$47]  |PARTITIONED|
+                                                            exchange 
+                                                            -- HASH_PARTITION_EXCHANGE [$$43]  |PARTITIONED|
+                                                              data-scan [$$43, $$40]<-[$$40, $$41, $$42, $$43, $$44, $$45, $$46] <- default.supplier
+                                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                exchange 
+                                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                  empty-tuple-source
+                                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                                            exchange 
+                                                            -- HASH_PARTITION_EXCHANGE [$$47]  |PARTITIONED|
+                                                              data-scan [$$47, $$48]<-[$$47, $$48, $$49, $$50] <- default.nation
+                                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                                exchange 
+                                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                                  empty-tuple-source
+                                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                            exchange 
+                                            -- HASH_PARTITION_EXCHANGE [$$20]  |PARTITIONED|
+                                              data-scan [$$20, $$19, $$22]<-[$$19, $$20, $$21, $$22, $$23] <- default.partsupp
+                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                exchange 
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  empty-tuple-source
+                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                    exchange 
+                                    -- HASH_PARTITION_EXCHANGE [$$10]  |PARTITIONED|
+                                      project ([$$10])
+                                      -- STREAM_PROJECT  |PARTITIONED|
+                                        select (function-call: hive:org.apache.hadoop.hive.ql.udf.UDFLike, Args:[%0->$$11, %green%])
+                                        -- STREAM_SELECT  |PARTITIONED|
+                                          exchange 
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            data-scan [$$10, $$11]<-[$$10, $$11, $$12, $$13, $$14, $$15, $$16, $$17, $$18] <- default.part
+                                            -- DATASOURCE_SCAN  |PARTITIONED|
+                                              exchange 
+                                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                empty-tuple-source
+                                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                            exchange 
+                            -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+                              data-scan [$$1, $$5]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.orders
+                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                exchange 
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  empty-tuple-source
+                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/u10_nestedloop_join.plan b/src/test/resources/optimizerts/results/u10_nestedloop_join.plan
new file mode 100644
index 0000000..c86d57f
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u10_nestedloop_join.plan
@@ -0,0 +1,24 @@
+write [%0->$$6, %0->$$2, %0->$$5, %0->$$1]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$6, $$2, $$5, $$1])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      join (function-call: algebricks:and, Args:[function-call: algebricks:gt, Args:[%0->$$5, %0->$$1], true])
+      -- NESTED_LOOP  |PARTITIONED|
+        exchange 
+        -- BROADCAST_EXCHANGE  |PARTITIONED|
+          data-scan [$$1, $$2]<-[$$1, $$2, $$3, $$4] <- default.nation
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+        exchange 
+        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          data-scan [$$5, $$6]<-[$$5, $$6, $$7, $$8] <- default.nation
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/u1_group_by.plan b/src/test/resources/optimizerts/results/u1_group_by.plan
new file mode 100644
index 0000000..188aa6d
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u1_group_by.plan
@@ -0,0 +1,36 @@
+write [%0->$$18, %0->$$19]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$18, $$19])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      group by ([$$17 := %0->$$23]) decor ([]) {
+                aggregate [$$18, $$19] <- [function-call: hive:sum(FINAL), Args:[%0->$$21], function-call: hive:sum(FINAL), Args:[%0->$$22]]
+                -- AGGREGATE  |LOCAL|
+                  nested tuple source
+                  -- NESTED_TUPLE_SOURCE  |LOCAL|
+             }
+      -- EXTERNAL_GROUP_BY[$$23]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$23]  |PARTITIONED|
+          group by ([$$23 := %0->$$9]) decor ([]) {
+                    aggregate [$$21, $$22] <- [function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFAbs, Args:[%0->$$5]], function-call: hive:sum(PARTIAL1), Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$6, function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMinus, Args:[1, %0->$$7]], function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPPlus, Args:[1, %0->$$8]]]]
+                    -- AGGREGATE  |LOCAL|
+                      nested tuple source
+                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                 }
+          -- EXTERNAL_GROUP_BY[$$9]  |LOCAL|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              project ([$$9, $$5, $$6, $$7, $$8])
+              -- STREAM_PROJECT  |PARTITIONED|
+                select (function-call: algebricks:le, Args:[%0->$$11, 1998-09-02])
+                -- STREAM_SELECT  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    data-scan [$$5, $$6, $$7, $$8, $$9, $$11]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+                    -- DATASOURCE_SCAN  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        empty-tuple-source
+                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/u2_select-project.plan b/src/test/resources/optimizerts/results/u2_select-project.plan
new file mode 100644
index 0000000..4485b36
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u2_select-project.plan
@@ -0,0 +1,16 @@
+write [%0->$$8, %0->$$3, %0->$$4, %0->$$2]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$8, $$3, $$4, $$2])
+  -- STREAM_PROJECT  |PARTITIONED|
+    assign [$$8] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[2, %0->$$1]]
+    -- ASSIGN  |PARTITIONED|
+      select (function-call: algebricks:lt, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$1, 2], 20])
+      -- STREAM_SELECT  |PARTITIONED|
+        exchange 
+        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          data-scan []<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7] <- default.supplier
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/u3_union.plan b/src/test/resources/optimizerts/results/u3_union.plan
new file mode 100644
index 0000000..c4040f2
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u3_union.plan
@@ -0,0 +1,38 @@
+write [%0->$$17, %0->$$18, %0->$$19, %0->$$20]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    union ($$8, $$16, $$17) ($$3, $$11, $$18) ($$4, $$12, $$19) ($$2, $$10, $$20)
+    -- UNION_ALL  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        project ([$$8, $$3, $$4, $$2])
+        -- STREAM_PROJECT  |PARTITIONED|
+          assign [$$8] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[2, %0->$$1]]
+          -- ASSIGN  |PARTITIONED|
+            select (function-call: algebricks:gt, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$1, 2], 50])
+            -- STREAM_SELECT  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                data-scan []<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7] <- default.supplier
+                -- DATASOURCE_SCAN  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    empty-tuple-source
+                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        project ([$$16, $$11, $$12, $$10])
+        -- STREAM_PROJECT  |PARTITIONED|
+          assign [$$16] <- [function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[2, %0->$$9]]
+          -- ASSIGN  |PARTITIONED|
+            select (function-call: algebricks:lt, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$9, 2], 20])
+            -- STREAM_SELECT  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                data-scan []<-[$$9, $$10, $$11, $$12, $$13, $$14, $$15] <- default.supplier
+                -- DATASOURCE_SCAN  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    empty-tuple-source
+                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/u4_join.plan b/src/test/resources/optimizerts/results/u4_join.plan
new file mode 100644
index 0000000..449a601
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u4_join.plan
@@ -0,0 +1,36 @@
+write [%0->$$1, %0->$$2, %0->$$3, %0->$$4]
+-- SINK_WRITE  |PARTITIONED|
+  select (function-call: algebricks:lt, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$1, 2], 20])
+  -- STREAM_SELECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      data-scan [$$1, $$2, $$3, $$4]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7] <- default.supplier
+      -- DATASOURCE_SCAN  |PARTITIONED|
+        exchange 
+        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          empty-tuple-source
+          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+write [%0->$$1, %0->$$9, %0->$$10, %0->$$11]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$1, $$9, $$10, $$11])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      join (function-call: algebricks:eq, Args:[%0->$$5, %0->$$1])
+      -- HYBRID_HASH_JOIN [$$5][$$1]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$5]  |PARTITIONED|
+          data-scan [$$5, $$9, $$10, $$11]<-[$$5, $$6, $$7, $$8, $$9, $$10, $$11] <- default.supplier
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+          data-scan [$$1]<-[$$1, $$2, $$3, $$4] <- default.result
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/u5_lateral_view.plan b/src/test/resources/optimizerts/results/u5_lateral_view.plan
new file mode 100644
index 0000000..48e624e
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u5_lateral_view.plan
@@ -0,0 +1,14 @@
+write [%0->$$2, %0->$$3, %0->$$8]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$2, $$3, $$8])
+  -- STREAM_PROJECT  |PARTITIONED|
+    unnest $$8 <- function-call: hive:explode, Args:[%0->$$1]
+    -- UNNEST  |PARTITIONED|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        data-scan [$$1, $$2, $$3]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7] <- default.supplier
+        -- DATASOURCE_SCAN  |PARTITIONED|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            empty-tuple-source
+            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/u6_limit.plan b/src/test/resources/optimizerts/results/u6_limit.plan
new file mode 100644
index 0000000..b5ed12f
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u6_limit.plan
@@ -0,0 +1,26 @@
+write [%0->$$1, %0->$$4, %0->$$5, %0->$$7]
+-- SINK_WRITE  |UNPARTITIONED|
+  limit 4
+  -- STREAM_LIMIT  |UNPARTITIONED|
+    limit 4
+    -- STREAM_LIMIT  |UNPARTITIONED|
+      exchange 
+      -- SORT_MERGE_EXCHANGE [$$4(ASC) ]  |PARTITIONED|
+        limit 4
+        -- STREAM_LIMIT  |LOCAL|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |LOCAL|
+            order (ASC, %0->$$4) 
+            -- STABLE_SORT [$$4(ASC)]  |LOCAL|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                select (function-call: algebricks:lt, Args:[%0->$$4, 10000])
+                -- STREAM_SELECT  |PARTITIONED|
+                  exchange 
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    data-scan [$$1, $$4, $$5, $$7]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9] <- default.orders
+                    -- DATASOURCE_SCAN  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        empty-tuple-source
+                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/u7_multi_join.plan b/src/test/resources/optimizerts/results/u7_multi_join.plan
new file mode 100644
index 0000000..ab55181
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u7_multi_join.plan
@@ -0,0 +1,52 @@
+write [%0->$$4, %0->$$25, %0->$$28, %0->$$29, %0->$$32]
+-- SINK_WRITE  |PARTITIONED|
+  project ([$$4, $$25, $$28, $$29, $$32])
+  -- STREAM_PROJECT  |PARTITIONED|
+    exchange 
+    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+      join (function-call: algebricks:eq, Args:[%0->$$1, %0->$$25])
+      -- HYBRID_HASH_JOIN [$$1][$$25]  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$1]  |PARTITIONED|
+          data-scan [$$1, $$4]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16] <- default.lineitem
+          -- DATASOURCE_SCAN  |PARTITIONED|
+            exchange 
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              empty-tuple-source
+              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+        exchange 
+        -- HASH_PARTITION_EXCHANGE [$$25]  |PARTITIONED|
+          project ([$$32, $$25, $$29, $$28])
+          -- STREAM_PROJECT  |PARTITIONED|
+            project ([$$25, $$17, $$28, $$29, $$32])
+            -- STREAM_PROJECT  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                join (function-call: algebricks:eq, Args:[%0->$$26, %0->$$17])
+                -- HYBRID_HASH_JOIN [$$26][$$17]  |PARTITIONED|
+                  exchange 
+                  -- HASH_PARTITION_EXCHANGE [$$26]  |PARTITIONED|
+                    select (function-call: algebricks:and, Args:[function-call: algebricks:lt, Args:[%0->$$28, 30000], function-call: algebricks:lt, Args:[%0->$$28, 30000]])
+                    -- STREAM_SELECT  |PARTITIONED|
+                      exchange 
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        data-scan [$$32, $$25, $$26, $$29, $$28]<-[$$25, $$26, $$27, $$28, $$29, $$30, $$31, $$32, $$33] <- default.orders
+                        -- DATASOURCE_SCAN  |PARTITIONED|
+                          exchange 
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            empty-tuple-source
+                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                  exchange 
+                  -- HASH_PARTITION_EXCHANGE [$$17]  |PARTITIONED|
+                    project ([$$17])
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      select (function-call: algebricks:and, Args:[function-call: algebricks:lt, Args:[%0->$$17, 5], function-call: algebricks:lt, Args:[%0->$$17, 5]])
+                      -- STREAM_SELECT  |PARTITIONED|
+                        exchange 
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          data-scan [$$17]<-[$$17, $$18, $$19, $$20, $$21, $$22, $$23, $$24] <- default.customer
+                          -- DATASOURCE_SCAN  |PARTITIONED|
+                            exchange 
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              empty-tuple-source
+                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/src/test/resources/optimizerts/results/u8_non_mapred.plan b/src/test/resources/optimizerts/results/u8_non_mapred.plan
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u8_non_mapred.plan
diff --git a/src/test/resources/optimizerts/results/u9_order_by.plan b/src/test/resources/optimizerts/results/u9_order_by.plan
new file mode 100644
index 0000000..7370fcf
--- /dev/null
+++ b/src/test/resources/optimizerts/results/u9_order_by.plan
@@ -0,0 +1,18 @@
+write [%0->$$1, %0->$$2, %0->$$3, %0->$$4]
+-- SINK_WRITE  |PARTITIONED|
+  exchange 
+  -- SORT_MERGE_EXCHANGE [$$2(ASC) ]  |PARTITIONED|
+    order (ASC, %0->$$2) 
+    -- STABLE_SORT [$$2(ASC)]  |LOCAL|
+      exchange 
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        select (function-call: algebricks:lt, Args:[function-call: hive:org.apache.hadoop.hive.ql.udf.UDFOPMultiply, Args:[%0->$$1, 2], 20])
+        -- STREAM_SELECT  |PARTITIONED|
+          exchange 
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            data-scan [$$1, $$2, $$3, $$4]<-[$$1, $$2, $$3, $$4, $$5, $$6, $$7] <- default.supplier
+            -- DATASOURCE_SCAN  |PARTITIONED|
+              exchange 
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                empty-tuple-source
+                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|