You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2017/03/30 22:15:27 UTC

[1/3] hive git commit: HIVE-16228 : Support subqueries in complex expression in SELECT clause (Vineet Garg via Ashutosh Chauhan)

Repository: hive
Updated Branches:
  refs/heads/master db983d6c6 -> ac6735a38


http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/results/clientpositive/perf/query9.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query9.q.out b/ql/src/test/results/clientpositive/perf/query9.q.out
new file mode 100644
index 0000000..d714d41
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/query9.q.out
@@ -0,0 +1,829 @@
+Warning: Shuffle Join MERGEJOIN[456][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
+Warning: Shuffle Join MERGEJOIN[457][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 3' is a cross product
+Warning: Shuffle Join MERGEJOIN[458][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[459][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[460][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[461][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6]] in Stage 'Reducer 7' is a cross product
+Warning: Shuffle Join MERGEJOIN[462][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[463][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8]] in Stage 'Reducer 9' is a cross product
+Warning: Shuffle Join MERGEJOIN[464][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9]] in Stage 'Reducer 10' is a cross product
+Warning: Shuffle Join MERGEJOIN[465][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10]] in Stage 'Reducer 11' is a cross product
+Warning: Shuffle Join MERGEJOIN[466][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11]] in Stage 'Reducer 12' is a cross product
+Warning: Shuffle Join MERGEJOIN[467][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12]] in Stage 'Reducer 13' is a cross product
+Warning: Shuffle Join MERGEJOIN[468][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13]] in Stage 'Reducer 14' is a cross product
+Warning: Shuffle Join MERGEJOIN[469][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14]] in Stage 'Reducer 15' is a cross product
+Warning: Shuffle Join MERGEJOIN[470][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15]] in Stage 'Reducer 16' is a cross product
+Warning: Shuffle Join MERGEJOIN[471][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16]] in Stage 'Reducer 17' is a cross product
+Warning: Shuffle Join MERGEJOIN[472][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17]] in Stage 'Reducer 18' is a cross product
+Warning: Shuffle Join MERGEJOIN[473][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18]] in Stage 'Reducer 19' is a cross product
+Warning: Shuffle Join MERGEJOIN[474][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19]] in Stage 'Reducer 20' is a cross product
+Warning: Shuffle Join MERGEJOIN[475][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20]] in Stage 'Reducer 21' is a cross product
+Warning: Shuffle Join MERGEJOIN[476][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21]] in Stage 'Reducer 22' is a cross product
+Warning: Shuffle Join MERGEJOIN[477][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21, $hdt$_22]] in Stage 'Reducer 23' is a cross product
+Warning: Shuffle Join MERGEJOIN[478][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21, $hdt$_22, $hdt$_23]] in Stage 'Reducer 24' is a cross product
+Warning: Shuffle Join MERGEJOIN[479][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21, $hdt$_22, $hdt$_23, $hdt$_24]] in Stage 'Reducer 25' is a cross product
+Warning: Shuffle Join MERGEJOIN[480][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21, $hdt$_22, $hdt$_23, $hdt$_24, $hdt$_25]] in Stage 'Reducer 26' is a cross product
+Warning: Shuffle Join MERGEJOIN[481][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21, $hdt$_22, $hdt$_23, $hdt$_24, $hdt$_25, $hdt$_26]] in Stage 'Reducer 27' is a cross product
+Warning: Shuffle Join MERGEJOIN[482][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21, $hdt$_22, $hdt$_23, $hdt$_24, $hdt$_25, $hdt$_26, $hdt$_27]] in Stage 'Reducer 28' is a cross product
+Warning: Shuffle Join MERGEJOIN[483][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21, $hdt$_22, $hdt$_23, $hdt$_24, $hdt$_25, $hdt$_26, $hdt$_27, $hdt$_28]] in Stage 'Reducer 29' is a cross product
+Warning: Shuffle Join MERGEJOIN[484][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21, $hdt$_22, $hdt$_23, $hdt$_24, $hdt$_25, $hdt$_26, $hdt$_27, $hdt$_28, $hdt$_29]] in Stage 'Reducer 30' is a cross product
+Warning: Shuffle Join MERGEJOIN[485][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15, $hdt$_16, $hdt$_17, $hdt$_18, $hdt$_19, $hdt$_20, $hdt$_21, $hdt$_22, $hdt$_23, $hdt$_24, $hdt$_25, $hdt$_26, $hdt$_27, $hdt$_28, $hdt$_29, $hdt$_30]] in Stage 'Reducer 31' is a cross product
+PREHOOK: query: explain select case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 1 and 20) > 409437
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 1 and 20)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 1 and 20) end bucket1 ,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 21 and 40) > 4595804
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 21 and 40)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 21 and 40) end bucket2,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 41 and 60) > 7887297
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 41 and 60)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 41 and 60) end bucket3,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 61 and 80) > 10872978
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 61 and 80)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 61 and 80) end bucket4,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 81 and 100) > 43571537
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 81 and 100)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 81 and 100) end bucket5
+from reason
+where r_reason_sk = 1
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 1 and 20) > 409437
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 1 and 20)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 1 and 20) end bucket1 ,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 21 and 40) > 4595804
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 21 and 40)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 21 and 40) end bucket2,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 41 and 60) > 7887297
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 41 and 60)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 41 and 60) end bucket3,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 61 and 80) > 10872978
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 61 and 80)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 61 and 80) end bucket4,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 81 and 100) > 43571537
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 81 and 100)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 81 and 100) end bucket5
+from reason
+where r_reason_sk = 1
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 49 (CUSTOM_SIMPLE_EDGE), Reducer 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (CUSTOM_SIMPLE_EDGE), Reducer 51 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (CUSTOM_SIMPLE_EDGE), Reducer 53 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (CUSTOM_SIMPLE_EDGE), Reducer 55 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (CUSTOM_SIMPLE_EDGE), Reducer 57 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Reducer 14 (CUSTOM_SIMPLE_EDGE), Reducer 59 (CUSTOM_SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (CUSTOM_SIMPLE_EDGE), Reducer 61 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Reducer 16 (CUSTOM_SIMPLE_EDGE), Reducer 63 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (CUSTOM_SIMPLE_EDGE), Reducer 65 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Reducer 18 (CUSTOM_SIMPLE_EDGE), Reducer 67 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE), Reducer 33 (CUSTOM_SIMPLE_EDGE)
+Reducer 20 <- Reducer 19 (CUSTOM_SIMPLE_EDGE), Reducer 69 (CUSTOM_SIMPLE_EDGE)
+Reducer 21 <- Reducer 20 (CUSTOM_SIMPLE_EDGE), Reducer 71 (CUSTOM_SIMPLE_EDGE)
+Reducer 22 <- Reducer 21 (CUSTOM_SIMPLE_EDGE), Reducer 73 (CUSTOM_SIMPLE_EDGE)
+Reducer 23 <- Reducer 22 (CUSTOM_SIMPLE_EDGE), Reducer 75 (CUSTOM_SIMPLE_EDGE)
+Reducer 24 <- Reducer 23 (CUSTOM_SIMPLE_EDGE), Reducer 77 (CUSTOM_SIMPLE_EDGE)
+Reducer 25 <- Reducer 24 (CUSTOM_SIMPLE_EDGE), Reducer 79 (CUSTOM_SIMPLE_EDGE)
+Reducer 26 <- Reducer 25 (CUSTOM_SIMPLE_EDGE), Reducer 81 (CUSTOM_SIMPLE_EDGE)
+Reducer 27 <- Reducer 26 (CUSTOM_SIMPLE_EDGE), Reducer 83 (CUSTOM_SIMPLE_EDGE)
+Reducer 28 <- Reducer 27 (CUSTOM_SIMPLE_EDGE), Reducer 85 (CUSTOM_SIMPLE_EDGE)
+Reducer 29 <- Reducer 28 (CUSTOM_SIMPLE_EDGE), Reducer 87 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (CUSTOM_SIMPLE_EDGE), Reducer 35 (CUSTOM_SIMPLE_EDGE)
+Reducer 30 <- Reducer 29 (CUSTOM_SIMPLE_EDGE), Reducer 89 (CUSTOM_SIMPLE_EDGE)
+Reducer 31 <- Reducer 30 (CUSTOM_SIMPLE_EDGE), Reducer 91 (CUSTOM_SIMPLE_EDGE)
+Reducer 33 <- Map 32 (CUSTOM_SIMPLE_EDGE)
+Reducer 35 <- Map 34 (CUSTOM_SIMPLE_EDGE)
+Reducer 37 <- Map 36 (CUSTOM_SIMPLE_EDGE)
+Reducer 39 <- Map 38 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (CUSTOM_SIMPLE_EDGE), Reducer 37 (CUSTOM_SIMPLE_EDGE)
+Reducer 41 <- Map 40 (CUSTOM_SIMPLE_EDGE)
+Reducer 43 <- Map 42 (CUSTOM_SIMPLE_EDGE)
+Reducer 45 <- Map 44 (CUSTOM_SIMPLE_EDGE)
+Reducer 47 <- Map 46 (CUSTOM_SIMPLE_EDGE)
+Reducer 49 <- Map 48 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Reducer 39 (CUSTOM_SIMPLE_EDGE), Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 51 <- Map 50 (CUSTOM_SIMPLE_EDGE)
+Reducer 53 <- Map 52 (CUSTOM_SIMPLE_EDGE)
+Reducer 55 <- Map 54 (CUSTOM_SIMPLE_EDGE)
+Reducer 57 <- Map 56 (CUSTOM_SIMPLE_EDGE)
+Reducer 59 <- Map 58 (CUSTOM_SIMPLE_EDGE)
+Reducer 6 <- Reducer 41 (CUSTOM_SIMPLE_EDGE), Reducer 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 61 <- Map 60 (CUSTOM_SIMPLE_EDGE)
+Reducer 63 <- Map 62 (CUSTOM_SIMPLE_EDGE)
+Reducer 65 <- Map 64 (CUSTOM_SIMPLE_EDGE)
+Reducer 67 <- Map 66 (CUSTOM_SIMPLE_EDGE)
+Reducer 69 <- Map 68 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Reducer 43 (CUSTOM_SIMPLE_EDGE), Reducer 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 71 <- Map 70 (CUSTOM_SIMPLE_EDGE)
+Reducer 73 <- Map 72 (CUSTOM_SIMPLE_EDGE)
+Reducer 75 <- Map 74 (CUSTOM_SIMPLE_EDGE)
+Reducer 77 <- Map 76 (CUSTOM_SIMPLE_EDGE)
+Reducer 79 <- Map 78 (CUSTOM_SIMPLE_EDGE)
+Reducer 8 <- Reducer 45 (CUSTOM_SIMPLE_EDGE), Reducer 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 81 <- Map 80 (CUSTOM_SIMPLE_EDGE)
+Reducer 83 <- Map 82 (CUSTOM_SIMPLE_EDGE)
+Reducer 85 <- Map 84 (CUSTOM_SIMPLE_EDGE)
+Reducer 87 <- Map 86 (CUSTOM_SIMPLE_EDGE)
+Reducer 89 <- Map 88 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Reducer 47 (CUSTOM_SIMPLE_EDGE), Reducer 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 91 <- Map 90 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 31
+      File Output Operator [FS_424]
+        Select Operator [SEL_423] (rows=36 width=3270)
+          Output:["_col0","_col1","_col2","_col3","_col4"]
+          Merge Join Operator [MERGEJOIN_485] (rows=36 width=3270)
+            Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20","_col22","_col24","_col26","_col28","_col30"]
+          <-Reducer 30 [CUSTOM_SIMPLE_EDGE]
+            PARTITION_ONLY_SHUFFLE [RS_420]
+              Merge Join Operator [MERGEJOIN_484] (rows=36 width=2981)
+                Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20","_col22","_col24","_col26","_col28"]
+              <-Reducer 29 [CUSTOM_SIMPLE_EDGE]
+                PARTITION_ONLY_SHUFFLE [RS_417]
+                  Merge Join Operator [MERGEJOIN_483] (rows=36 width=2972)
+                    Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20","_col22","_col24","_col26","_col28"]
+                  <-Reducer 28 [CUSTOM_SIMPLE_EDGE]
+                    PARTITION_ONLY_SHUFFLE [RS_414]
+                      Merge Join Operator [MERGEJOIN_482] (rows=36 width=2683)
+                        Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20","_col22","_col24","_col26"]
+                      <-Reducer 27 [CUSTOM_SIMPLE_EDGE]
+                        PARTITION_ONLY_SHUFFLE [RS_411]
+                          Merge Join Operator [MERGEJOIN_481] (rows=36 width=2674)
+                            Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20","_col22","_col24","_col26"]
+                          <-Reducer 26 [CUSTOM_SIMPLE_EDGE]
+                            PARTITION_ONLY_SHUFFLE [RS_408]
+                              Merge Join Operator [MERGEJOIN_480] (rows=36 width=2665)
+                                Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20","_col22","_col24"]
+                              <-Reducer 25 [CUSTOM_SIMPLE_EDGE]
+                                PARTITION_ONLY_SHUFFLE [RS_405]
+                                  Merge Join Operator [MERGEJOIN_479] (rows=36 width=2656)
+                                    Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20","_col22","_col24"]
+                                  <-Reducer 24 [CUSTOM_SIMPLE_EDGE]
+                                    PARTITION_ONLY_SHUFFLE [RS_402]
+                                      Merge Join Operator [MERGEJOIN_478] (rows=36 width=2367)
+                                        Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20","_col22"]
+                                      <-Reducer 23 [CUSTOM_SIMPLE_EDGE]
+                                        PARTITION_ONLY_SHUFFLE [RS_399]
+                                          Merge Join Operator [MERGEJOIN_477] (rows=36 width=2358)
+                                            Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20","_col22"]
+                                          <-Reducer 22 [CUSTOM_SIMPLE_EDGE]
+                                            PARTITION_ONLY_SHUFFLE [RS_396]
+                                              Merge Join Operator [MERGEJOIN_476] (rows=36 width=2069)
+                                                Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20"]
+                                              <-Reducer 21 [CUSTOM_SIMPLE_EDGE]
+                                                PARTITION_ONLY_SHUFFLE [RS_393]
+                                                  Merge Join Operator [MERGEJOIN_475] (rows=36 width=2060)
+                                                    Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18","_col20"]
+                                                  <-Reducer 20 [CUSTOM_SIMPLE_EDGE]
+                                                    PARTITION_ONLY_SHUFFLE [RS_390]
+                                                      Merge Join Operator [MERGEJOIN_474] (rows=36 width=2051)
+                                                        Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18"]
+                                                      <-Reducer 19 [CUSTOM_SIMPLE_EDGE]
+                                                        PARTITION_ONLY_SHUFFLE [RS_387]
+                                                          Merge Join Operator [MERGEJOIN_473] (rows=36 width=2042)
+                                                            Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16","_col18"]
+                                                          <-Reducer 18 [CUSTOM_SIMPLE_EDGE]
+                                                            PARTITION_ONLY_SHUFFLE [RS_384]
+                                                              Merge Join Operator [MERGEJOIN_472] (rows=36 width=1753)
+                                                                Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16"]
+                                                              <-Reducer 17 [CUSTOM_SIMPLE_EDGE]
+                                                                PARTITION_ONLY_SHUFFLE [RS_381]
+                                                                  Merge Join Operator [MERGEJOIN_471] (rows=36 width=1744)
+                                                                    Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14","_col16"]
+                                                                  <-Reducer 16 [CUSTOM_SIMPLE_EDGE]
+                                                                    PARTITION_ONLY_SHUFFLE [RS_378]
+                                                                      Merge Join Operator [MERGEJOIN_470] (rows=36 width=1455)
+                                                                        Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14"]
+                                                                      <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                                        PARTITION_ONLY_SHUFFLE [RS_375]
+                                                                          Merge Join Operator [MERGEJOIN_469] (rows=36 width=1446)
+                                                                            Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12","_col14"]
+                                                                          <-Reducer 14 [CUSTOM_SIMPLE_EDGE]
+                                                                            PARTITION_ONLY_SHUFFLE [RS_372]
+                                                                              Merge Join Operator [MERGEJOIN_468] (rows=36 width=1437)
+                                                                                Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10","_col12"]
+                                                                              <-Reducer 13 [CUSTOM_SIMPLE_EDGE]
+                                                                                PARTITION_ONLY_SHUFFLE [RS_369]
+                                                                                  Merge Join Operator [MERGEJOIN_467] (rows=36 width=1428)
+                                                                                    Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10","_col12"]
+                                                                                  <-Reducer 12 [CUSTOM_SIMPLE_EDGE]
+                                                                                    PARTITION_ONLY_SHUFFLE [RS_366]
+                                                                                      Merge Join Operator [MERGEJOIN_466] (rows=36 width=1139)
+                                                                                        Conds:(Inner),Output:["_col2","_col4","_col6","_col8","_col10"]
+                                                                                      <-Reducer 11 [CUSTOM_SIMPLE_EDGE]
+                                                                                        PARTITION_ONLY_SHUFFLE [RS_363]
+                                                                                          Merge Join Operator [MERGEJOIN_465] (rows=36 width=1130)
+                                                                                            Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8","_col10"]
+                                                                                          <-Reducer 10 [CUSTOM_SIMPLE_EDGE]
+                                                                                            PARTITION_ONLY_SHUFFLE [RS_360]
+                                                                                              Merge Join Operator [MERGEJOIN_464] (rows=36 width=841)
+                                                                                                Conds:(Inner),Output:["_col2","_col4","_col6","_col8"]
+                                                                                              <-Reducer 49 [CUSTOM_SIMPLE_EDGE]
+                                                                                                PARTITION_ONLY_SHUFFLE [RS_358]
+                                                                                                  Select Operator [SEL_105] (rows=1 width=8)
+                                                                                                    Filter Operator [FIL_104] (rows=1 width=8)
+                                                                                                      predicate:(sq_count_check(_col0) <= 1)
+                                                                                                      Group By Operator [GBY_102] (rows=1 width=8)
+                                                                                                        Output:["_col0"],aggregations:["count()"]
+                                                                                                        Select Operator [SEL_97] (rows=1 width=8)
+                                                                                                          Group By Operator [GBY_96] (rows=1 width=8)
+                                                                                                            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                                          <-Map 48 [CUSTOM_SIMPLE_EDGE]
+                                                                                                            PARTITION_ONLY_SHUFFLE [RS_95]
+                                                                                                              Group By Operator [GBY_94] (rows=1 width=8)
+                                                                                                                Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                                                                Select Operator [SEL_93] (rows=63999515 width=88)
+                                                                                                                  Output:["ss_sold_date_sk"]
+                                                                                                                  Filter Operator [FIL_434] (rows=63999515 width=88)
+                                                                                                                    predicate:ss_quantity BETWEEN 21 AND 40
+                                                                                                                    TableScan [TS_91] (rows=575995635 width=88)
+                                                                                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                                                              <-Reducer 9 [CUSTOM_SIMPLE_EDGE]
+                                                                                                PARTITION_ONLY_SHUFFLE [RS_357]
+                                                                                                  Merge Join Operator [MERGEJOIN_463] (rows=36 width=832)
+                                                                                                    Conds:(Left Outer),Output:["_col2","_col4","_col6","_col8"]
+                                                                                                  <-Reducer 47 [CUSTOM_SIMPLE_EDGE]
+                                                                                                    PARTITION_ONLY_SHUFFLE [RS_355]
+                                                                                                      Group By Operator [GBY_89] (rows=1 width=8)
+                                                                                                        Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                                      <-Map 46 [CUSTOM_SIMPLE_EDGE]
+                                                                                                        PARTITION_ONLY_SHUFFLE [RS_88]
+                                                                                                          Group By Operator [GBY_87] (rows=1 width=8)
+                                                                                                            Output:["_col0"],aggregations:["count()"]
+                                                                                                            Select Operator [SEL_86] (rows=63999515 width=88)
+                                                                                                              Filter Operator [FIL_433] (rows=63999515 width=88)
+                                                                                                                predicate:ss_quantity BETWEEN 21 AND 40
+                                                                                                                TableScan [TS_84] (rows=575995635 width=88)
+                                                                                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity"]
+                                                                                                  <-Reducer 8 [CUSTOM_SIMPLE_EDGE]
+                                                                                                    PARTITION_ONLY_SHUFFLE [RS_354]
+                                                                                                      Merge Join Operator [MERGEJOIN_462] (rows=36 width=823)
+                                                                                                        Conds:(Inner),Output:["_col2","_col4","_col6"]
+                                                                                                      <-Reducer 45 [CUSTOM_SIMPLE_EDGE]
+                                                                                                        PARTITION_ONLY_SHUFFLE [RS_352]
+                                                                                                          Select Operator [SEL_83] (rows=1 width=8)
+                                                                                                            Filter Operator [FIL_82] (rows=1 width=8)
+                                                                                                              predicate:(sq_count_check(_col0) <= 1)
+                                                                                                              Group By Operator [GBY_80] (rows=1 width=8)
+                                                                                                                Output:["_col0"],aggregations:["count()"]
+                                                                                                                Select Operator [SEL_75] (rows=1 width=8)
+                                                                                                                  Group By Operator [GBY_74] (rows=1 width=8)
+                                                                                                                    Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                                                  <-Map 44 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                    PARTITION_ONLY_SHUFFLE [RS_73]
+                                                                                                                      Group By Operator [GBY_72] (rows=1 width=8)
+                                                                                                                        Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                                                                        Select Operator [SEL_71] (rows=63999515 width=88)
+                                                                                                                          Output:["ss_sold_date_sk"]
+                                                                                                                          Filter Operator [FIL_432] (rows=63999515 width=88)
+                                                                                                                            predicate:ss_quantity BETWEEN 21 AND 40
+                                                                                                                            TableScan [TS_69] (rows=575995635 width=88)
+                                                                                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                                                                      <-Reducer 7 [CUSTOM_SIMPLE_EDGE]
+                                                                                                        PARTITION_ONLY_SHUFFLE [RS_351]
+                                                                                                          Merge Join Operator [MERGEJOIN_461] (rows=36 width=814)
+                                                                                                            Conds:(Left Outer),Output:["_col2","_col4","_col6"]
+                                                                                                          <-Reducer 43 [CUSTOM_SIMPLE_EDGE]
+                                                                                                            PARTITION_ONLY_SHUFFLE [RS_349]
+                                                                                                              Group By Operator [GBY_67] (rows=1 width=288)
+                                                                                                                Output:["_col0"],aggregations:["avg(VALUE._col0)"]
+                                                                                                              <-Map 42 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                PARTITION_ONLY_SHUFFLE [RS_66]
+                                                                                                                  Group By Operator [GBY_65] (rows=1 width=288)
+                                                                                                                    Output:["_col0"],aggregations:["avg(ss_net_paid_inc_tax)"]
+                                                                                                                    Select Operator [SEL_64] (rows=63999515 width=88)
+                                                                                                                      Output:["ss_net_paid_inc_tax"]
+                                                                                                                      Filter Operator [FIL_431] (rows=63999515 width=88)
+                                                                                                                        predicate:ss_quantity BETWEEN 1 AND 20
+                                                                                                                        TableScan [TS_62] (rows=575995635 width=88)
+                                                                                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity","ss_net_paid_inc_tax"]
+                                                                                                          <-Reducer 6 [CUSTOM_SIMPLE_EDGE]
+                                                                                                            PARTITION_ONLY_SHUFFLE [RS_348]
+                                                                                                              Merge Join Operator [MERGEJOIN_460] (rows=36 width=525)
+                                                                                                                Conds:(Inner),Output:["_col2","_col4"]
+                                                                                                              <-Reducer 41 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                PARTITION_ONLY_SHUFFLE [RS_346]
+                                                                                                                  Select Operator [SEL_61] (rows=1 width=8)
+                                                                                                                    Filter Operator [FIL_60] (rows=1 width=8)
+                                                                                                                      predicate:(sq_count_check(_col0) <= 1)
+                                                                                                                      Group By Operator [GBY_58] (rows=1 width=8)
+                                                                                                                        Output:["_col0"],aggregations:["count()"]
+                                                                                                                        Select Operator [SEL_53] (rows=1 width=8)
+                                                                                                                          Group By Operator [GBY_52] (rows=1 width=8)
+                                                                                                                            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                                                          <-Map 40 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                            PARTITION_ONLY_SHUFFLE [RS_51]
+                                                                                                                              Group By Operator [GBY_50] (rows=1 width=8)
+                                                                                                                                Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                                                                                Select Operator [SEL_49] (rows=63999515 width=88)
+                                                                                                                                  Output:["ss_sold_date_sk"]
+                                                                                                                                  Filter Operator [FIL_430] (rows=63999515 width=88)
+                                                                                                                                    predicate:ss_quantity BETWEEN 1 AND 20
+                                                                                                                                    TableScan [TS_47] (rows=575995635 width=88)
+                                                                                                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                                                                              <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                PARTITION_ONLY_SHUFFLE [RS_345]
+                                                                                                                  Merge Join Operator [MERGEJOIN_459] (rows=36 width=516)
+                                                                                                                    Conds:(Left Outer),Output:["_col2","_col4"]
+                                                                                                                  <-Reducer 39 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                    PARTITION_ONLY_SHUFFLE [RS_343]
+                                                                                                                      Group By Operator [GBY_45] (rows=1 width=288)
+                                                                                                                        Output:["_col0"],aggregations:["avg(VALUE._col0)"]
+                                                                                                                      <-Map 38 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                        PARTITION_ONLY_SHUFFLE [RS_44]
+                                                                                                                          Group By Operator [GBY_43] (rows=1 width=288)
+                                                                                                                            Output:["_col0"],aggregations:["avg(ss_ext_list_price)"]
+                                                                                                                            Select Operator [SEL_42] (rows=63999515 width=88)
+                                                                                                                              Output:["ss_ext_list_price"]
+                                                                                                                              Filter Operator [FIL_429] (rows=63999515 width=88)
+                                                                                                                                predicate:ss_quantity BETWEEN 1 AND 20
+                                                                                                                                TableScan [TS_40] (rows=575995635 width=88)
+                                                                                                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity","ss_ext_list_price"]
+                                                                                                                  <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                    PARTITION_ONLY_SHUFFLE [RS_342]
+                                                                                                                      Merge Join Operator [MERGEJOIN_458] (rows=36 width=227)
+                                                                                                                        Conds:(Inner),Output:["_col2"]
+                                                                                                                      <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                        PARTITION_ONLY_SHUFFLE [RS_339]
+                                                                                                                          Merge Join Operator [MERGEJOIN_457] (rows=36 width=218)
+                                                                                                                            Conds:(Left Outer),Output:["_col2"]
+                                                                                                                          <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                            PARTITION_ONLY_SHUFFLE [RS_336]
+                                                                                                                              Merge Join Operator [MERGEJOIN_456] (rows=36 width=209)
+                                                                                                                                Conds:(Inner)
+                                                                                                                              <-Map 1 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                                PARTITION_ONLY_SHUFFLE [RS_333]
+                                                                                                                                  Select Operator [SEL_2] (rows=36 width=200)
+                                                                                                                                    Filter Operator [FIL_425] (rows=36 width=200)
+                                                                                                                                      predicate:(r_reason_sk = 1)
+                                                                                                                                      TableScan [TS_0] (rows=72 width=200)
+                                                                                                                                        default@reason,reason,Tbl:COMPLETE,Col:NONE,Output:["r_reason_sk"]
+                                                                                                                              <-Reducer 33 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                                PARTITION_ONLY_SHUFFLE [RS_334]
+                                                                                                                                  Select Operator [SEL_17] (rows=1 width=8)
+                                                                                                                                    Filter Operator [FIL_16] (rows=1 width=8)
+                                                                                                                                      predicate:(sq_count_check(_col0) <= 1)
+                                                                                                                                      Group By Operator [GBY_14] (rows=1 width=8)
+                                                                                                                                        Output:["_col0"],aggregations:["count()"]
+                                                                                                                                        Select Operator [SEL_9] (rows=1 width=8)
+                                                                                                                                          Group By Operator [GBY_8] (rows=1 width=8)
+                                                                                                                                            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                                                                          <-Map 32 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                                            PARTITION_ONLY_SHUFFLE [RS_7]
+                                                                                                                                              Group By Operator [GBY_6] (rows=1 width=8)
+                                                                                                                                                Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                                                                                                Select Operator [SEL_5] (rows=63999515 width=88)
+                                                                                                                                                  Output:["ss_sold_date_sk"]
+                                                                                                                                                  Filter Operator [FIL_426] (rows=63999515 width=88)
+                                                                                                                                                    predicate:ss_quantity BETWEEN 1 AND 20
+                                                                                                                                                    TableScan [TS_3] (rows=575995635 width=88)
+                                                                                                                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                                                                                          <-Reducer 35 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                            PARTITION_ONLY_SHUFFLE [RS_337]
+                                                                                                                              Group By Operator [GBY_23] (rows=1 width=8)
+                                                                                                                                Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                                                              <-Map 34 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                                PARTITION_ONLY_SHUFFLE [RS_22]
+                                                                                                                                  Group By Operator [GBY_21] (rows=1 width=8)
+                                                                                                                                    Output:["_col0"],aggregations:["count()"]
+                                                                                                                                    Select Operator [SEL_20] (rows=63999515 width=88)
+                                                                                                                                      Filter Operator [FIL_427] (rows=63999515 width=88)
+                                                                                                                                        predicate:ss_quantity BETWEEN 1 AND 20
+                                                                                                                                        TableScan [TS_18] (rows=575995635 width=88)
+                                                                                                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity"]
+                                                                                                                      <-Reducer 37 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                        PARTITION_ONLY_SHUFFLE [RS_340]
+                                                                                                                          Select Operator [SEL_39] (rows=1 width=8)
+                                                                                                                            Filter Operator [FIL_38] (rows=1 width=8)
+                                                                                                                              predicate:(sq_count_check(_col0) <= 1)
+                                                                                                                              Group By Operator [GBY_36] (rows=1 width=8)
+                                                                                                                                Output:["_col0"],aggregations:["count()"]
+                                                                                                                                Select Operator [SEL_31] (rows=1 width=8)
+                                                                                                                                  Group By Operator [GBY_30] (rows=1 width=8)
+                                                                                                                                    Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                                                                  <-Map 36 [CUSTOM_SIMPLE_EDGE]
+                                                                                                                                    PARTITION_ONLY_SHUFFLE [RS_29]
+                                                                                                                                      Group By Operator [GBY_28] (rows=1 width=8)
+                                                                                                                                        Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                                                                                        Select Operator [SEL_27] (rows=63999515 width=88)
+                                                                                                                                          Output:["ss_sold_date_sk"]
+                                                                                                                                          Filter Operator [FIL_428] (rows=63999515 width=88)
+                                                                                                                                            predicate:ss_quantity BETWEEN 1 AND 20
+                                                                                                                                            TableScan [TS_25] (rows=575995635 width=88)
+                                                                                                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                                                          <-Reducer 51 [CUSTOM_SIMPLE_EDGE]
+                                                                                            PARTITION_ONLY_SHUFFLE [RS_361]
+                                                                                              Group By Operator [GBY_111] (rows=1 width=288)
+                                                                                                Output:["_col0"],aggregations:["avg(VALUE._col0)"]
+                                                                                              <-Map 50 [CUSTOM_SIMPLE_EDGE]
+                                                                                                PARTITION_ONLY_SHUFFLE [RS_110]
+                                                                                                  Group By Operator [GBY_109] (rows=1 width=288)
+                                                                                                    Output:["_col0"],aggregations:["avg(ss_ext_list_price)"]
+                                                                                                    Select Operator [SEL_108] (rows=63999515 width=88)
+                                                                                                      Output:["ss_ext_list_price"]
+                                                                                                      Filter Operator [FIL_435] (rows=63999515 width=88)
+                                                                                                        predicate:ss_quantity BETWEEN 21 AND 40
+                                                                                                        TableScan [TS_106] (rows=575995635 width=88)
+                                                                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity","ss_ext_list_price"]
+                                                                                      <-Reducer 53 [CUSTOM_SIMPLE_EDGE]
+                                                                                        PARTITION_ONLY_SHUFFLE [RS_364]
+                                                                                          Select Operator [SEL_127] (rows=1 width=8)
+                                                                                            Filter Operator [FIL_126] (rows=1 width=8)
+                                                                                              predicate:(sq_count_check(_col0) <= 1)
+                                                                                              Group By Operator [GBY_124] (rows=1 width=8)
+                                                                                                Output:["_col0"],aggregations:["count()"]
+                                                                                                Select Operator [SEL_119] (rows=1 width=8)
+                                                                                                  Group By Operator [GBY_118] (rows=1 width=8)
+                                                                                                    Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                                  <-Map 52 [CUSTOM_SIMPLE_EDGE]
+                                                                                                    PARTITION_ONLY_SHUFFLE [RS_117]
+                                                                                                      Group By Operator [GBY_116] (rows=1 width=8)
+                                                                                                        Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                                                        Select Operator [SEL_115] (rows=63999515 width=88)
+                                                                                                          Output:["ss_sold_date_sk"]
+                                                                                                          Filter Operator [FIL_436] (rows=63999515 width=88)
+                                                                                                            predicate:ss_quantity BETWEEN 21 AND 40
+                                                                                                            TableScan [TS_113] (rows=575995635 width=88)
+                                                                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                                                  <-Reducer 55 [CUSTOM_SIMPLE_EDGE]
+                                                                                    PARTITION_ONLY_SHUFFLE [RS_367]
+                                                                                      Group By Operator [GBY_133] (rows=1 width=288)
+                                                                                        Output:["_col0"],aggregations:["avg(VALUE._col0)"]
+                                                                                      <-Map 54 [CUSTOM_SIMPLE_EDGE]
+                                                                                        PARTITION_ONLY_SHUFFLE [RS_132]
+                                                                                          Group By Operator [GBY_131] (rows=1 width=288)
+                                                                                            Output:["_col0"],aggregations:["avg(ss_net_paid_inc_tax)"]
+                                                                                            Select Operator [SEL_130] (rows=63999515 width=88)
+                                                                                              Output:["ss_net_paid_inc_tax"]
+                                                                                              Filter Operator [FIL_437] (rows=63999515 width=88)
+                                                                                                predicate:ss_quantity BETWEEN 21 AND 40
+                                                                                                TableScan [TS_128] (rows=575995635 width=88)
+                                                                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity","ss_net_paid_inc_tax"]
+                                                                              <-Reducer 57 [CUSTOM_SIMPLE_EDGE]
+                                                                                PARTITION_ONLY_SHUFFLE [RS_370]
+                                                                                  Select Operator [SEL_149] (rows=1 width=8)
+                                                                                    Filter Operator [FIL_148] (rows=1 width=8)
+                                                                                      predicate:(sq_count_check(_col0) <= 1)
+                                                                                      Group By Operator [GBY_146] (rows=1 width=8)
+                                                                                        Output:["_col0"],aggregations:["count()"]
+                                                                                        Select Operator [SEL_141] (rows=1 width=8)
+                                                                                          Group By Operator [GBY_140] (rows=1 width=8)
+                                                                                            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                          <-Map 56 [CUSTOM_SIMPLE_EDGE]
+                                                                                            PARTITION_ONLY_SHUFFLE [RS_139]
+                                                                                              Group By Operator [GBY_138] (rows=1 width=8)
+                                                                                                Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                                                Select Operator [SEL_137] (rows=63999515 width=88)
+                                                                                                  Output:["ss_sold_date_sk"]
+                                                                                                  Filter Operator [FIL_438] (rows=63999515 width=88)
+                                                                                                    predicate:ss_quantity BETWEEN 41 AND 60
+                                                                                                    TableScan [TS_135] (rows=575995635 width=88)
+                                                                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                                          <-Reducer 59 [CUSTOM_SIMPLE_EDGE]
+                                                                            PARTITION_ONLY_SHUFFLE [RS_373]
+                                                                              Group By Operator [GBY_155] (rows=1 width=8)
+                                                                                Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                              <-Map 58 [CUSTOM_SIMPLE_EDGE]
+                                                                                PARTITION_ONLY_SHUFFLE [RS_154]
+                                                                                  Group By Operator [GBY_153] (rows=1 width=8)
+                                                                                    Output:["_col0"],aggregations:["count()"]
+                                                                                    Select Operator [SEL_152] (rows=63999515 width=88)
+                                                                                      Filter Operator [FIL_439] (rows=63999515 width=88)
+                                                                                        predicate:ss_quantity BETWEEN 41 AND 60
+                                                                                        TableScan [TS_150] (rows=575995635 width=88)
+                                                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity"]
+                                                                      <-Reducer 61 [CUSTOM_SIMPLE_EDGE]
+                                                                        PARTITION_ONLY_SHUFFLE [RS_376]
+                                                                          Select Operator [SEL_171] (rows=1 width=8)
+                                                                            Filter Operator [FIL_170] (rows=1 width=8)
+                                                                              predicate:(sq_count_check(_col0) <= 1)
+                                                                              Group By Operator [GBY_168] (rows=1 width=8)
+                                                                                Output:["_col0"],aggregations:["count()"]
+                                                                                Select Operator [SEL_163] (rows=1 width=8)
+                                                                                  Group By Operator [GBY_162] (rows=1 width=8)
+                                                                                    Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                                  <-Map 60 [CUSTOM_SIMPLE_EDGE]
+                                                                                    PARTITION_ONLY_SHUFFLE [RS_161]
+                                                                                      Group By Operator [GBY_160] (rows=1 width=8)
+                                                                                        Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                                        Select Operator [SEL_159] (rows=63999515 width=88)
+                                                                                          Output:["ss_sold_date_sk"]
+                                                                                          Filter Operator [FIL_440] (rows=63999515 width=88)
+                                                                                            predicate:ss_quantity BETWEEN 41 AND 60
+                                                                                            TableScan [TS_157] (rows=575995635 width=88)
+                                                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                                  <-Reducer 63 [CUSTOM_SIMPLE_EDGE]
+                                                                    PARTITION_ONLY_SHUFFLE [RS_379]
+                                                                      Group By Operator [GBY_177] (rows=1 width=288)
+                                                                        Output:["_col0"],aggregations:["avg(VALUE._col0)"]
+                                                                      <-Map 62 [CUSTOM_SIMPLE_EDGE]
+                                                                        PARTITION_ONLY_SHUFFLE [RS_176]
+                                                                          Group By Operator [GBY_175] (rows=1 width=288)
+                                                                            Output:["_col0"],aggregations:["avg(ss_ext_list_price)"]
+                                                                            Select Operator [SEL_174] (rows=63999515 width=88)
+                                                                              Output:["ss_ext_list_price"]
+                                                                              Filter Operator [FIL_441] (rows=63999515 width=88)
+                                                                                predicate:ss_quantity BETWEEN 41 AND 60
+                                                                                TableScan [TS_172] (rows=575995635 width=88)
+                                                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity","ss_ext_list_price"]
+                                                              <-Reducer 65 [CUSTOM_SIMPLE_EDGE]
+                                                                PARTITION_ONLY_SHUFFLE [RS_382]
+                                                                  Select Operator [SEL_193] (rows=1 width=8)
+                                                                    Filter Operator [FIL_192] (rows=1 width=8)
+                                                                      predicate:(sq_count_check(_col0) <= 1)
+                                                                      Group By Operator [GBY_190] (rows=1 width=8)
+                                                                        Output:["_col0"],aggregations:["count()"]
+                                                                        Select Operator [SEL_185] (rows=1 width=8)
+                                                                          Group By Operator [GBY_184] (rows=1 width=8)
+                                                                            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                          <-Map 64 [CUSTOM_SIMPLE_EDGE]
+                                                                            PARTITION_ONLY_SHUFFLE [RS_183]
+                                                                              Group By Operator [GBY_182] (rows=1 width=8)
+                                                                                Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                                Select Operator [SEL_181] (rows=63999515 width=88)
+                                                                                  Output:["ss_sold_date_sk"]
+                                                                                  Filter Operator [FIL_442] (rows=63999515 width=88)
+                                                                                    predicate:ss_quantity BETWEEN 41 AND 60
+                                                                                    TableScan [TS_179] (rows=575995635 width=88)
+                                                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                          <-Reducer 67 [CUSTOM_SIMPLE_EDGE]
+                                                            PARTITION_ONLY_SHUFFLE [RS_385]
+                                                              Group By Operator [GBY_199] (rows=1 width=288)
+                                                                Output:["_col0"],aggregations:["avg(VALUE._col0)"]
+                                                              <-Map 66 [CUSTOM_SIMPLE_EDGE]
+                                                                PARTITION_ONLY_SHUFFLE [RS_198]
+                                                                  Group By Operator [GBY_197] (rows=1 width=288)
+                                                                    Output:["_col0"],aggregations:["avg(ss_net_paid_inc_tax)"]
+                                                                    Select Operator [SEL_196] (rows=63999515 width=88)
+                                                                      Output:["ss_net_paid_inc_tax"]
+                                                                      Filter Operator [FIL_443] (rows=63999515 width=88)
+                                                                        predicate:ss_quantity BETWEEN 41 AND 60
+                                                                        TableScan [TS_194] (rows=575995635 width=88)
+                                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity","ss_net_paid_inc_tax"]
+                                                      <-Reducer 69 [CUSTOM_SIMPLE_EDGE]
+                                                        PARTITION_ONLY_SHUFFLE [RS_388]
+                                                          Select Operator [SEL_215] (rows=1 width=8)
+                                                            Filter Operator [FIL_214] (rows=1 width=8)
+                                                              predicate:(sq_count_check(_col0) <= 1)
+                                                              Group By Operator [GBY_212] (rows=1 width=8)
+                                                                Output:["_col0"],aggregations:["count()"]
+                                                                Select Operator [SEL_207] (rows=1 width=8)
+                                                                  Group By Operator [GBY_206] (rows=1 width=8)
+                                                                    Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                                  <-Map 68 [CUSTOM_SIMPLE_EDGE]
+                                                                    PARTITION_ONLY_SHUFFLE [RS_205]
+                                                                      Group By Operator [GBY_204] (rows=1 width=8)
+                                                                        Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                        Select Operator [SEL_203] (rows=63999515 width=88)
+                                                                          Output:["ss_sold_date_sk"]
+                                                                          Filter Operator [FIL_444] (rows=63999515 width=88)
+                                                                            predicate:ss_quantity BETWEEN 61 AND 80
+                                                                            TableScan [TS_201] (rows=575995635 width=88)
+                                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                  <-Reducer 71 [CUSTOM_SIMPLE_EDGE]
+                                                    PARTITION_ONLY_SHUFFLE [RS_391]
+                                                      Group By Operator [GBY_221] (rows=1 width=8)
+                                                        Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                      <-Map 70 [CUSTOM_SIMPLE_EDGE]
+                                                        PARTITION_ONLY_SHUFFLE [RS_220]
+                                                          Group By Operator [GBY_219] (rows=1 width=8)
+                                                            Output:["_col0"],aggregations:["count()"]
+                                                            Select Operator [SEL_218] (rows=63999515 width=88)
+                                                              Filter Operator [FIL_445] (rows=63999515 width=88)
+                                                                predicate:ss_quantity BETWEEN 61 AND 80
+                                                                TableScan [TS_216] (rows=575995635 width=88)
+                                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity"]
+                                              <-Reducer 73 [CUSTOM_SIMPLE_EDGE]
+                                                PARTITION_ONLY_SHUFFLE [RS_394]
+                                                  Select Operator [SEL_237] (rows=1 width=8)
+                                                    Filter Operator [FIL_236] (rows=1 width=8)
+                                                      predicate:(sq_count_check(_col0) <= 1)
+                                                      Group By Operator [GBY_234] (rows=1 width=8)
+                                                        Output:["_col0"],aggregations:["count()"]
+                                                        Select Operator [SEL_229] (rows=1 width=8)
+                                                          Group By Operator [GBY_228] (rows=1 width=8)
+                                                            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                          <-Map 72 [CUSTOM_SIMPLE_EDGE]
+                                                            PARTITION_ONLY_SHUFFLE [RS_227]
+                                                              Group By Operator [GBY_226] (rows=1 width=8)
+                                                                Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                                Select Operator [SEL_225] (rows=63999515 width=88)
+                                                                  Output:["ss_sold_date_sk"]
+                                                                  Filter Operator [FIL_446] (rows=63999515 width=88)
+                                                                    predicate:ss_quantity BETWEEN 61 AND 80
+                                                                    TableScan [TS_223] (rows=575995635 width=88)
+                                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                          <-Reducer 75 [CUSTOM_SIMPLE_EDGE]
+                                            PARTITION_ONLY_SHUFFLE [RS_397]
+                                              Group By Operator [GBY_243] (rows=1 width=288)
+                                                Output:["_col0"],aggregations:["avg(VALUE._col0)"]
+                                              <-Map 74 [CUSTOM_SIMPLE_EDGE]
+                                                PARTITION_ONLY_SHUFFLE [RS_242]
+                                                  Group By Operator [GBY_241] (rows=1 width=288)
+                                                    Output:["_col0"],aggregations:["avg(ss_ext_list_price)"]
+                                                    Select Operator [SEL_240] (rows=63999515 width=88)
+                                                      Output:["ss_ext_list_price"]
+                                                      Filter Operator [FIL_447] (rows=63999515 width=88)
+                                                        predicate:ss_quantity BETWEEN 61 AND 80
+                                                        TableScan [TS_238] (rows=575995635 width=88)
+                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity","ss_ext_list_price"]
+                                      <-Reducer 77 [CUSTOM_SIMPLE_EDGE]
+                                        PARTITION_ONLY_SHUFFLE [RS_400]
+                                          Select Operator [SEL_259] (rows=1 width=8)
+                                            Filter Operator [FIL_258] (rows=1 width=8)
+                                              predicate:(sq_count_check(_col0) <= 1)
+                                              Group By Operator [GBY_256] (rows=1 width=8)
+                                                Output:["_col0"],aggregations:["count()"]
+                                                Select Operator [SEL_251] (rows=1 width=8)
+                                                  Group By Operator [GBY_250] (rows=1 width=8)
+                                                    Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                  <-Map 76 [CUSTOM_SIMPLE_EDGE]
+                                                    PARTITION_ONLY_SHUFFLE [RS_249]
+                                                      Group By Operator [GBY_248] (rows=1 width=8)
+                                                        Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                        Select Operator [SEL_247] (rows=63999515 width=88)
+                                                          Output:["ss_sold_date_sk"]
+                                                          Filter Operator [FIL_448] (rows=63999515 width=88)
+                                                            predicate:ss_quantity BETWEEN 61 AND 80
+                                                            TableScan [TS_245] (rows=575995635 width=88)
+                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                                  <-Reducer 79 [CUSTOM_SIMPLE_EDGE]
+                                    PARTITION_ONLY_SHUFFLE [RS_403]
+                                      Group By Operator [GBY_265] (rows=1 width=288)
+                                        Output:["_col0"],aggregations:["avg(VALUE._col0)"]
+                                      <-Map 78 [CUSTOM_SIMPLE_EDGE]
+                                        PARTITION_ONLY_SHUFFLE [RS_264]
+                                          Group By Operator [GBY_263] (rows=1 width=288)
+                                            Output:["_col0"],aggregations:["avg(ss_net_paid_inc_tax)"]
+                                            Select Operator [SEL_262] (rows=63999515 width=88)
+                                              Output:["ss_net_paid_inc_tax"]
+                                              Filter Operator [FIL_449] (rows=63999515 width=88)
+                                                predicate:ss_quantity BETWEEN 61 AND 80
+                                                TableScan [TS_260] (rows=575995635 width=88)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity","ss_net_paid_inc_tax"]
+                              <-Reducer 81 [CUSTOM_SIMPLE_EDGE]
+                                PARTITION_ONLY_SHUFFLE [RS_406]
+                                  Select Operator [SEL_281] (rows=1 width=8)
+                                    Filter Operator [FIL_280] (rows=1 width=8)
+                                      predicate:(sq_count_check(_col0) <= 1)
+                                      Group By Operator [GBY_278] (rows=1 width=8)
+                                        Output:["_col0"],aggregations:["count()"]
+                                        Select Operator [SEL_273] (rows=1 width=8)
+                                          Group By Operator [GBY_272] (rows=1 width=8)
+                                            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                          <-Map 80 [CUSTOM_SIMPLE_EDGE]
+                                            PARTITION_ONLY_SHUFFLE [RS_271]
+                                              Group By Operator [GBY_270] (rows=1 width=8)
+                                                Output:["_col0"],aggregations:["count(ss_sold_date_sk)"]
+                                                Select Operator [SEL_269] (rows=63999515 width=88)
+                                                  Output:["ss_sold_date_sk"]
+                                                  Filter Operator [FIL_450] (rows=63999515 width=88)
+                                                    predicate:ss_quantity BETWEEN 81 AND 100
+                                                    TableScan [TS_267] (rows=575995635 width=88)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_quantity"]
+                          <-Reducer 83 [CUSTOM_SIMPLE_EDGE]
+                            PARTITION_ONLY_SHUFFLE [RS_409]
+                              Group By Operator [GBY_287] (rows=1 width=8)
+                                Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                              <-Map 82 [CUSTOM_SIMPLE_EDGE]
+              

<TRUNCATED>

[3/3] hive git commit: HIVE-16228 : Support subqueries in complex expression in SELECT clause (Vineet Garg via Ashutosh Chauhan)

Posted by ha...@apache.org.
HIVE-16228 : Support subqueries in complex expression in SELECT clause (Vineet Garg via Ashutosh Chauhan)

Signed-off-by: Ashutosh Chauhan <ha...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/ac6735a3
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/ac6735a3
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/ac6735a3

Branch: refs/heads/master
Commit: ac6735a385dfe88a59fa43194234433ceed7e899
Parents: db983d6
Author: Vineet Garg <vg...@hortonworks.com>
Authored: Wed Mar 15 19:02:00 2017 -0700
Committer: Ashutosh Chauhan <ha...@apache.org>
Committed: Thu Mar 30 15:14:31 2017 -0700

----------------------------------------------------------------------
 .../calcite/rules/HiveSubQueryRemoveRule.java   |  156 +-
 .../hadoop/hive/ql/parse/CalcitePlanner.java    |    5 +-
 .../hadoop/hive/ql/parse/SubQueryUtils.java     |   21 +-
 .../subquery_select_complex_expr.q              |    3 -
 .../clientnegative/subquery_select_no_source.q  |    2 +
 .../clientnegative/subquery_select_udf.q        |    2 -
 .../test/queries/clientpositive/perf/query9.q   |   50 +
 .../queries/clientpositive/subquery_select.q    |  138 +-
 .../clientnegative/subquery_in_select.q.out     |    1 -
 .../subquery_select_aggregate.q.out             |    2 +-
 .../subquery_select_complex_expr.q.out          |    1 -
 .../subquery_select_no_source.q.out             |    1 +
 .../clientnegative/subquery_select_udf.q.out    |    1 -
 .../clientpositive/llap/subquery_select.q.out   | 5225 +++++++++++++++++-
 .../results/clientpositive/perf/query9.q.out    |  829 +++
 15 files changed, 6194 insertions(+), 243 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSubQueryRemoveRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSubQueryRemoveRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSubQueryRemoveRule.java
index 7c96f3d..c692cc0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSubQueryRemoveRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSubQueryRemoveRule.java
@@ -29,6 +29,7 @@ import org.apache.calcite.rel.core.JoinRelType;
 import org.apache.calcite.rel.core.Project;
 import org.apache.calcite.rex.LogicVisitor;
 import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexVisitorImpl;
 import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.rex.RexShuttle;
 import org.apache.calcite.rex.RexSubQuery;
@@ -43,10 +44,12 @@ import org.apache.calcite.sql.type.ReturnTypes;
 import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.tools.RelBuilderFactory;
 import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
 
+import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
@@ -72,49 +75,26 @@ import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFilter;
  */
 public abstract class HiveSubQueryRemoveRule extends RelOptRule{
 
-    public static final HiveSubQueryRemoveRule PROJECT =
-            new HiveSubQueryRemoveRule(
-                    operand(Project.class, null, RexUtil.SubQueryFinder.PROJECT_PREDICATE,
-                            any()),
-                    HiveRelFactories.HIVE_BUILDER, "SubQueryRemoveRule:Project") {
-                public void onMatch(RelOptRuleCall call) {
-                    final Project project = call.rel(0);
-                    //TODO: replace HiveSubQRemoveRelBuilder with calcite's once calcite 1.11.0 is released
-                    final HiveSubQRemoveRelBuilder builder = new HiveSubQRemoveRelBuilder(null, call.rel(0).getCluster(), null);
-                    final RexSubQuery e =
-                            RexUtil.SubQueryFinder.find(project.getProjects());
-                    assert e != null;
-                    final RelOptUtil.Logic logic =
-                            LogicVisitor.find(RelOptUtil.Logic.TRUE_FALSE_UNKNOWN,
-                                    project.getProjects(), e);
-                    builder.push(project.getInput());
-                    final int fieldCount = builder.peek().getRowType().getFieldCount();
-                    final RexNode target = apply(e, HiveFilter.getVariablesSet(e),
-                            logic, builder, 1, fieldCount, false);
-                    final RexShuttle shuttle = new ReplaceSubQueryShuttle(e, target);
-                    builder.project(shuttle.apply(project.getProjects()),
-                            project.getRowType().getFieldNames());
-                    call.transformTo(builder.build());
-                }
-            };
-
-    public static final HiveSubQueryRemoveRule FILTER =
-            new HiveSubQueryRemoveRule(
-                    operand(Filter.class, null, RexUtil.SubQueryFinder.FILTER_PREDICATE,
-                            any()),
-                    HiveRelFactories.HIVE_BUILDER, "SubQueryRemoveRule:Filter") {
-                public void onMatch(RelOptRuleCall call) {
+    public static final HiveSubQueryRemoveRule REL_NODE =
+        new HiveSubQueryRemoveRule(
+            operand(RelNode.class, null, HiveSubQueryFinder.RELNODE_PREDICATE,
+                any()),
+            HiveRelFactories.HIVE_BUILDER, "SubQueryRemoveRule:Filter") {
+            public void onMatch(RelOptRuleCall call) {
+                final RelNode relNode = call.rel(0);
+                //TODO: replace HiveSubQRemoveRelBuilder with calcite's once calcite 1.11.0 is released
+                final HiveSubQRemoveRelBuilder builder = new HiveSubQRemoveRelBuilder(null, call.rel(0).getCluster(), null);
+
+                // if subquery is in FILTER
+                if(relNode instanceof Filter) {
                     final Filter filter = call.rel(0);
-                    //final RelBuilder builder = call.builder();
-                    //TODO: replace HiveSubQRemoveRelBuilder with calcite's once calcite 1.11.0 is released
-                    final HiveSubQRemoveRelBuilder builder = new HiveSubQRemoveRelBuilder(null, call.rel(0).getCluster(), null);
                     final RexSubQuery e =
-                            RexUtil.SubQueryFinder.find(filter.getCondition());
+                        RexUtil.SubQueryFinder.find(filter.getCondition());
                     assert e != null;
 
                     final RelOptUtil.Logic logic =
-                            LogicVisitor.find(RelOptUtil.Logic.TRUE,
-                                    ImmutableList.of(filter.getCondition()), e);
+                        LogicVisitor.find(RelOptUtil.Logic.TRUE,
+                            ImmutableList.of(filter.getCondition()), e);
                     builder.push(filter.getInput());
                     final int fieldCount = builder.peek().getRowType().getFieldCount();
 
@@ -123,13 +103,37 @@ public abstract class HiveSubQueryRemoveRule extends RelOptRule{
                     boolean isCorrScalarQuery = corrScalarQueries.contains(e.rel);
 
                     final RexNode target = apply(e, HiveFilter.getVariablesSet(e), logic,
-                            builder, 1, fieldCount, isCorrScalarQuery);
+                        builder, 1, fieldCount, isCorrScalarQuery);
                     final RexShuttle shuttle = new ReplaceSubQueryShuttle(e, target);
                     builder.filter(shuttle.apply(filter.getCondition()));
                     builder.project(fields(builder, filter.getRowType().getFieldCount()));
                     call.transformTo(builder.build());
                 }
-            };
+                // if subquery is in PROJECT
+                else if(relNode instanceof Project) {
+                    final Project project = call.rel(0);
+                    final RexSubQuery e =
+                        RexUtil.SubQueryFinder.find(project.getProjects());
+                    assert e != null;
+
+                    final RelOptUtil.Logic logic =
+                        LogicVisitor.find(RelOptUtil.Logic.TRUE_FALSE_UNKNOWN,
+                            project.getProjects(), e);
+                    builder.push(project.getInput());
+                    final int fieldCount = builder.peek().getRowType().getFieldCount();
+
+                    Set<RelNode> corrScalarQueries = project.getCluster().getPlanner().getContext().unwrap(Set.class);
+                    boolean isCorrScalarQuery = corrScalarQueries.contains(e.rel);
+
+                    final RexNode target = apply(e, HiveFilter.getVariablesSet(e),
+                        logic, builder, 1, fieldCount, isCorrScalarQuery);
+                    final RexShuttle shuttle = new ReplaceSubQueryShuttle(e, target);
+                    builder.project(shuttle.apply(project.getProjects()),
+                        project.getRowType().getFieldNames());
+                    call.transformTo(builder.build());
+                }
+            }
+        };
 
     private HiveSubQueryRemoveRule(RelOptRuleOperand operand,
                                RelBuilderFactory relBuilderFactory,
@@ -200,7 +204,9 @@ public abstract class HiveSubQueryRemoveRule extends RelOptRule{
                     final ImmutableList.Builder<RexNode> operands = ImmutableList.builder();
                     RexNode literal;
                     if(isAggZeroOnEmpty(e)) {
-                        literal = builder.literal(0);
+                        // since count has a return type of BIG INT we need to make a literal of type big int
+                        // relbuilder's literal doesn't allow this
+                        literal = e.rel.getCluster().getRexBuilder().makeBigintLiteral(new BigDecimal(0));
                     }
                     else {
                         literal = e.rel.getCluster().getRexBuilder().makeNullLiteral(getAggTypeForScalarSub(e));
@@ -455,6 +461,72 @@ public abstract class HiveSubQueryRemoveRule extends RelOptRule{
             return RexUtil.eq(subQuery, this.subQuery) ? replacement : subQuery;
         }
     }
+
+    // TODO:
+    // Following HiveSubQueryFinder has been copied from RexUtil::SubQueryFinder
+    // since there is BUG in there (CALCITE-1726).
+    // Once CALCITE-1726 is fixed we should get rid of the following code
+    /** Visitor that throws {@link org.apache.calcite.util.Util.FoundOne} if
+     * applied to an expression that contains a {@link RexSubQuery}. */
+    public static class HiveSubQueryFinder extends RexVisitorImpl<Void> {
+        public static final HiveSubQueryFinder INSTANCE = new HiveSubQueryFinder();
+
+        /** Returns whether a {@link Project} contains a sub-query. */
+        public static final Predicate<RelNode> RELNODE_PREDICATE=
+            new Predicate<RelNode>() {
+                public boolean apply(RelNode relNode) {
+                    if (relNode instanceof Project) {
+                        Project project = (Project)relNode;
+                        for (RexNode node : project.getProjects()) {
+                            try {
+                                node.accept(INSTANCE);
+                            } catch (Util.FoundOne e) {
+                                return true;
+                            }
+                        }
+                        return false;
+                    }
+                    else if (relNode instanceof Filter) {
+                        try {
+                            ((Filter)relNode).getCondition().accept(INSTANCE);
+                            return false;
+                        } catch (Util.FoundOne e) {
+                            return true;
+                        }
+                    }
+                    return false;
+                }
+            };
+
+        private HiveSubQueryFinder() {
+            super(true);
+        }
+
+        @Override public Void visitSubQuery(RexSubQuery subQuery) {
+            throw new Util.FoundOne(subQuery);
+        }
+
+        public static RexSubQuery find(Iterable<RexNode> nodes) {
+            for (RexNode node : nodes) {
+                try {
+                    node.accept(INSTANCE);
+                } catch (Util.FoundOne e) {
+                    return (RexSubQuery) e.getNode();
+                }
+            }
+            return null;
+        }
+
+        public static RexSubQuery find(RexNode node) {
+            try {
+                node.accept(INSTANCE);
+                return null;
+            } catch (Util.FoundOne e) {
+                return (RexSubQuery) e.getNode();
+            }
+        }
+    }
+
 }
 
 // End SubQueryRemoveRule.java

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
index e75e892..79662ec 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
@@ -1341,7 +1341,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
       //Remove subquery
       LOG.debug("Plan before removing subquery:\n" + RelOptUtil.toString(calciteGenPlan));
       calciteGenPlan = hepPlan(calciteGenPlan, false, mdProvider.getMetadataProvider(), null,
-              HiveSubQueryRemoveRule.FILTER, HiveSubQueryRemoveRule.PROJECT);
+              HiveSubQueryRemoveRule.REL_NODE);
       LOG.debug("Plan just after removing subquery:\n" + RelOptUtil.toString(calciteGenPlan));
 
       calciteGenPlan = HiveRelDecorrelator.decorrelateQuery(calciteGenPlan);
@@ -3642,7 +3642,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
                   subQueryToRelNode);
           if(isSubQuery) {
             ExprNodeDesc subQueryExpr = genExprNodeDesc(expr, relToHiveRR.get(srcRel),
-                    outerRR, subQueryToRelNode, false);
+                    outerRR, subQueryToRelNode, true);
             col_list.add(subQueryExpr);
 
             ColumnInfo colInfo = new ColumnInfo(SemanticAnalyzer.getColumnInternalName(pos),
@@ -3652,6 +3652,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
                       + colAlias + " => " + colInfo + " due to duplication, see previous warnings",
                       UnsupportedFeature.Duplicates_in_RR);
             }
+            pos = Integer.valueOf(pos.intValue() + 1);
           } else {
 
             // 6.4 Build ExprNode corresponding to colums

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/java/org/apache/hadoop/hive/ql/parse/SubQueryUtils.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SubQueryUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SubQueryUtils.java
index 0ec24b5..06cf56d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SubQueryUtils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SubQueryUtils.java
@@ -653,15 +653,26 @@ public class SubQueryUtils {
     return eq;
   }
 
-  static void checkForSubqueries(ASTNode node) throws SemanticException {
+  static void checkForSubqueries(ASTNode node, boolean disallow) throws SemanticException {
     // allow NOT but throw an error for rest
     if(node.getType() == HiveParser.TOK_SUBQUERY_EXPR
-            && node.getParent().getType() != HiveParser.KW_NOT) {
+            && disallow) {
       throw new CalciteSubquerySemanticException(ErrorMsg.UNSUPPORTED_SUBQUERY_EXPRESSION.getMsg(
-              "Invalid subquery. Subquery in SELECT could only be top-level expression"));
+              "Invalid subquery. Subquery in UDAF is not allowed."));
+    }
+    if (node.getType() == HiveParser.TOK_FUNCTION
+            || node.getType() == HiveParser.TOK_FUNCTIONDI
+            || node.getType() == HiveParser.TOK_FUNCTIONSTAR) {
+      if (node.getChild(0).getType() == HiveParser.Identifier) {
+        String functionName = SemanticAnalyzer.unescapeIdentifier(node.getChild(0).getText());
+        GenericUDAFResolver udafResolver = FunctionRegistry.getGenericUDAFResolver(functionName);
+        if (udafResolver != null) {
+          disallow = disallow || true;
+        }
+      }
     }
     for(int i=0; i<node.getChildCount(); i++) {
-        checkForSubqueries((ASTNode)node.getChild(i));
+        checkForSubqueries((ASTNode)node.getChild(i), disallow);
     }
   }
   /*
@@ -694,7 +705,7 @@ public class SubQueryUtils {
       }
       // otherwise we need to make sure that there is no subquery at any level
       for(int j=0; j<selExpr.getChildCount(); j++) {
-        checkForSubqueries((ASTNode) selExpr.getChild(j));
+        checkForSubqueries((ASTNode) selExpr.getChild(j), false);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/queries/clientnegative/subquery_select_complex_expr.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/subquery_select_complex_expr.q b/ql/src/test/queries/clientnegative/subquery_select_complex_expr.q
deleted file mode 100644
index 8e6cf66..0000000
--- a/ql/src/test/queries/clientnegative/subquery_select_complex_expr.q
+++ /dev/null
@@ -1,3 +0,0 @@
-
--- since subquery is not top level expression this should throw an error
-explain SELECT p_size, 1+(SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type) from part;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/queries/clientnegative/subquery_select_no_source.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/subquery_select_no_source.q b/ql/src/test/queries/clientnegative/subquery_select_no_source.q
new file mode 100644
index 0000000..75cae51
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/subquery_select_no_source.q
@@ -0,0 +1,2 @@
+-- since CBO doesn't allow such queries we can not support subqueries here
+explain select (select max(p_size) from part);

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/queries/clientnegative/subquery_select_udf.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/subquery_select_udf.q b/ql/src/test/queries/clientnegative/subquery_select_udf.q
deleted file mode 100644
index a52a5a9..0000000
--- a/ql/src/test/queries/clientnegative/subquery_select_udf.q
+++ /dev/null
@@ -1,2 +0,0 @@
--- subqueries in UDFs are not allowed
-explain SELECT p_size, exp((SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type)) from part;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/queries/clientpositive/perf/query9.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/query9.q b/ql/src/test/queries/clientpositive/perf/query9.q
new file mode 100644
index 0000000..77bffca
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/query9.q
@@ -0,0 +1,50 @@
+set hive.mapred.mode=nonstrict;
+
+explain select case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 1 and 20) > 409437
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 1 and 20)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 1 and 20) end bucket1 ,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 21 and 40) > 4595804
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 21 and 40)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 21 and 40) end bucket2,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 41 and 60) > 7887297
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 41 and 60)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 41 and 60) end bucket3,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 61 and 80) > 10872978
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 61 and 80)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 61 and 80) end bucket4,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 81 and 100) > 43571537
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 81 and 100)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 81 and 100) end bucket5
+from reason
+where r_reason_sk = 1
+;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/queries/clientpositive/subquery_select.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/subquery_select.q b/ql/src/test/queries/clientpositive/subquery_select.q
index cb7d7aa..15377a4 100644
--- a/ql/src/test/queries/clientpositive/subquery_select.q
+++ b/ql/src/test/queries/clientpositive/subquery_select.q
@@ -66,12 +66,13 @@ FROM part;
 SELECT p_size, NOT EXISTS(SELECT p_size FROM part pp where pp.p_type = part.p_type)
 FROM part;
 
--- SCALAR, corr
-explain SELECT p_size, (SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type)
-FROM part;
+-- scalar with COUNT, since where is always false count should return 0
+explain select p_size, (select count(p_name) from part p where p.p_type = part.p_name) from part;
+select p_size, (select count(p_name) from part p where p.p_type = part.p_name) from part;
 
-SELECT p_size, (SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type)
-FROM part;
+-- scalar with MAX, since where is always false max should return NULL
+explain select p_size, (select max(p_name) from part p where p.p_type = part.p_name) from part;
+select p_size, (select max(p_name) from part p where p.p_type = part.p_name) from part;
 
 -- SCALAR, non corr
 explain SELECT p_size, (SELECT max(p_size) FROM part)
@@ -131,3 +132,130 @@ select p_size, (select max(i) from tempty) from part;
 
 DROP table tempty;
 DROP table tnull;
+
+-- following tests test subquery in all kind of expressions (except UDAF, UDA and UDTF)
+
+
+
+-- different data types
+-- string with string
+-- null with int
+-- boolean (IN, EXISTS) with AND, OR
+
+-- scalar, corr
+explain SELECT p_size, 1+(SELECT max(p_size) FROM part p
+    WHERE p.p_type = part.p_type) from part;
+SELECT p_size, 1+(SELECT max(p_size) FROM part p
+    WHERE p.p_type = part.p_type) from part;
+
+-- IS NULL
+explain SELECT p_size, (SELECT count(p_size) FROM part p
+    WHERE p.p_type = part.p_type) IS NULL from part;
+SELECT p_size, (SELECT count(p_size) FROM part p
+    WHERE p.p_type = part.p_type) IS NULL from part;
+
+-- scalar, non-corr, non agg
+explain select p_type, (select p_size from part order by p_size limit 1) = 1 from part;
+select p_type, (select p_size from part order by p_size limit 1) = 1 from part;
+
+-- in corr, multiple
+EXPLAIN SELECT p_size, p_size IN (
+        SELECT MAX(p_size) FROM part p where p.p_type = part.p_type) AND
+        p_name IN (SELECT min(p_name) from part)
+FROM part;
+SELECT p_size, p_size IN (
+        SELECT MAX(p_size) FROM part p where p.p_type = part.p_type) AND
+        p_name IN (SELECT min(p_name) from part)
+FROM part;
+
+-- exists, corr
+explain SELECT p_size, NOT EXISTS(SELECT p_size FROM part pp where pp.p_type = part.p_type)
+FROM part;
+SELECT p_size, NOT EXISTS(SELECT p_size FROM part pp where pp.p_type = part.p_type)
+FROM part;
+
+-- scalar subquery within IN subquery
+explain select p_size, (p_size IN
+    (select (select max(p_size) from part) as sb from part order by sb limit 1)) = true
+   from part;
+select p_size, (p_size IN
+    (select (select max(p_size) from part) as sb from part order by sb limit 1)) = true
+   from part;
+
+explain select case when (select count(*)
+                  from part
+                  where p_size between 1 and 20) > 409437
+            then (select avg(p_partkey)
+                  from part
+                  where p_partkey between 1 and 20)
+            else (select max(p_size)
+                  from part
+                  where p_partkey between 10000 and 20000) end sq
+from part;
+
+select case when (select count(*)
+                  from part
+                  where p_size between 1 and 20) > 409437
+            then (select avg(p_partkey)
+                  from part
+                  where p_partkey between 1 and 20)
+            else (select max(p_size)
+                  from part
+                  where p_partkey between 10000 and 20000) end sq
+from part;
+
+
+explain select max(p_size) > ( select count(*)-1 from part) from part;
+select max(p_size) > ( select count(*)-1 from part) from part;
+
+-- corr scalar query in project and scalar query in filter
+explain select o.p_size, (select count(distinct p_type) from part p where p.p_partkey = o.p_partkey) tmp
+    FROM part o right join (select * from part where p_size > (select avg(p_size) from part)) t on t.p_partkey = o.p_partkey;
+select o.p_size, (select count(distinct p_type) from part p where p.p_partkey = o.p_partkey) tmp
+    FROM part o right join (select * from part where p_size > (select avg(p_size) from part)) t on t.p_partkey = o.p_partkey;
+
+-- multiple scalar queries in project
+explain select (select max(p_size) from part), (select min(p_size) from part),
+    (select avg(p_size) from part), (select sum(p_size) from part)
+     from part;
+select (select max(p_size) from part), (select min(p_size) from part),
+    (select avg(p_size) from part), (select sum(p_size) from part)
+     from part;
+
+-- scalar subquery with join
+explain select t1.p_size,
+    (select count(*) from part p, part pp where p.p_size = pp.p_size and p.p_type = pp.p_type)
+    from part t1;
+select t1.p_size,
+    (select count(*) from part p, part pp where p.p_size = pp.p_size and p.p_type = pp.p_type)
+    from part t1;
+
+-- scalar subquery in join and in filter
+explain select t1.p_size,
+    (select count(*) from part p, part pp where p.p_size = pp.p_size and p.p_type = pp.p_type
+                                              and (select sum(p_size) from part a1 where a1.p_partkey = p.p_partkey
+                                                                        group by a1.p_partkey) > 0)
+    from part t1;
+select t1.p_size,
+    (select count(*) from part p, part pp where p.p_size = pp.p_size and p.p_type = pp.p_type
+                                              and (select sum(p_size) from part a1 where a1.p_partkey = p.p_partkey
+                                                                        group by a1.p_partkey) > 0)
+    from part t1;
+
+-- multiple scalar queries in projecdt with scalar query in filter
+explain select t1.p_size,
+    (select count(*) from part t2 where t2.p_partkey = t1.p_partkey group by t2.p_partkey),
+    (select count(*) from part p, part pp where p.p_size = pp.p_size and p.p_type = pp.p_type
+                                              and (select sum(p_size) from part a1 where a1.p_partkey = p.p_partkey
+                                                                        group by a1.p_partkey) > 0)
+    from part t1;
+select t1.p_size,
+    (select count(*) from part t2 where t2.p_partkey = t1.p_partkey group by t2.p_partkey),
+    (select count(*) from part p, part pp where p.p_size = pp.p_size and p.p_type = pp.p_type
+                                              and (select sum(p_size) from part a1 where a1.p_partkey = p.p_partkey
+                                                                        group by a1.p_partkey) > 0)
+    from part t1;
+
+-- subquery in UDF
+explain SELECT p_size, exp((SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type)) from part;
+SELECT p_size, exp((SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type)) from part;

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/results/clientnegative/subquery_in_select.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/subquery_in_select.q.out b/ql/src/test/results/clientnegative/subquery_in_select.q.out
deleted file mode 100644
index a8e1b99..0000000
--- a/ql/src/test/results/clientnegative/subquery_in_select.q.out
+++ /dev/null
@@ -1 +0,0 @@
-FAILED: SemanticException org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException: Unsupported SubQuery Expression Invalid subquery. Subquery in SELECT could only be top-level expression

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/results/clientnegative/subquery_select_aggregate.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/subquery_select_aggregate.q.out b/ql/src/test/results/clientnegative/subquery_select_aggregate.q.out
index a8e1b99..dd28e22 100644
--- a/ql/src/test/results/clientnegative/subquery_select_aggregate.q.out
+++ b/ql/src/test/results/clientnegative/subquery_select_aggregate.q.out
@@ -1 +1 @@
-FAILED: SemanticException org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException: Unsupported SubQuery Expression Invalid subquery. Subquery in SELECT could only be top-level expression
+FAILED: SemanticException org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException: Unsupported SubQuery Expression Invalid subquery. Subquery in UDAF is not allowed.

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/results/clientnegative/subquery_select_complex_expr.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/subquery_select_complex_expr.q.out b/ql/src/test/results/clientnegative/subquery_select_complex_expr.q.out
deleted file mode 100644
index a8e1b99..0000000
--- a/ql/src/test/results/clientnegative/subquery_select_complex_expr.q.out
+++ /dev/null
@@ -1 +0,0 @@
-FAILED: SemanticException org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException: Unsupported SubQuery Expression Invalid subquery. Subquery in SELECT could only be top-level expression

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/results/clientnegative/subquery_select_no_source.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/subquery_select_no_source.q.out b/ql/src/test/results/clientnegative/subquery_select_no_source.q.out
new file mode 100644
index 0000000..37c4e57
--- /dev/null
+++ b/ql/src/test/results/clientnegative/subquery_select_no_source.q.out
@@ -0,0 +1 @@
+FAILED: CalciteSubquerySemanticException [Error 10249]: Unsupported SubQuery Expression  Currently SubQuery expressions are only allowed as Where and Having Clause predicates

http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/results/clientnegative/subquery_select_udf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/subquery_select_udf.q.out b/ql/src/test/results/clientnegative/subquery_select_udf.q.out
deleted file mode 100644
index a8e1b99..0000000
--- a/ql/src/test/results/clientnegative/subquery_select_udf.q.out
+++ /dev/null
@@ -1 +0,0 @@
-FAILED: SemanticException org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException: Unsupported SubQuery Expression Invalid subquery. Subquery in SELECT could only be top-level expression


[2/3] hive git commit: HIVE-16228 : Support subqueries in complex expression in SELECT clause (Vineet Garg via Ashutosh Chauhan)

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/ac6735a3/ql/src/test/results/clientpositive/llap/subquery_select.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/subquery_select.q.out b/ql/src/test/results/clientpositive/llap/subquery_select.q.out
index 6fb253b..8e6cd8b 100644
--- a/ql/src/test/results/clientpositive/llap/subquery_select.q.out
+++ b/ql/src/test/results/clientpositive/llap/subquery_select.q.out
@@ -685,11 +685,13 @@ STAGE PLANS:
     Tez
 #### A masked pattern was here ####
       Edges:
-        Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+        Reducer 10 <- Map 9 (SIMPLE_EDGE)
+        Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+        Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
         Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
-        Reducer 5 <- Map 4 (SIMPLE_EDGE)
-        Reducer 7 <- Map 6 (SIMPLE_EDGE)
-        Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+        Reducer 4 <- Reducer 11 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+        Reducer 6 <- Map 5 (SIMPLE_EDGE)
+        Reducer 8 <- Map 7 (SIMPLE_EDGE)
 #### A masked pattern was here ####
       Vertices:
         Map 1 
@@ -709,7 +711,27 @@ STAGE PLANS:
                       value expressions: _col1 (type: int)
             Execution mode: llap
             LLAP IO: no inputs
-        Map 4 
+        Map 5 
+            Map Operator Tree:
+                TableScan
+                  alias: p
+                  Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 1352 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      keys: p_type (type: string)
+                      mode: hash
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 7 
             Map Operator Tree:
                 TableScan
                   alias: p
@@ -731,7 +753,7 @@ STAGE PLANS:
                         value expressions: _col1 (type: int)
             Execution mode: llap
             LLAP IO: no inputs
-        Map 6 
+        Map 9 
             Map Operator Tree:
                 TableScan
                   alias: p
@@ -753,6 +775,50 @@ STAGE PLANS:
                         value expressions: _col1 (type: int)
             Execution mode: llap
             LLAP IO: no inputs
+        Reducer 10 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: max(VALUE._col0)
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  keys: _col0 (type: string), _col1 (type: int)
+                  mode: hash
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: _col0 (type: string), _col1 (type: int)
+                    sort order: ++
+                    Map-reduce partition columns: _col0 (type: string), _col1 (type: int)
+                    Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
+        Reducer 11 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                keys: KEY._col0 (type: string), KEY._col1 (type: int)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col1 (type: int), _col0 (type: string)
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (_col0 = _col0) (type: boolean)
+                    Statistics: Num rows: 1 Data size: 108 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: _col0 (type: int), _col1 (type: string), true (type: boolean)
+                      outputColumnNames: _col0, _col1, _col2
+                      Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col1 (type: string), _col0 (type: int)
+                        sort order: ++
+                        Map-reduce partition columns: _col1 (type: string), _col0 (type: int)
+                        Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col2 (type: boolean)
         Reducer 2 
             Execution mode: llap
             Reduce Operator Tree:
@@ -762,15 +828,39 @@ STAGE PLANS:
                 keys:
                   0 _col0 (type: string)
                   1 _col0 (type: string)
-                outputColumnNames: _col0, _col1, _col3, _col4
-                Statistics: Num rows: 26 Data size: 3224 Basic stats: COMPLETE Column stats: COMPLETE
+                outputColumnNames: _col0, _col1, _col3
+                Statistics: Num rows: 26 Data size: 3016 Basic stats: COMPLETE Column stats: COMPLETE
+                Filter Operator
+                  predicate: (sq_count_check(_col3, true) > 0) (type: boolean)
+                  Statistics: Num rows: 8 Data size: 928 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: _col0 (type: string), _col1 (type: int)
+                    outputColumnNames: _col0, _col1
+                    Statistics: Num rows: 8 Data size: 928 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: string)
+                      sort order: +
+                      Map-reduce partition columns: _col0 (type: string)
+                      Statistics: Num rows: 8 Data size: 928 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col1 (type: int)
+        Reducer 3 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Left Outer Join0 to 1
+                keys:
+                  0 _col0 (type: string)
+                  1 _col0 (type: string)
+                outputColumnNames: _col0, _col1, _col5, _col6
+                Statistics: Num rows: 8 Data size: 992 Basic stats: COMPLETE Column stats: COMPLETE
                 Reduce Output Operator
                   key expressions: _col0 (type: string), _col1 (type: int)
                   sort order: ++
                   Map-reduce partition columns: _col0 (type: string), _col1 (type: int)
-                  Statistics: Num rows: 26 Data size: 3224 Basic stats: COMPLETE Column stats: COMPLETE
-                  value expressions: _col3 (type: bigint), _col4 (type: bigint)
-        Reducer 3 
+                  Statistics: Num rows: 8 Data size: 992 Basic stats: COMPLETE Column stats: COMPLETE
+                  value expressions: _col5 (type: bigint), _col6 (type: bigint)
+        Reducer 4 
             Execution mode: llap
             Reduce Operator Tree:
               Merge Join Operator
@@ -779,41 +869,40 @@ STAGE PLANS:
                 keys:
                   0 _col0 (type: string), _col1 (type: int)
                   1 _col1 (type: string), _col0 (type: int)
-                outputColumnNames: _col1, _col3, _col4, _col7
-                Statistics: Num rows: 26 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+                outputColumnNames: _col1, _col5, _col6, _col9
+                Statistics: Num rows: 8 Data size: 192 Basic stats: COMPLETE Column stats: COMPLETE
                 Select Operator
-                  expressions: _col1 (type: int), CASE WHEN ((_col3 = 0)) THEN (true) WHEN (_col3 is null) THEN (true) WHEN (_col7 is not null) THEN (false) WHEN (_col1 is null) THEN (null) WHEN ((_col4 < _col3)) THEN (null) ELSE (true) END (type: boolean)
+                  expressions: _col1 (type: int), CASE WHEN ((_col5 = 0)) THEN (true) WHEN (_col5 is null) THEN (true) WHEN (_col9 is not null) THEN (false) WHEN (_col1 is null) THEN (null) WHEN ((_col6 < _col5)) THEN (null) ELSE (true) END (type: boolean)
                   outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 26 Data size: 208 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 8 Data size: 64 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 26 Data size: 208 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 8 Data size: 64 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                         serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
-        Reducer 5 
+        Reducer 6 
             Execution mode: llap
             Reduce Operator Tree:
               Group By Operator
-                aggregations: max(VALUE._col0)
                 keys: KEY._col0 (type: string)
                 mode: mergepartial
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                outputColumnNames: _col0
+                Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
                 Group By Operator
-                  aggregations: count(), count(_col1)
+                  aggregations: count()
                   keys: _col0 (type: string)
                   mode: complete
-                  outputColumnNames: _col0, _col1, _col2
-                  Statistics: Num rows: 6 Data size: 720 Basic stats: COMPLETE Column stats: COMPLETE
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
                     key expressions: _col0 (type: string)
                     sort order: +
                     Map-reduce partition columns: _col0 (type: string)
-                    Statistics: Num rows: 6 Data size: 720 Basic stats: COMPLETE Column stats: COMPLETE
-                    value expressions: _col1 (type: bigint), _col2 (type: bigint)
-        Reducer 7 
+                    Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col1 (type: bigint)
+        Reducer 8 
             Execution mode: llap
             Reduce Operator Tree:
               Group By Operator
@@ -823,40 +912,17 @@ STAGE PLANS:
                 outputColumnNames: _col0, _col1
                 Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
                 Group By Operator
-                  keys: _col0 (type: string), _col1 (type: int)
-                  mode: hash
-                  outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
+                  aggregations: count(), count(_col1)
+                  keys: _col0 (type: string)
+                  mode: complete
+                  outputColumnNames: _col0, _col1, _col2
+                  Statistics: Num rows: 6 Data size: 720 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
-                    key expressions: _col0 (type: string), _col1 (type: int)
-                    sort order: ++
-                    Map-reduce partition columns: _col0 (type: string), _col1 (type: int)
-                    Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
-        Reducer 8 
-            Execution mode: llap
-            Reduce Operator Tree:
-              Group By Operator
-                keys: KEY._col0 (type: string), KEY._col1 (type: int)
-                mode: mergepartial
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
-                Select Operator
-                  expressions: _col1 (type: int), _col0 (type: string)
-                  outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
-                  Filter Operator
-                    predicate: (_col0 = _col0) (type: boolean)
-                    Statistics: Num rows: 1 Data size: 108 Basic stats: COMPLETE Column stats: COMPLETE
-                    Select Operator
-                      expressions: _col0 (type: int), _col1 (type: string), true (type: boolean)
-                      outputColumnNames: _col0, _col1, _col2
-                      Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                      Reduce Output Operator
-                        key expressions: _col1 (type: string), _col0 (type: int)
-                        sort order: ++
-                        Map-reduce partition columns: _col1 (type: string), _col0 (type: int)
-                        Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                        value expressions: _col2 (type: boolean)
+                    key expressions: _col0 (type: string)
+                    sort order: +
+                    Map-reduce partition columns: _col0 (type: string)
+                    Statistics: Num rows: 6 Data size: 720 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col1 (type: bigint), _col2 (type: bigint)
 
   Stage: Stage-0
     Fetch Operator
@@ -1444,11 +1510,9 @@ POSTHOOK: Input: default@part
 6	false
 18	false
 45	false
-PREHOOK: query: explain SELECT p_size, (SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type)
-FROM part
+PREHOOK: query: explain select p_size, (select count(p_name) from part p where p.p_type = part.p_name) from part
 PREHOOK: type: QUERY
-POSTHOOK: query: explain SELECT p_size, (SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type)
-FROM part
+POSTHOOK: query: explain select p_size, (select count(p_name) from part p where p.p_type = part.p_name) from part
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -1468,16 +1532,16 @@ STAGE PLANS:
             Map Operator Tree:
                 TableScan
                   alias: part
-                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 26 Data size: 3250 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: p_type (type: string), p_size (type: int)
+                    expressions: p_name (type: string), p_size (type: int)
                     outputColumnNames: _col0, _col1
-                    Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 26 Data size: 3250 Basic stats: COMPLETE Column stats: COMPLETE
                     Reduce Output Operator
                       key expressions: _col0 (type: string)
                       sort order: +
                       Map-reduce partition columns: _col0 (type: string)
-                      Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                      Statistics: Num rows: 26 Data size: 3250 Basic stats: COMPLETE Column stats: COMPLETE
                       value expressions: _col1 (type: int)
             Execution mode: llap
             LLAP IO: no inputs
@@ -1505,22 +1569,26 @@ STAGE PLANS:
             Map Operator Tree:
                 TableScan
                   alias: p
-                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 26 Data size: 5850 Basic stats: COMPLETE Column stats: COMPLETE
                   Filter Operator
                     predicate: (p_type = p_type) (type: boolean)
-                    Statistics: Num rows: 13 Data size: 1404 Basic stats: COMPLETE Column stats: COMPLETE
-                    Group By Operator
-                      aggregations: max(p_size)
-                      keys: p_type (type: string)
-                      mode: hash
-                      outputColumnNames: _col0, _col1
-                      Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
-                      Reduce Output Operator
-                        key expressions: _col0 (type: string)
-                        sort order: +
-                        Map-reduce partition columns: _col0 (type: string)
-                        Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
-                        value expressions: _col1 (type: int)
+                    Statistics: Num rows: 13 Data size: 2925 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: p_type (type: string), p_name (type: string)
+                      outputColumnNames: p_type, p_name
+                      Statistics: Num rows: 13 Data size: 2925 Basic stats: COMPLETE Column stats: COMPLETE
+                      Group By Operator
+                        aggregations: count(p_name)
+                        keys: p_type (type: string)
+                        mode: hash
+                        outputColumnNames: _col0, _col1
+                        Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: string)
+                          sort order: +
+                          Map-reduce partition columns: _col0 (type: string)
+                          Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                          value expressions: _col1 (type: bigint)
             Execution mode: llap
             LLAP IO: no inputs
         Reducer 2 
@@ -1533,16 +1601,16 @@ STAGE PLANS:
                 keys:
                   0 _col0 (type: string)
                   1 _col0 (type: string)
-                  2 _col1 (type: string)
-                outputColumnNames: _col1, _col4
-                Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  2 _col2 (type: string)
+                outputColumnNames: _col1, _col4, _col5
+                Statistics: Num rows: 1 Data size: 16 Basic stats: COMPLETE Column stats: COMPLETE
                 Select Operator
-                  expressions: _col1 (type: int), _col4 (type: int)
+                  expressions: _col1 (type: int), CASE WHEN (_col5 is null) THEN (0) ELSE (_col4) END (type: bigint)
                   outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 1 Data size: 12 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 1 Data size: 12 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -1577,21 +1645,21 @@ STAGE PLANS:
             Execution mode: llap
             Reduce Operator Tree:
               Group By Operator
-                aggregations: max(VALUE._col0)
+                aggregations: count(VALUE._col0)
                 keys: KEY._col0 (type: string)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
                 Select Operator
-                  expressions: _col1 (type: int), _col0 (type: string)
-                  outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                  expressions: _col1 (type: bigint), true (type: boolean), _col0 (type: string)
+                  outputColumnNames: _col0, _col1, _col2
+                  Statistics: Num rows: 6 Data size: 696 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
-                    key expressions: _col1 (type: string)
+                    key expressions: _col2 (type: string)
                     sort order: +
-                    Map-reduce partition columns: _col1 (type: string)
-                    Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
-                    value expressions: _col0 (type: int)
+                    Map-reduce partition columns: _col2 (type: string)
+                    Statistics: Num rows: 6 Data size: 696 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: bigint), _col1 (type: boolean)
 
   Stage: Stage-0
     Fetch Operator
@@ -1599,49 +1667,43 @@ STAGE PLANS:
       Processor Tree:
         ListSink
 
-PREHOOK: query: SELECT p_size, (SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type)
-FROM part
+PREHOOK: query: select p_size, (select count(p_name) from part p where p.p_type = part.p_name) from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
-POSTHOOK: query: SELECT p_size, (SELECT max(p_size) FROM part p WHERE p.p_type = part.p_type)
-FROM part
+POSTHOOK: query: select p_size, (select count(p_name) from part p where p.p_type = part.p_name) from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-7	7
-46	46
-1	1
-40	40
-23	23
-34	34
-42	42
-14	14
-19	19
-2	2
-17	31
-31	31
-14	14
-6	6
-2	2
-2	2
-39	39
-10	10
-2	2
-27	27
-25	25
-28	28
-12	12
-6	6
-18	18
-45	45
-Warning: Shuffle Join MERGEJOIN[30][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
-Warning: Shuffle Join MERGEJOIN[31][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 3' is a cross product
-PREHOOK: query: explain SELECT p_size, (SELECT max(p_size) FROM part)
-    FROM part
+31	0
+2	0
+2	0
+17	0
+34	0
+14	0
+10	0
+6	0
+19	0
+1	0
+45	0
+6	0
+2	0
+14	0
+39	0
+40	0
+28	0
+46	0
+27	0
+2	0
+42	0
+25	0
+18	0
+7	0
+12	0
+23	0
+PREHOOK: query: explain select p_size, (select max(p_name) from part p where p.p_type = part.p_name) from part
 PREHOOK: type: QUERY
-POSTHOOK: query: explain SELECT p_size, (SELECT max(p_size) FROM part)
-    FROM part
+POSTHOOK: query: explain select p_size, (select max(p_name) from part p where p.p_type = part.p_name) from part
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -1652,28 +1714,223 @@ STAGE PLANS:
     Tez
 #### A masked pattern was here ####
       Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE), Reducer 5 (CUSTOM_SIMPLE_EDGE)
-        Reducer 3 <- Reducer 2 (CUSTOM_SIMPLE_EDGE), Reducer 7 (CUSTOM_SIMPLE_EDGE)
-        Reducer 5 <- Map 4 (CUSTOM_SIMPLE_EDGE)
-        Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+        Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+        Reducer 4 <- Map 3 (SIMPLE_EDGE)
+        Reducer 6 <- Map 5 (SIMPLE_EDGE)
 #### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
                 TableScan
                   alias: part
-                  Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 26 Data size: 3250 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: p_size (type: int)
-                    outputColumnNames: _col0
-                    Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                    expressions: p_name (type: string), p_size (type: int)
+                    outputColumnNames: _col0, _col1
+                    Statistics: Num rows: 26 Data size: 3250 Basic stats: COMPLETE Column stats: COMPLETE
                     Reduce Output Operator
-                      sort order: 
-                      Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
-                      value expressions: _col0 (type: int)
+                      key expressions: _col0 (type: string)
+                      sort order: +
+                      Map-reduce partition columns: _col0 (type: string)
+                      Statistics: Num rows: 26 Data size: 3250 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col1 (type: int)
             Execution mode: llap
             LLAP IO: no inputs
-        Map 4 
+        Map 3 
+            Map Operator Tree:
+                TableScan
+                  alias: p
+                  Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 1352 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      keys: p_type (type: string)
+                      mode: hash
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 5 
+            Map Operator Tree:
+                TableScan
+                  alias: p
+                  Statistics: Num rows: 26 Data size: 5850 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 2925 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: p_type (type: string), p_name (type: string)
+                      outputColumnNames: p_type, p_name
+                      Statistics: Num rows: 13 Data size: 2925 Basic stats: COMPLETE Column stats: COMPLETE
+                      Group By Operator
+                        aggregations: max(p_name)
+                        keys: p_type (type: string)
+                        mode: hash
+                        outputColumnNames: _col0, _col1
+                        Statistics: Num rows: 6 Data size: 1728 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: string)
+                          sort order: +
+                          Map-reduce partition columns: _col0 (type: string)
+                          Statistics: Num rows: 6 Data size: 1728 Basic stats: COMPLETE Column stats: COMPLETE
+                          value expressions: _col1 (type: string)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Left Outer Join0 to 1
+                     Left Outer Join0 to 2
+                keys:
+                  0 _col0 (type: string)
+                  1 _col0 (type: string)
+                  2 _col2 (type: string)
+                outputColumnNames: _col1, _col4, _col5
+                Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col1 (type: int), CASE WHEN (_col5 is null) THEN (null) ELSE (_col4) END (type: string)
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 1 Data size: 188 Basic stats: COMPLETE Column stats: COMPLETE
+                  File Output Operator
+                    compressed: false
+                    Statistics: Num rows: 1 Data size: 188 Basic stats: COMPLETE Column stats: COMPLETE
+                    table:
+                        input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                        output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+        Reducer 4 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  aggregations: count()
+                  keys: _col0 (type: string)
+                  mode: complete
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (sq_count_check(_col1) <= 1) (type: boolean)
+                    Statistics: Num rows: 2 Data size: 224 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: _col0 (type: string)
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 2 Data size: 224 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 2 Data size: 224 Basic stats: COMPLETE Column stats: COMPLETE
+        Reducer 6 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: max(VALUE._col0)
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 6 Data size: 1728 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col1 (type: string), true (type: boolean), _col0 (type: string)
+                  outputColumnNames: _col0, _col1, _col2
+                  Statistics: Num rows: 6 Data size: 1752 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: _col2 (type: string)
+                    sort order: +
+                    Map-reduce partition columns: _col2 (type: string)
+                    Statistics: Num rows: 6 Data size: 1752 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: string), _col1 (type: boolean)
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select p_size, (select max(p_name) from part p where p.p_type = part.p_name) from part
+PREHOOK: type: QUERY
+PREHOOK: Input: default@part
+#### A masked pattern was here ####
+POSTHOOK: query: select p_size, (select max(p_name) from part p where p.p_type = part.p_name) from part
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@part
+#### A masked pattern was here ####
+31	NULL
+2	NULL
+2	NULL
+17	NULL
+34	NULL
+14	NULL
+10	NULL
+6	NULL
+19	NULL
+1	NULL
+45	NULL
+6	NULL
+2	NULL
+14	NULL
+39	NULL
+40	NULL
+28	NULL
+46	NULL
+27	NULL
+2	NULL
+42	NULL
+25	NULL
+18	NULL
+7	NULL
+12	NULL
+23	NULL
+Warning: Shuffle Join MERGEJOIN[30][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
+Warning: Shuffle Join MERGEJOIN[31][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 3' is a cross product
+PREHOOK: query: explain SELECT p_size, (SELECT max(p_size) FROM part)
+    FROM part
+PREHOOK: type: QUERY
+POSTHOOK: query: explain SELECT p_size, (SELECT max(p_size) FROM part)
+    FROM part
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE), Reducer 5 (CUSTOM_SIMPLE_EDGE)
+        Reducer 3 <- Reducer 2 (CUSTOM_SIMPLE_EDGE), Reducer 7 (CUSTOM_SIMPLE_EDGE)
+        Reducer 5 <- Map 4 (CUSTOM_SIMPLE_EDGE)
+        Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_size (type: int)
+                    outputColumnNames: _col0
+                    Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      sort order: 
+                      Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col0 (type: int)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 4 
             Map Operator Tree:
                 TableScan
                   alias: part
@@ -2105,11 +2362,10 @@ STAGE PLANS:
     Tez
 #### A masked pattern was here ####
       Edges:
-        Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
-        Reducer 4 <- Map 3 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
-        Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
-        Reducer 7 <- Map 6 (SIMPLE_EDGE)
-        Reducer 9 <- Map 8 (SIMPLE_EDGE)
+        Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+        Reducer 4 <- Map 3 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+        Reducer 6 <- Map 5 (SIMPLE_EDGE)
+        Reducer 8 <- Map 7 (SIMPLE_EDGE)
 #### A masked pattern was here ####
       Vertices:
         Map 1 
@@ -2147,7 +2403,7 @@ STAGE PLANS:
                         Statistics: Num rows: 83 Data size: 14774 Basic stats: COMPLETE Column stats: COMPLETE
             Execution mode: llap
             LLAP IO: no inputs
-        Map 6 
+        Map 5 
             Map Operator Tree:
                 TableScan
                   alias: sc
@@ -2167,7 +2423,7 @@ STAGE PLANS:
                         Statistics: Num rows: 107 Data size: 9737 Basic stats: COMPLETE Column stats: COMPLETE
             Execution mode: llap
             LLAP IO: no inputs
-        Map 8 
+        Map 7 
             Map Operator Tree:
                 TableScan
                   alias: sc
@@ -2198,7 +2454,7 @@ STAGE PLANS:
             Reduce Operator Tree:
               Merge Join Operator
                 condition map:
-                     Inner Join 0 to 1
+                     Left Semi Join 0 to 1
                 keys:
                   0 _col0 (type: string), _col1 (type: string)
                   1 _col0 (type: string), _col1 (type: string)
@@ -2221,15 +2477,15 @@ STAGE PLANS:
                 keys:
                   0 _col1 (type: string)
                   1 _col0 (type: string)
-                  2 _col1 (type: string)
-                outputColumnNames: _col1, _col4
-                Statistics: Num rows: 80 Data size: 22000 Basic stats: COMPLETE Column stats: COMPLETE
+                  2 _col2 (type: string)
+                outputColumnNames: _col1, _col4, _col5
+                Statistics: Num rows: 80 Data size: 22320 Basic stats: COMPLETE Column stats: COMPLETE
                 Select Operator
-                  expressions: _col4 (type: string), _col1 (type: string)
-                  outputColumnNames: _col4, _col1
+                  expressions: CASE WHEN (_col5 is null) THEN (null) ELSE (_col4) END (type: string), _col1 (type: string)
+                  outputColumnNames: _col0, _col1
                   Statistics: Num rows: 80 Data size: 22000 Basic stats: COMPLETE Column stats: COMPLETE
                   Group By Operator
-                    keys: _col4 (type: string), _col1 (type: string)
+                    keys: _col0 (type: string), _col1 (type: string)
                     mode: hash
                     outputColumnNames: _col0, _col1
                     Statistics: Num rows: 40 Data size: 11000 Basic stats: COMPLETE Column stats: COMPLETE
@@ -2238,20 +2494,7 @@ STAGE PLANS:
                       sort order: ++
                       Map-reduce partition columns: _col0 (type: string), _col1 (type: string)
                       Statistics: Num rows: 40 Data size: 11000 Basic stats: COMPLETE Column stats: COMPLETE
-        Reducer 5 
-            Execution mode: llap
-            Reduce Operator Tree:
-              Group By Operator
-                keys: KEY._col0 (type: string), KEY._col1 (type: string)
-                mode: mergepartial
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 40 Data size: 11000 Basic stats: COMPLETE Column stats: COMPLETE
-                Reduce Output Operator
-                  key expressions: _col0 (type: string), _col1 (type: string)
-                  sort order: ++
-                  Map-reduce partition columns: _col0 (type: string), _col1 (type: string)
-                  Statistics: Num rows: 40 Data size: 11000 Basic stats: COMPLETE Column stats: COMPLETE
-        Reducer 7 
+        Reducer 6 
             Execution mode: llap
             Reduce Operator Tree:
               Group By Operator
@@ -2277,7 +2520,7 @@ STAGE PLANS:
                         sort order: +
                         Map-reduce partition columns: _col0 (type: string)
                         Statistics: Num rows: 35 Data size: 3465 Basic stats: COMPLETE Column stats: COMPLETE
-        Reducer 9 
+        Reducer 8 
             Execution mode: llap
             Reduce Operator Tree:
               Group By Operator
@@ -2287,15 +2530,15 @@ STAGE PLANS:
                 outputColumnNames: _col0, _col1
                 Statistics: Num rows: 107 Data size: 29425 Basic stats: COMPLETE Column stats: COMPLETE
                 Select Operator
-                  expressions: _col1 (type: string), _col0 (type: string)
-                  outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 107 Data size: 29425 Basic stats: COMPLETE Column stats: COMPLETE
+                  expressions: _col1 (type: string), true (type: boolean), _col0 (type: string)
+                  outputColumnNames: _col0, _col1, _col2
+                  Statistics: Num rows: 107 Data size: 29853 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
-                    key expressions: _col1 (type: string)
+                    key expressions: _col2 (type: string)
                     sort order: +
-                    Map-reduce partition columns: _col1 (type: string)
-                    Statistics: Num rows: 107 Data size: 29425 Basic stats: COMPLETE Column stats: COMPLETE
-                    value expressions: _col0 (type: string)
+                    Map-reduce partition columns: _col2 (type: string)
+                    Statistics: Num rows: 107 Data size: 29853 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: string), _col1 (type: boolean)
 
   Stage: Stage-0
     Fetch Operator
@@ -2940,3 +3183,4625 @@ POSTHOOK: query: DROP table tnull
 POSTHOOK: type: DROPTABLE
 POSTHOOK: Input: default@tnull
 POSTHOOK: Output: default@tnull
+PREHOOK: query: explain SELECT p_size, 1+(SELECT max(p_size) FROM part p
+    WHERE p.p_type = part.p_type) from part
+PREHOOK: type: QUERY
+POSTHOOK: query: explain SELECT p_size, 1+(SELECT max(p_size) FROM part p
+    WHERE p.p_type = part.p_type) from part
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+        Reducer 4 <- Map 3 (SIMPLE_EDGE)
+        Reducer 6 <- Map 5 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_type (type: string), p_size (type: int)
+                    outputColumnNames: _col0, _col1
+                    Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: string)
+                      sort order: +
+                      Map-reduce partition columns: _col0 (type: string)
+                      Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col1 (type: int)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 3 
+            Map Operator Tree:
+                TableScan
+                  alias: p
+                  Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 1352 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      keys: p_type (type: string)
+                      mode: hash
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 5 
+            Map Operator Tree:
+                TableScan
+                  alias: p
+                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 1404 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: max(p_size)
+                      keys: p_type (type: string)
+                      mode: hash
+                      outputColumnNames: _col0, _col1
+                      Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col1 (type: int)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Left Outer Join0 to 1
+                     Left Outer Join0 to 2
+                keys:
+                  0 _col0 (type: string)
+                  1 _col0 (type: string)
+                  2 _col2 (type: string)
+                outputColumnNames: _col1, _col4, _col5
+                Statistics: Num rows: 1 Data size: 12 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col1 (type: int), (1 + CASE WHEN (_col5 is null) THEN (null) ELSE (_col4) END) (type: int)
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  File Output Operator
+                    compressed: false
+                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    table:
+                        input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                        output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+        Reducer 4 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  aggregations: count()
+                  keys: _col0 (type: string)
+                  mode: complete
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (sq_count_check(_col1) <= 1) (type: boolean)
+                    Statistics: Num rows: 2 Data size: 224 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: _col0 (type: string)
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 2 Data size: 224 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 2 Data size: 224 Basic stats: COMPLETE Column stats: COMPLETE
+        Reducer 6 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: max(VALUE._col0)
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col1 (type: int), true (type: boolean), _col0 (type: string)
+                  outputColumnNames: _col0, _col1, _col2
+                  Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: _col2 (type: string)
+                    sort order: +
+                    Map-reduce partition columns: _col2 (type: string)
+                    Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: int), _col1 (type: boolean)
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: SELECT p_size, 1+(SELECT max(p_size) FROM part p
+    WHERE p.p_type = part.p_type) from part
+PREHOOK: type: QUERY
+PREHOOK: Input: default@part
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT p_size, 1+(SELECT max(p_size) FROM part p
+    WHERE p.p_type = part.p_type) from part
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@part
+#### A masked pattern was here ####
+7	8
+46	47
+1	2
+40	41
+23	24
+34	35
+42	43
+14	15
+19	20
+2	3
+17	32
+31	32
+14	15
+6	7
+2	3
+2	3
+39	40
+10	11
+2	3
+27	28
+25	26
+28	29
+12	13
+6	7
+18	19
+45	46
+PREHOOK: query: explain SELECT p_size, (SELECT count(p_size) FROM part p
+    WHERE p.p_type = part.p_type) IS NULL from part
+PREHOOK: type: QUERY
+POSTHOOK: query: explain SELECT p_size, (SELECT count(p_size) FROM part p
+    WHERE p.p_type = part.p_type) IS NULL from part
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+        Reducer 4 <- Map 3 (SIMPLE_EDGE)
+        Reducer 6 <- Map 5 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_type (type: string), p_size (type: int)
+                    outputColumnNames: _col0, _col1
+                    Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: string)
+                      sort order: +
+                      Map-reduce partition columns: _col0 (type: string)
+                      Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col1 (type: int)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 3 
+            Map Operator Tree:
+                TableScan
+                  alias: p
+                  Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 1352 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      keys: p_type (type: string)
+                      mode: hash
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 5 
+            Map Operator Tree:
+                TableScan
+                  alias: p
+                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 1404 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: count(p_size)
+                      keys: p_type (type: string)
+                      mode: hash
+                      outputColumnNames: _col0, _col1
+                      Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col1 (type: bigint)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Left Outer Join0 to 1
+                     Left Outer Join0 to 2
+                keys:
+                  0 _col0 (type: string)
+                  1 _col0 (type: string)
+                  2 _col2 (type: string)
+                outputColumnNames: _col1, _col4, _col5
+                Statistics: Num rows: 1 Data size: 16 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col1 (type: int), CASE WHEN (_col5 is null) THEN (false) ELSE (_col4 is null) END (type: boolean)
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  File Output Operator
+                    compressed: false
+                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    table:
+                        input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                        output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+        Reducer 4 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  aggregations: count()
+                  keys: _col0 (type: string)
+                  mode: complete
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (sq_count_check(_col1) <= 1) (type: boolean)
+                    Statistics: Num rows: 2 Data size: 224 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: _col0 (type: string)
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 2 Data size: 224 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 2 Data size: 224 Basic stats: COMPLETE Column stats: COMPLETE
+        Reducer 6 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 6 Data size: 672 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col1 (type: bigint), true (type: boolean), _col0 (type: string)
+                  outputColumnNames: _col0, _col1, _col2
+                  Statistics: Num rows: 6 Data size: 696 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: _col2 (type: string)
+                    sort order: +
+                    Map-reduce partition columns: _col2 (type: string)
+                    Statistics: Num rows: 6 Data size: 696 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: bigint), _col1 (type: boolean)
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: SELECT p_size, (SELECT count(p_size) FROM part p
+    WHERE p.p_type = part.p_type) IS NULL from part
+PREHOOK: type: QUERY
+PREHOOK: Input: default@part
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT p_size, (SELECT count(p_size) FROM part p
+    WHERE p.p_type = part.p_type) IS NULL from part
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@part
+#### A masked pattern was here ####
+7	false
+46	false
+1	false
+40	false
+23	false
+34	false
+42	false
+14	false
+19	false
+2	false
+17	false
+31	false
+14	false
+6	false
+2	false
+2	false
+39	false
+10	false
+2	false
+27	false
+25	false
+28	false
+12	false
+6	false
+18	false
+45	false
+Warning: Shuffle Join MERGEJOIN[29][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
+Warning: Shuffle Join MERGEJOIN[30][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 3' is a cross product
+PREHOOK: query: explain select p_type, (select p_size from part order by p_size limit 1) = 1 from part
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select p_type, (select p_size from part order by p_size limit 1) = 1 from part
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE), Reducer 6 (CUSTOM_SIMPLE_EDGE)
+        Reducer 3 <- Reducer 2 (CUSTOM_SIMPLE_EDGE), Reducer 8 (CUSTOM_SIMPLE_EDGE)
+        Reducer 5 <- Map 4 (SIMPLE_EDGE)
+        Reducer 6 <- Reducer 5 (CUSTOM_SIMPLE_EDGE)
+        Reducer 8 <- Map 7 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_type (type: string)
+                    outputColumnNames: _col0
+                    Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      sort order: 
+                      Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col0 (type: string)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 4 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_size (type: int)
+                    outputColumnNames: _col0
+                    Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: int)
+                      sort order: +
+                      Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 7 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_size (type: int)
+                    outputColumnNames: _col0
+                    Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: int)
+                      sort order: +
+                      Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                      TopN Hash Memory Usage: 0.1
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Inner Join 0 to 1
+                keys:
+                  0 
+                  1 
+                outputColumnNames: _col0
+                Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                Reduce Output Operator
+                  sort order: 
+                  Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                  value expressions: _col0 (type: string)
+        Reducer 3 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Left Outer Join0 to 1
+                keys:
+                  0 
+                  1 
+                outputColumnNames: _col0, _col2
+                Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col0 (type: string), (_col2 = 1) (type: boolean)
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  File Output Operator
+                    compressed: false
+                    Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                    table:
+                        input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                        output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+        Reducer 5 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Select Operator
+                Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                Limit
+                  Number of rows: 1
+                  Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+                  Group By Operator
+                    aggregations: count()
+                    mode: hash
+                    outputColumnNames: _col0
+                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      sort order: 
+                      Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col0 (type: bigint)
+        Reducer 6 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Filter Operator
+                  predicate: (sq_count_check(_col0) <= 1) (type: boolean)
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      sort order: 
+                      Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+        Reducer 8 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Select Operator
+                expressions: KEY.reducesinkkey0 (type: int)
+                outputColumnNames: _col0
+                Statistics: Num rows: 26 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+                Limit
+                  Number of rows: 1
+                  Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    sort order: 
+                    Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: int)
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+Warning: Shuffle Join MERGEJOIN[29][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
+Warning: Shuffle Join MERGEJOIN[30][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 3' is a cross product
+PREHOOK: query: select p_type, (select p_size from part order by p_size limit 1) = 1 from part
+PREHOOK: type: QUERY
+PREHOOK: Input: default@part
+#### A masked pattern was here ####
+POSTHOOK: query: select p_type, (select p_size from part order by p_size limit 1) = 1 from part
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@part
+#### A masked pattern was here ####
+PROMO PLATED TIN	true
+PROMO PLATED TIN	true
+LARGE BRUSHED STEEL	true
+PROMO BURNISHED NICKEL	true
+STANDARD ANODIZED STEEL	true
+LARGE BURNISHED STEEL	true
+MEDIUM ANODIZED COPPER	true
+ECONOMY POLISHED STEEL	true
+MEDIUM BURNISHED COPPER	true
+SMALL POLISHED NICKEL	true
+STANDARD PLATED TIN	true
+MEDIUM BURNISHED TIN	true
+PROMO ANODIZED TIN	true
+MEDIUM BURNISHED BRASS	true
+ECONOMY PLATED COPPER	true
+STANDARD POLISHED STEEL	true
+SMALL BRUSHED BRASS	true
+PROMO POLISHED STEEL	true
+SMALL PLATED STEEL	true
+ECONOMY BRUSHED COPPER	true
+STANDARD ANODIZED TIN	true
+MEDIUM BURNISHED TIN	true
+STANDARD BURNISHED TIN	true
+SMALL PLATED BRASS	true
+ECONOMY BURNISHED STEEL	true
+LARGE BRUSHED BRASS	true
+Warning: Shuffle Join MERGEJOIN[74][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 4' is a cross product
+PREHOOK: query: EXPLAIN SELECT p_size, p_size IN (
+        SELECT MAX(p_size) FROM part p where p.p_type = part.p_type) AND
+        p_name IN (SELECT min(p_name) from part)
+FROM part
+PREHOOK: type: QUERY
+POSTHOOK: query: EXPLAIN SELECT p_size, p_size IN (
+        SELECT MAX(p_size) FROM part p where p.p_type = part.p_type) AND
+        p_name IN (SELECT min(p_name) from part)
+FROM part
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+        Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+        Reducer 14 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+        Reducer 15 <- Reducer 14 (SIMPLE_EDGE)
+        Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+        Reducer 3 <- Reducer 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+        Reducer 4 <- Reducer 12 (CUSTOM_SIMPLE_EDGE), Reducer 3 (CUSTOM_SIMPLE_EDGE)
+        Reducer 5 <- Reducer 15 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+        Reducer 7 <- Map 6 (SIMPLE_EDGE)
+        Reducer 9 <- Map 8 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 5954 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_name (type: string), p_type (type: string), p_size (type: int)
+                    outputColumnNames: _col0, _col1, _col2
+                    Statistics: Num rows: 26 Data size: 5954 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      key expressions: _col1 (type: string)
+                      sort order: +
+                      Map-reduce partition columns: _col1 (type: string)
+                      Statistics: Num rows: 26 Data size: 5954 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col0 (type: string), _col2 (type: int)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 11 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 3146 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_name (type: string)
+                    outputColumnNames: p_name
+                    Statistics: Num rows: 26 Data size: 3146 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: min(p_name)
+                      mode: hash
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 1 Data size: 184 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        sort order: 
+                        Statistics: Num rows: 1 Data size: 184 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col0 (type: string)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 13 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 3146 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_name (type: string)
+                    outputColumnNames: p_name
+                    Statistics: Num rows: 26 Data size: 3146 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: min(p_name)
+                      mode: hash
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 1 Data size: 184 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        sort order: 
+                        Statistics: Num rows: 1 Data size: 184 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col0 (type: string)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 6 
+            Map Operator Tree:
+                TableScan
+                  alias: p
+                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 1404 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: max(p_size)
+                      keys: p_type (type: string)
+                      mode: hash
+                      outputColumnNames: _col0, _col1
+                      Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col1 (type: int)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 8 
+            Map Operator Tree:
+                TableScan
+                  alias: p
+                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 1404 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: max(p_size)
+                      keys: p_type (type: string)
+                      mode: hash
+                      outputColumnNames: _col0, _col1
+                      Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col1 (type: int)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 10 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                keys: KEY._col0 (type: string), KEY._col1 (type: int)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col1 (type: int), _col0 (type: string)
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (_col0 = _col0) (type: boolean)
+                    Statistics: Num rows: 1 Data size: 108 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: _col0 (type: int), _col1 (type: string), true (type: boolean)
+                      outputColumnNames: _col0, _col1, _col2
+                      Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col1 (type: string), _col0 (type: int)
+                        sort order: ++
+                        Map-reduce partition columns: _col1 (type: string), _col0 (type: int)
+                        Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col2 (type: boolean)
+        Reducer 12 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: min(VALUE._col0)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 184 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  aggregations: count(), count(_col0)
+                  mode: complete
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 1 Data size: 16 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    sort order: 
+                    Statistics: Num rows: 1 Data size: 16 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: bigint), _col1 (type: bigint)
+        Reducer 14 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: min(VALUE._col0)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 184 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  keys: _col0 (type: string)
+                  mode: hash
+                  outputColumnNames: _col0
+                  Statistics: Num rows: 1 Data size: 184 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: _col0 (type: string)
+                    sort order: +
+                    Map-reduce partition columns: _col0 (type: string)
+                    Statistics: Num rows: 1 Data size: 184 Basic stats: COMPLETE Column stats: COMPLETE
+        Reducer 15 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 184 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col0 (type: string), true (type: boolean)
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 1 Data size: 188 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: _col0 (type: string)
+                    sort order: +
+                    Map-reduce partition columns: _col0 (type: string)
+                    Statistics: Num rows: 1 Data size: 188 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col1 (type: boolean)
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Left Outer Join0 to 1
+                keys:
+                  0 _col1 (type: string)
+                  1 _col0 (type: string)
+                outputColumnNames: _col0, _col1, _col2, _col4, _col5
+                Statistics: Num rows: 26 Data size: 6370 Basic stats: COMPLETE Column stats: COMPLETE
+                Reduce Output Operator
+                  key expressions: _col1 (type: string), _col2 (type: int)
+                  sort order: ++
+                  Map-reduce partition columns: _col1 (type: string), _col2 (type: int)
+                  Statistics: Num rows: 26 Data size: 6370 Basic stats: COMPLETE Column stats: COMPLETE
+                  value expressions: _col0 (type: string), _col4 (type: bigint), _col5 (type: bigint)
+        Reducer 3 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Left Outer Join0 to 1
+                keys:
+                  0 _col1 (type: string), _col2 (type: int)
+                  1 _col1 (type: string), _col0 (type: int)
+                outputColumnNames: _col0, _col2, _col4, _col5, _col8
+                Statistics: Num rows: 26 Data size: 3770 Basic stats: COMPLETE Column stats: COMPLETE
+                Reduce Output Operator
+                  sort order: 
+                  Statistics: Num rows: 26 Data size: 3770 Basic stats: COMPLETE Column stats: COMPLETE
+                  value expressions: _col0 (type: string), _col2 (type: int), _col4 (type: bigint), _col5 (type: bigint), _col8 (type: boolean)
+        Reducer 4 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Inner Join 0 to 1
+                keys:
+                  0 
+                  1 
+                outputColumnNames: _col0, _col2, _col4, _col5, _col8, _col9, _col10
+                Statistics: Num rows: 26 Data size: 4186 Basic stats: COMPLETE Column stats: COMPLETE
+                Reduce Output Operator
+                  key expressions: _col0 (type: string)
+                  sort order: +
+                  Map-reduce partition columns: _col0 (type: string)
+                  Statistics: Num rows: 26 Data size: 4186 Basic stats: COMPLETE Column stats: COMPLETE
+                  value expressions: _col2 (type: int), _col4 (type: bigint), _col5 (type: bigint), _col8 (type: boolean), _col9 (type: bigint), _col10 (type: bigint)
+        Reducer 5 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Left Outer Join0 to 1
+                keys:
+                  0 _col0 (type: string)
+                  1 _col0 (type: string)
+                outputColumnNames: _col0, _col2, _col4, _col5, _col8, _col9, _col10, _col12
+                Statistics: Num rows: 26 Data size: 4290 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: _col2 (type: int), (CASE WHEN ((_col4 = 0)) THEN (false) WHEN (_col4 is null) THEN (false) WHEN (_col8 is not null) THEN (true) WHEN (_col2 is null) THEN (null) WHEN ((_col5 < _col4)) THEN (null) ELSE (false) END and CASE WHEN ((_col9 = 0)) THEN (false) WHEN (_col12 is not null) THEN (true) WHEN (_col0 is null) THEN (null) WHEN ((_col10 < _col9)) THEN (null) ELSE (false) END) (type: boolean)
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 26 Data size: 208 Basic stats: COMPLETE Column stats: COMPLETE
+                  File Output Operator
+                    compressed: false
+                    Statistics: Num rows: 26 Data size: 208 Basic stats: COMPLETE Column stats: COMPLETE
+                    table:
+                        input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                        output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+        Reducer 7 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: max(VALUE._col0)
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  aggregations: count(), count(_col1)
+                  keys: _col0 (type: string)
+                  mode: complete
+                  outputColumnNames: _col0, _col1, _col2
+                  Statistics: Num rows: 6 Data size: 720 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: _col0 (type: string)
+                    sort order: +
+                    Map-reduce partition columns: _col0 (type: string)
+                    Statistics: Num rows: 6 Data size: 720 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col1 (type: bigint), _col2 (type: bigint)
+        Reducer 9 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: max(VALUE._col0)
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 6 Data size: 648 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  keys: _col0 (type: string), _col1 (type: int)
+                  mode: hash
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: _col0 (type: string), _col1 (type: int)
+                    sort order: ++
+                    Map-reduce partition columns: _col0 (type: string), _col1 (type: int)
+                    Statistics: Num rows: 3 Data size: 324 Basic stats: COMPLETE Column stats: COMPLETE
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+Warning: Shuffle Join MERGEJOIN[74][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 4' is a cross product
+PREHOOK: query: SELECT p_size, p_size IN (
+        SELECT MAX(p_size) FROM part p where p.p_type = part.p_type) AND
+        p_name IN (SELECT min(p_name) from part)
+FROM part
+PREHOOK: type: QUERY
+PREHOOK: Input: default@part
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT p_size, p_size IN (
+        SELECT MAX(p_size) FROM part p where p.p_type = part.p_type) AND
+        p_name IN (SELECT min(p_name) from part)
+FROM part
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@part
+#### A masked pattern was here ####
+31	true
+2	false
+2	false
+17	false
+34	false
+14	false
+10	false
+6	false
+19	false
+1	false
+45	false
+6	false
+2	false
+14	false
+39	false
+40	false
+28	false
+46	false
+27	false
+2	false
+42	false
+25	false
+18	false
+7	false
+12	false
+23	false
+PREHOOK: query: explain SELECT p_size, NOT EXISTS(SELECT p_size FROM part pp where pp.p_type = part.p_type)
+FROM part
+PREHOOK: type: QUERY
+POSTHOOK: query: explain SELECT p_size, NOT EXISTS(SELECT p_size FROM part pp where pp.p_type = part.p_type)
+FROM part
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+        Reducer 4 <- Map 3 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: part
+                  Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: p_type (type: string), p_size (type: int)
+                    outputColumnNames: _col0, _col1
+                    Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: string)
+                      sort order: +
+                      Map-reduce partition columns: _col0 (type: string)
+                      Statistics: Num rows: 26 Data size: 2808 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col1 (type: int)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 3 
+            Map Operator Tree:
+                TableScan
+                  alias: pp
+                  Statistics: Num rows: 26 Data size: 2704 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (p_type = p_type) (type: boolean)
+                    Statistics: Num rows: 13 Data size: 1352 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      keys: p_type (type: string)
+                      mode: hash
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 6 Data size: 624 Basic stats: COMPLET

<TRUNCATED>