You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by px...@apache.org on 2017/05/24 22:06:05 UTC

[1/7] hive git commit: HIVE-15160: Can't order by an unselected column (Pengcheng Xiong, reviewed by Ashutosh Chauhan)

Repository: hive
Updated Branches:
  refs/heads/master bda5e1e0c -> a74c1e7ce


http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/spark/subquery_in.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/subquery_in.q.out b/ql/src/test/results/clientpositive/spark/subquery_in.q.out
index 5e38938..80a3506 100644
--- a/ql/src/test/results/clientpositive/spark/subquery_in.q.out
+++ b/ql/src/test/results/clientpositive/spark/subquery_in.q.out
@@ -3138,11 +3138,11 @@ STAGE PLANS:
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
-                  expressions: _col1 (type: string), _col0 (type: string), _col2 (type: int)
-                  outputColumnNames: _col0, _col1, _col2
+                  expressions: _col0 (type: string), _col1 (type: string), _col2 (type: int)
+                  outputColumnNames: _col1, _col3, _col4
                   Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
                   Reduce Output Operator
-                    key expressions: _col0 (type: string), _col2 (type: int)
+                    key expressions: _col3 (type: string), _col4 (type: int)
                     sort order: ++
                     Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
                     value expressions: _col1 (type: string)

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/vector_coalesce.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/vector_coalesce.q.out b/ql/src/test/results/clientpositive/vector_coalesce.q.out
index 87ab937..445a246 100644
--- a/ql/src/test/results/clientpositive/vector_coalesce.q.out
+++ b/ql/src/test/results/clientpositive/vector_coalesce.q.out
@@ -202,12 +202,14 @@ STAGE PLANS:
                 Select Vectorization:
                     className: VectorSelectOperator
                     native: true
-                    projectedOutputColumns: []
-                  Reduce Sink Vectorization:
-                      className: VectorReduceSinkOperator
-                      native: false
-                      nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
-                      nativeConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
+                    projectedOutputColumns: [12, 13, 14]
+                    selectExpressions: ConstantVectorExpression(val null) -> 12:float, ConstantVectorExpression(val null) -> 13:bigint, ConstantVectorExpression(val 0.0) -> 14:double
+                  Limit Vectorization:
+                      className: VectorLimitOperator
+                      native: true
+                    File Sink Vectorization:
+                        className: VectorFileSinkOperator
+                        native: false
       Execution mode: vectorized
       Map Vectorization:
           enabled: true
@@ -217,11 +219,6 @@ STAGE PLANS:
           allNative: false
           usesVectorUDFAdaptor: false
           vectorized: true
-      Reduce Vectorization:
-          enabled: false
-          enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true
-          enableConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
-      Reduce Operator Tree:
 
   Stage: Stage-0
     Fetch Operator
@@ -371,12 +368,14 @@ STAGE PLANS:
                 Select Vectorization:
                     className: VectorSelectOperator
                     native: true
-                    projectedOutputColumns: []
-                  Reduce Sink Vectorization:
-                      className: VectorReduceSinkOperator
-                      native: false
-                      nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
-                      nativeConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
+                    projectedOutputColumns: [12, 13, 14]
+                    selectExpressions: ConstantVectorExpression(val null) -> 12:float, ConstantVectorExpression(val null) -> 13:bigint, ConstantVectorExpression(val null) -> 14:float
+                  Limit Vectorization:
+                      className: VectorLimitOperator
+                      native: true
+                    File Sink Vectorization:
+                        className: VectorFileSinkOperator
+                        native: false
       Execution mode: vectorized
       Map Vectorization:
           enabled: true
@@ -386,11 +385,6 @@ STAGE PLANS:
           allNative: false
           usesVectorUDFAdaptor: false
           vectorized: true
-      Reduce Vectorization:
-          enabled: false
-          enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true
-          enableConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
-      Reduce Operator Tree:
 
   Stage: Stage-0
     Fetch Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/vector_date_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/vector_date_1.q.out b/ql/src/test/results/clientpositive/vector_date_1.q.out
index c2389e6..6762374 100644
--- a/ql/src/test/results/clientpositive/vector_date_1.q.out
+++ b/ql/src/test/results/clientpositive/vector_date_1.q.out
@@ -594,26 +594,17 @@ STAGE PLANS:
               predicate: ((dt1 = 2001-01-01) and (2001-01-01 = dt1) and (dt1 <> 1970-01-01) and (1970-01-01 <> dt1) and (dt1 > 1970-01-01) and (dt1 >= 1970-01-01) and (1970-01-01 < dt1) and (1970-01-01 <= dt1)) (type: boolean)
               Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
               Select Operator
-                expressions: dt2 (type: date)
-                outputColumnNames: _col1
+                expressions: 2001-01-01 (type: date), dt2 (type: date)
+                outputColumnNames: _col0, _col1
                 Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  sort order: 
+                File Output Operator
+                  compressed: false
                   Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col1 (type: date)
+                  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
       Execution mode: vectorized
-      Reduce Operator Tree:
-        Select Operator
-          expressions: 2001-01-01 (type: date), VALUE._col0 (type: date)
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
-            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
 
   Stage: Stage-0
     Fetch Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/vector_decimal_round.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/vector_decimal_round.q.out b/ql/src/test/results/clientpositive/vector_decimal_round.q.out
index d92b6c2..be7b509 100644
--- a/ql/src/test/results/clientpositive/vector_decimal_round.q.out
+++ b/ql/src/test/results/clientpositive/vector_decimal_round.q.out
@@ -137,15 +137,16 @@ STAGE PLANS:
                 native: true
                 projectedOutputColumns: [0]
             Select Operator
-              expressions: dec (type: decimal(10,0))
-              outputColumnNames: _col0
+              expressions: dec (type: decimal(10,0)), round(dec, -1) (type: decimal(11,0))
+              outputColumnNames: _col0, _col2
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
-                  projectedOutputColumns: [0]
+                  projectedOutputColumns: [0, 1]
+                  selectExpressions: FuncRoundWithNumDigitsDecimalToDecimal(col 0, decimalPlaces -1) -> 1:decimal(11,0)
               Statistics: Num rows: 1 Data size: 3 Basic stats: COMPLETE Column stats: NONE
               Reduce Output Operator
-                key expressions: round(_col0, -1) (type: decimal(11,0))
+                key expressions: _col2 (type: decimal(11,0))
                 sort order: +
                 Reduce Sink Vectorization:
                     className: VectorReduceSinkOperator
@@ -309,11 +310,11 @@ STAGE PLANS:
             alias: decimal_tbl_rc
             Statistics: Num rows: 1 Data size: 3 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: dec (type: decimal(10,0))
-              outputColumnNames: _col0
+              expressions: dec (type: decimal(10,0)), round(dec, -1) (type: decimal(11,0))
+              outputColumnNames: _col0, _col2
               Statistics: Num rows: 1 Data size: 3 Basic stats: COMPLETE Column stats: NONE
               Reduce Output Operator
-                key expressions: round(_col0, -1) (type: decimal(11,0))
+                key expressions: _col2 (type: decimal(11,0))
                 sort order: +
                 Statistics: Num rows: 1 Data size: 3 Basic stats: COMPLETE Column stats: NONE
                 value expressions: _col0 (type: decimal(10,0))
@@ -488,15 +489,16 @@ STAGE PLANS:
                 native: true
                 projectedOutputColumns: [0]
             Select Operator
-              expressions: dec (type: decimal(10,0))
-              outputColumnNames: _col0
+              expressions: dec (type: decimal(10,0)), round(dec, -1) (type: decimal(11,0))
+              outputColumnNames: _col0, _col2
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
-                  projectedOutputColumns: [0]
+                  projectedOutputColumns: [0, 1]
+                  selectExpressions: FuncRoundWithNumDigitsDecimalToDecimal(col 0, decimalPlaces -1) -> 1:decimal(11,0)
               Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: NONE
               Reduce Output Operator
-                key expressions: round(_col0, -1) (type: decimal(11,0))
+                key expressions: _col2 (type: decimal(11,0))
                 sort order: +
                 Reduce Sink Vectorization:
                     className: VectorReduceSinkOperator

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/vector_interval_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/vector_interval_1.q.out b/ql/src/test/results/clientpositive/vector_interval_1.q.out
index 2a398ae..02b7d46 100644
--- a/ql/src/test/results/clientpositive/vector_interval_1.q.out
+++ b/ql/src/test/results/clientpositive/vector_interval_1.q.out
@@ -72,7 +72,7 @@ STAGE PLANS:
                 projectedOutputColumns: [0, 1, 2, 3]
             Select Operator
               expressions: str1 (type: string), CAST( str1 AS INTERVAL YEAR TO MONTH) (type: interval_year_month), CAST( str2 AS INTERVAL DAY TO SECOND) (type: interval_day_time)
-              outputColumnNames: _col0, _col2, _col4
+              outputColumnNames: _col0, _col1, _col2
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
@@ -88,7 +88,7 @@ STAGE PLANS:
                     nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
                     nativeConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
                 Statistics: Num rows: 2 Data size: 442 Basic stats: COMPLETE Column stats: NONE
-                value expressions: _col2 (type: interval_year_month), _col4 (type: interval_day_time)
+                value expressions: _col1 (type: interval_year_month), _col2 (type: interval_day_time)
       Execution mode: vectorized
       Map Vectorization:
           enabled: true
@@ -181,7 +181,7 @@ STAGE PLANS:
                 projectedOutputColumns: [0, 1, 2, 3]
             Select Operator
               expressions: dt (type: date), (CAST( str1 AS INTERVAL YEAR TO MONTH) + CAST( str1 AS INTERVAL YEAR TO MONTH)) (type: interval_year_month), (1-2 + CAST( str1 AS INTERVAL YEAR TO MONTH)) (type: interval_year_month), (CAST( str1 AS INTERVAL YEAR TO MONTH) - CAST( str1 AS INTERVAL YEAR TO MONTH)) (type: interval_year_month), (1-2 - CAST( str1 AS INTERVAL YEAR TO MONTH)) (type: interval_year_month)
-              outputColumnNames: _col0, _col2, _col3, _col5, _col6
+              outputColumnNames: _col0, _col1, _col2, _col3, _col4
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
@@ -197,7 +197,7 @@ STAGE PLANS:
                     nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
                     nativeConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
                 Statistics: Num rows: 2 Data size: 442 Basic stats: COMPLETE Column stats: NONE
-                value expressions: _col2 (type: interval_year_month), _col3 (type: interval_year_month), _col5 (type: interval_year_month), _col6 (type: interval_year_month)
+                value expressions: _col1 (type: interval_year_month), _col2 (type: interval_year_month), _col3 (type: interval_year_month), _col4 (type: interval_year_month)
       Execution mode: vectorized
       Map Vectorization:
           enabled: true
@@ -298,7 +298,7 @@ STAGE PLANS:
                 projectedOutputColumns: [0, 1, 2, 3]
             Select Operator
               expressions: dt (type: date), (CAST( str2 AS INTERVAL DAY TO SECOND) + CAST( str2 AS INTERVAL DAY TO SECOND)) (type: interval_day_time), (1 02:03:04.000000000 + CAST( str2 AS INTERVAL DAY TO SECOND)) (type: interval_day_time), (CAST( str2 AS INTERVAL DAY TO SECOND) - CAST( str2 AS INTERVAL DAY TO SECOND)) (type: interval_day_time), (1 02:03:04.000000000 - CAST( str2 AS INTERVAL DAY TO SECOND)) (type: interval_day_time)
-              outputColumnNames: _col0, _col2, _col3, _col5, _col6
+              outputColumnNames: _col0, _col1, _col2, _col3, _col4
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
@@ -314,7 +314,7 @@ STAGE PLANS:
                     nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
                     nativeConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
                 Statistics: Num rows: 2 Data size: 442 Basic stats: COMPLETE Column stats: NONE
-                value expressions: _col2 (type: interval_day_time), _col3 (type: interval_day_time), _col5 (type: interval_day_time), _col6 (type: interval_day_time)
+                value expressions: _col1 (type: interval_day_time), _col2 (type: interval_day_time), _col3 (type: interval_day_time), _col4 (type: interval_day_time)
       Execution mode: vectorized
       Map Vectorization:
           enabled: true

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/vector_interval_arithmetic.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/vector_interval_arithmetic.q.out b/ql/src/test/results/clientpositive/vector_interval_arithmetic.q.out
index b67231c..fc397eb 100644
--- a/ql/src/test/results/clientpositive/vector_interval_arithmetic.q.out
+++ b/ql/src/test/results/clientpositive/vector_interval_arithmetic.q.out
@@ -572,21 +572,30 @@ STAGE PLANS:
                 native: true
                 projectedOutputColumns: [0, 1]
             Select Operator
+              expressions: 5-5 (type: interval_year_month), -1-1 (type: interval_year_month)
+              outputColumnNames: _col0, _col1
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
-                  projectedOutputColumns: []
+                  projectedOutputColumns: [2, 3]
+                  selectExpressions: ConstantVectorExpression(val 65) -> 2:long, ConstantVectorExpression(val -13) -> 3:long
               Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE
-              Reduce Output Operator
-                key expressions: CAST( 5-5 AS INTERVAL YEAR TO MONTH) (type: interval_year_month)
-                sort order: +
-                Reduce Sink Vectorization:
-                    className: VectorReduceSinkOperator
-                    native: false
-                    nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
-                    nativeConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
-                Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE
-                TopN Hash Memory Usage: 0.1
+              Limit
+                Number of rows: 2
+                Limit Vectorization:
+                    className: VectorLimitOperator
+                    native: true
+                Statistics: Num rows: 2 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+                File Output Operator
+                  compressed: false
+                  File Sink Vectorization:
+                      className: VectorFileSinkOperator
+                      native: false
+                  Statistics: Num rows: 2 Data size: 32 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
       Execution mode: vectorized
       Map Vectorization:
           enabled: true
@@ -596,25 +605,6 @@ STAGE PLANS:
           allNative: false
           usesVectorUDFAdaptor: false
           vectorized: true
-      Reduce Vectorization:
-          enabled: false
-          enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true
-          enableConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
-      Reduce Operator Tree:
-        Select Operator
-          expressions: 5-5 (type: interval_year_month), -1-1 (type: interval_year_month)
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE
-          Limit
-            Number of rows: 2
-            Statistics: Num rows: 2 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
-            File Output Operator
-              compressed: false
-              Statistics: Num rows: 2 Data size: 32 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
 
   Stage: Stage-0
     Fetch Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/view_alias.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/view_alias.q.out b/ql/src/test/results/clientpositive/view_alias.q.out
index 90bf28d..1582f06 100644
--- a/ql/src/test/results/clientpositive/view_alias.q.out
+++ b/ql/src/test/results/clientpositive/view_alias.q.out
@@ -56,11 +56,11 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Input: default@v
 #### A masked pattern was here ####
-165	12
-27	12
-311	12
-97	12
 238	12
+86	12
+311	12
+27	12
+165	12
 PREHOOK: query: drop view v
 PREHOOK: type: DROPVIEW
 PREHOOK: Input: default@v
@@ -123,11 +123,11 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Input: default@v
 #### A masked pattern was here ####
-165	12
-27	12
-311	12
-97	12
 238	12
+86	12
+311	12
+27	12
+165	12
 PREHOOK: query: drop view v
 PREHOOK: type: DROPVIEW
 PREHOOK: Input: default@v
@@ -192,11 +192,11 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Input: default@v
 #### A masked pattern was here ####
-165	val_165	12
-27	val_27	12
-311	val_311	12
-97	val_97	12
 238	val_238	12
+86	val_86	12
+311	val_311	12
+27	val_27	12
+165	val_165	12
 PREHOOK: query: drop view v
 PREHOOK: type: DROPVIEW
 PREHOOK: Input: default@v
@@ -261,11 +261,11 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Input: default@v
 #### A masked pattern was here ####
-165	val_165	12
-27	val_27	12
-311	val_311	12
-97	val_97	12
 238	val_238	12
+86	val_86	12
+311	val_311	12
+27	val_27	12
+165	val_165	12
 PREHOOK: query: drop view v
 PREHOOK: type: DROPVIEW
 PREHOOK: Input: default@v
@@ -445,8 +445,8 @@ POSTHOOK: Input: default@a
 POSTHOOK: Input: default@b
 POSTHOOK: Input: default@v
 #### A masked pattern was here ####
-010	86	val_86	121	86	val_86	234
-010	311	val_311	121	311	val_311	234
-010	27	val_27	121	27	val_27	234
-010	238	val_238	121	238	val_238	234
 010	165	val_165	121	165	val_165	234
+010	238	val_238	121	238	val_238	234
+010	27	val_27	121	27	val_27	234
+010	311	val_311	121	311	val_311	234
+010	86	val_86	121	86	val_86	234


[7/7] hive git commit: HIVE-15160: Can't order by an unselected column (Pengcheng Xiong, reviewed by Ashutosh Chauhan)

Posted by px...@apache.org.
HIVE-15160: Can't order by an unselected column (Pengcheng Xiong, reviewed by Ashutosh Chauhan)


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

Branch: refs/heads/master
Commit: a74c1e7ceeab05917fbe01e9a7cd3eda8e87ee27
Parents: bda5e1e
Author: Pengcheng Xiong <px...@hortonworks.com>
Authored: Wed May 24 15:05:55 2017 -0700
Committer: Pengcheng Xiong <px...@hortonworks.com>
Committed: Wed May 24 15:05:55 2017 -0700

----------------------------------------------------------------------
 .../rules/HiveProjectSortTransposeRule.java     |  56 +-
 .../hadoop/hive/ql/parse/CalcitePlanner.java    | 198 ++++--
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java  |   3 +
 .../hive/ql/parse/TypeCheckProcFactory.java     |   2 +-
 .../queries/clientpositive/order_by_expr_1.q    |  44 ++
 .../queries/clientpositive/order_by_expr_2.q    |  11 +
 .../clientpositive/annotate_stats_select.q.out  |  25 +-
 ql/src/test/results/clientpositive/cp_sel.q.out |  22 +-
 .../results/clientpositive/druid_basic2.q.out   |  10 +-
 .../clientpositive/dynamic_rdd_cache.q.out      |   6 +-
 .../groupby_grouping_sets_grouping.q.out        |   6 +-
 .../clientpositive/llap/bucket_groupby.q.out    |   2 +-
 .../clientpositive/llap/explainuser_1.q.out     | 221 +++---
 .../clientpositive/llap/limit_pushdown.q.out    |   6 +-
 .../clientpositive/llap/limit_pushdown3.q.out   |   6 +-
 .../llap/offset_limit_ppd_optimizer.q.out       |   6 +-
 .../clientpositive/llap/subquery_in.q.out       |  10 +-
 .../clientpositive/llap/vector_coalesce.q.out   |  96 +--
 .../clientpositive/llap/vector_date_1.q.out     |  30 +-
 .../clientpositive/llap/vector_decimal_2.q.out  | 297 +++-----
 .../llap/vector_decimal_round.q.out             |  26 +-
 .../vector_groupby_grouping_sets_grouping.q.out |   6 +-
 .../vector_groupby_grouping_sets_limit.q.out    |   2 +-
 .../clientpositive/llap/vector_interval_1.q.out |  12 +-
 .../llap/vector_interval_arithmetic.q.out       |  67 +-
 ql/src/test/results/clientpositive/order3.q.out |  22 +-
 .../clientpositive/order_by_expr_1.q.out        | 566 +++++++++++++++
 .../clientpositive/order_by_expr_2.q.out        | 100 +++
 ql/src/test/results/clientpositive/pcr.q.out    | 114 ++--
 .../results/clientpositive/perf/query31.q.out   |  68 +-
 .../results/clientpositive/perf/query36.q.out   |  20 +-
 .../results/clientpositive/perf/query39.q.out   |  34 +-
 .../results/clientpositive/perf/query42.q.out   |  30 +-
 .../results/clientpositive/perf/query52.q.out   |  30 +-
 .../results/clientpositive/perf/query64.q.out   | 154 ++---
 .../results/clientpositive/perf/query66.q.out   |  56 +-
 .../results/clientpositive/perf/query70.q.out   |  30 +-
 .../results/clientpositive/perf/query75.q.out   | 682 ++++++++++---------
 .../results/clientpositive/perf/query81.q.out   | 274 ++++----
 .../results/clientpositive/perf/query85.q.out   |  34 +-
 .../results/clientpositive/perf/query86.q.out   |  16 +-
 .../results/clientpositive/perf/query89.q.out   |  22 +-
 .../results/clientpositive/perf/query91.q.out   |  28 +-
 .../results/clientpositive/pointlookup2.q.out   |  94 +--
 .../results/clientpositive/pointlookup3.q.out   |  96 +--
 .../results/clientpositive/ppd_udf_case.q.out   |  36 +-
 .../spark/dynamic_rdd_cache.q.out               |   6 +-
 .../clientpositive/spark/limit_pushdown.q.out   |   2 +-
 .../test/results/clientpositive/spark/pcr.q.out |  44 +-
 .../clientpositive/spark/subquery_in.q.out      |   6 +-
 .../clientpositive/vector_coalesce.q.out        |  38 +-
 .../results/clientpositive/vector_date_1.q.out  |  25 +-
 .../clientpositive/vector_decimal_round.q.out   |  24 +-
 .../clientpositive/vector_interval_1.q.out      |  12 +-
 .../vector_interval_arithmetic.q.out            |  50 +-
 .../results/clientpositive/view_alias.q.out     |  40 +-
 56 files changed, 2269 insertions(+), 1654 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveProjectSortTransposeRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveProjectSortTransposeRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveProjectSortTransposeRule.java
index 1487ed4..871c411 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveProjectSortTransposeRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveProjectSortTransposeRule.java
@@ -18,22 +18,33 @@
 package org.apache.hadoop.hive.ql.optimizer.calcite.rules;
 
 import org.apache.calcite.plan.RelOptCluster;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.calcite.plan.RelOptRule;
 import org.apache.calcite.plan.RelOptRuleCall;
 import org.apache.calcite.plan.RelOptRuleOperand;
 import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.plan.RelTraitSet;
 import org.apache.calcite.rel.RelCollation;
-import org.apache.calcite.rel.RelCollationTraitDef;
+import org.apache.calcite.rel.RelCollationImpl;
 import org.apache.calcite.rel.RelFieldCollation;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rex.RexCall;
 import org.apache.calcite.rex.RexCallBinding;
+import org.apache.calcite.rex.RexInputRef;
 import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.rex.RexUtil;
 import org.apache.calcite.sql.SqlKind;
 import org.apache.calcite.sql.validate.SqlMonotonicity;
 import org.apache.calcite.util.mapping.Mappings;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil;
 import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveProject;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveRelNode;
 import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSortLimit;
 
 import com.google.common.collect.ImmutableList;
@@ -67,15 +78,15 @@ public class HiveProjectSortTransposeRule extends RelOptRule {
     final HiveSortLimit sort = call.rel(1);
     final RelOptCluster cluster = project.getCluster();
 
-    // Determine mapping between project input and output fields. If sort
-    // relies on non-trivial expressions, we can't push.
+    // Determine mapping between project input and output fields. 
+    // In Hive, Sort is always based on RexInputRef
+    // We only need to check if project can contain all the positions that sort needs.
     final Mappings.TargetMapping map =
         RelOptUtil.permutationIgnoreCast(
             project.getProjects(), project.getInput().getRowType()).inverse();
+    Set<Integer> needed = new HashSet<>();
     for (RelFieldCollation fc : sort.getCollation().getFieldCollations()) {
-      if (map.getTarget(fc.getFieldIndex()) < 0) {
-        return;
-      }
+      needed.add(fc.getFieldIndex());
       final RexNode node = project.getProjects().get(map.getTarget(fc.getFieldIndex()));
       if (node.isA(SqlKind.CAST)) {
         // Check whether it is a monotonic preserving cast, otherwise we cannot push
@@ -88,12 +99,35 @@ public class HiveProjectSortTransposeRule extends RelOptRule {
         }
       }
     }
+    Map<Integer,Integer> m = new HashMap<>();
+    for (int projPos = 0; projPos < project.getChildExps().size(); projPos++) {
+      RexNode expr = project.getChildExps().get(projPos);
+      if (expr instanceof RexInputRef) {
+        Set<Integer> positions = HiveCalciteUtil.getInputRefs(expr);
+        if (positions.size() > 1) {
+          continue;
+        } else {
+          int parentPos = positions.iterator().next();
+          if(needed.contains(parentPos)){
+            m.put(parentPos, projPos);
+            needed.remove(parentPos);
+          }
+        }
+      }
+    }
+    if(!needed.isEmpty()){
+      return;
+    }
+    
+    List<RelFieldCollation> fieldCollations = new ArrayList<>();
+    for (RelFieldCollation fc : sort.getCollation().getFieldCollations()) {
+      fieldCollations.add(new RelFieldCollation(m.get(fc.getFieldIndex()), fc.direction,
+          fc.nullDirection));
+    }
 
-    // Create new collation
-    final RelCollation newCollation =
-        RelCollationTraitDef.INSTANCE.canonize(
-            RexUtil.apply(map, sort.getCollation()));
-
+    RelTraitSet traitSet = sort.getCluster().traitSetOf(HiveRelNode.CONVENTION);
+    RelCollation newCollation = traitSet.canonize(RelCollationImpl.of(fieldCollations));
+    
     // New operators
     final RelNode newProject = project.copy(sort.getInput().getTraitSet(),
             ImmutableList.<RelNode>of(sort.getInput()));

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/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 fa96e94..721dac8 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
@@ -1744,9 +1744,9 @@ public class CalcitePlanner extends SemanticAnalyzer {
       // 8. Merge, remove and reduce Project if possible
       perfLogger.PerfLogBegin(this.getClass().getName(), PerfLogger.OPTIMIZER);
       basePlan = hepPlan(basePlan, false, mdProvider, executorProvider,
-           HiveProjectMergeRule.INSTANCE, ProjectRemoveRule.INSTANCE);
+           HiveProjectMergeRule.INSTANCE, ProjectRemoveRule.INSTANCE, HiveSortMergeRule.INSTANCE);
       perfLogger.PerfLogEnd(this.getClass().getName(), PerfLogger.OPTIMIZER,
-        "Calcite: Prejoin ordering transformation, Merge Project-Project");
+          "Calcite: Prejoin ordering transformation, Merge Project-Project, Merge Sort-Sort");
 
       // 9. Rerun PPD through Project as column pruning would have introduced
       // DT above scans; By pushing filter just above TS, Hive can push it into
@@ -2887,7 +2887,8 @@ public class CalcitePlanner extends SemanticAnalyzer {
           && selExprList.getChildCount() == 1 && selExprList.getChild(0).getChildCount() == 1) {
         ASTNode node = (ASTNode) selExprList.getChild(0).getChild(0);
         if (node.getToken().getType() == HiveParser.TOK_ALLCOLREF) {
-          srcRel = genSelectLogicalPlan(qb, srcRel, srcRel, null,null);
+          // As we said before, here we use genSelectLogicalPlan to rewrite AllColRef
+          srcRel = genSelectLogicalPlan(qb, srcRel, srcRel, null, null, true).getKey();
           RowResolver rr = this.relToHiveRR.get(srcRel);
           qbp.setSelExprForClause(detsClauseName, SemanticAnalyzer.genSelectDIAST(rr));
         }
@@ -3049,14 +3050,18 @@ public class CalcitePlanner extends SemanticAnalyzer {
      * @param qb
      * @param srcRel
      * @param outermostOB
-     * @return Pair<RelNode, RelNode> Key- OB RelNode, Value - Input Select for
-     *         top constraining Select
+     * @return RelNode OB RelNode
      * @throws SemanticException
      */
-    private Pair<RelNode, RelNode> genOBLogicalPlan(QB qb, RelNode srcRel, boolean outermostOB)
-        throws SemanticException {
+    private RelNode genOBLogicalPlan(QB qb, Pair<RelNode, RowResolver> selPair,
+        boolean outermostOB) throws SemanticException {
+      // selPair.getKey() is the operator right before OB
+      // selPair.getValue() is RR which only contains columns needed in result
+      // set. Extra columns needed by order by will be absent from it.
+      RelNode srcRel = selPair.getKey();
+      RowResolver selectOutputRR = selPair.getValue();
       RelNode sortRel = null;
-      RelNode originalOBChild = null;
+      RelNode returnRel = null;
 
       QBParseInfo qbp = getQBParseInfo(qb);
       String dest = qbp.getClauseNames().iterator().next();
@@ -3064,7 +3069,8 @@ public class CalcitePlanner extends SemanticAnalyzer {
 
       if (obAST != null) {
         // 1. OB Expr sanity test
-        // in strict mode, in the presence of order by, limit must be specified
+        // in strict mode, in the presence of order by, limit must be
+        // specified
         Integer limit = qb.getParseInfo().getDestLimit(dest);
         if (limit == null) {
           String error = StrictChecks.checkNoLimit(conf);
@@ -3096,11 +3102,28 @@ public class CalcitePlanner extends SemanticAnalyzer {
           obASTExpr = (ASTNode) obASTExprLst.get(i);
           nullObASTExpr = (ASTNode) obASTExpr.getChild(0);
           ASTNode ref = (ASTNode) nullObASTExpr.getChild(0);
-          Map<ASTNode, ExprNodeDesc> astToExprNDescMap = genAllExprNodeDesc(ref, inputRR);
-          ExprNodeDesc obExprNDesc = astToExprNDescMap.get(ref);
-          if (obExprNDesc == null)
+          Map<ASTNode, ExprNodeDesc> astToExprNDescMap = null;
+          ExprNodeDesc obExprNDesc = null;
+          // first try to get it from select
+          // in case of udtf, selectOutputRR may be null.
+          if (selectOutputRR != null) {
+            try {
+              astToExprNDescMap = genAllExprNodeDesc(ref, selectOutputRR);
+              obExprNDesc = astToExprNDescMap.get(ref);
+            } catch (SemanticException ex) {
+              // we can tolerate this as this is the previous behavior
+              LOG.debug("Can not find column in " + ref.getText() + ". The error msg is "
+                  + ex.getMessage());
+            }
+          }
+          // then try to get it from all
+          if (obExprNDesc == null) {
+            astToExprNDescMap = genAllExprNodeDesc(ref, inputRR);
+            obExprNDesc = astToExprNDescMap.get(ref);
+          }
+          if (obExprNDesc == null) {
             throw new SemanticException("Invalid order by expression: " + obASTExpr.toString());
-
+          }
           // 2.2 Convert ExprNode to RexNode
           rnd = converter.convert(obExprNDesc);
 
@@ -3126,8 +3149,8 @@ public class CalcitePlanner extends SemanticAnalyzer {
           } else if (nullObASTExpr.getType() == HiveParser.TOK_NULLS_LAST) {
             nullOrder = RelFieldCollation.NullDirection.LAST;
           } else {
-            throw new SemanticException(
-                    "Unexpected null ordering option: " + nullObASTExpr.getType());
+            throw new SemanticException("Unexpected null ordering option: "
+                + nullObASTExpr.getType());
           }
 
           // 2.5 Add to field collations
@@ -3174,7 +3197,6 @@ public class CalcitePlanner extends SemanticAnalyzer {
                   "Duplicates detected when adding columns to RR: see previous message",
                   UnsupportedFeature.Duplicates_in_RR);
             }
-            originalOBChild = srcRel;
           }
         } else {
           if (!RowResolver.add(outputRR, inputRR)) {
@@ -3199,9 +3221,26 @@ public class CalcitePlanner extends SemanticAnalyzer {
             outputRR, sortRel);
         relToHiveRR.put(sortRel, outputRR);
         relToHiveColNameCalcitePosMap.put(sortRel, hiveColNameCalcitePosMap);
-      }
 
-      return (new Pair<RelNode, RelNode>(sortRel, originalOBChild));
+        if (selectOutputRR != null) {
+          List<RexNode> originalInputRefs = Lists.transform(srcRel.getRowType().getFieldList(),
+              new Function<RelDataTypeField, RexNode>() {
+                @Override
+                public RexNode apply(RelDataTypeField input) {
+                  return new RexInputRef(input.getIndex(), input.getType());
+                }
+              });
+          List<RexNode> selectedRefs = Lists.newArrayList();
+          for (int index = 0; index < selectOutputRR.getColumnInfos().size(); index++) {
+            selectedRefs.add(originalInputRefs.get(index));
+          }
+          // We need to add select since order by schema may have more columns than result schema.
+          returnRel = genSelectRelNode(selectedRefs, selectOutputRR, sortRel);
+        } else {
+          returnRel = sortRel;
+        }
+      }
+      return returnRel;
     }
 
     private RelNode genLimitLogicalPlan(QB qb, RelNode srcRel) throws SemanticException {
@@ -3532,8 +3571,20 @@ public class CalcitePlanner extends SemanticAnalyzer {
      *
      * @throws SemanticException
      */
-    private RelNode genSelectLogicalPlan(QB qb, RelNode srcRel, RelNode starSrcRel,
-                                         ImmutableMap<String, Integer> outerNameToPosMap, RowResolver outerRR)
+    /**
+     * @param qb
+     * @param srcRel
+     * @param starSrcRel
+     * @param outerNameToPosMap
+     * @param outerRR
+     * @param isAllColRefRewrite
+     *          when it is true, it means that it is called from group by *, where we use
+     *          genSelectLogicalPlan to rewrite *
+     * @return RelNode: the select relnode RowResolver: i.e., originalRR, the RR after select when there is an order by.
+     * @throws SemanticException
+     */
+    private Pair<RelNode,RowResolver> genSelectLogicalPlan(QB qb, RelNode srcRel, RelNode starSrcRel,
+                                         ImmutableMap<String, Integer> outerNameToPosMap, RowResolver outerRR, boolean isAllColRefRewrite)
         throws SemanticException {
       // 0. Generate a Select Node for Windowing
       // Exclude the newly-generated select columns from */etc. resolution.
@@ -3798,15 +3849,64 @@ public class CalcitePlanner extends SemanticAnalyzer {
       // 8. Build Calcite Rel
       RelNode outputRel = null;
       if (genericUDTF != null) {
-        // The basic idea for CBO support of UDTF is to treat UDTF as a special project.
-        // In AST return path, as we just need to generate a SEL_EXPR, we just need to remember the expressions and the alias.
-        // In OP return path, we need to generate a SEL and then a UDTF following old semantic analyzer.
-        outputRel = genUDTFPlan(genericUDTF, genericUDTFName, udtfTableAlias, udtfColAliases, qb, calciteColLst, out_rwsch, srcRel);
-      }
-      else{
-        outputRel = genSelectRelNode(calciteColLst, out_rwsch, srcRel);
+        // The basic idea for CBO support of UDTF is to treat UDTF as a special
+        // project.
+        // In AST return path, as we just need to generate a SEL_EXPR, we just
+        // need to remember the expressions and the alias.
+        // In OP return path, we need to generate a SEL and then a UDTF
+        // following old semantic analyzer.
+        outputRel = genUDTFPlan(genericUDTF, genericUDTFName, udtfTableAlias, udtfColAliases, qb,
+            calciteColLst, out_rwsch, srcRel);
+      } else {
+        String dest = qbp.getClauseNames().iterator().next();
+        ASTNode obAST = qbp.getOrderByForClause(dest);
+
+        RowResolver originalRR = null;
+        // We only support limited unselected column following by order by.
+        // TODO: support unselected columns in genericUDTF and windowing functions.
+        // We examine the order by in this query block and adds in column needed
+        // by order by in select list.
+        if (obAST != null && !(selForWindow != null && selExprList.getToken().getType() == HiveParser.TOK_SELECTDI) && !isAllColRefRewrite) {
+          // 1. OB Expr sanity test
+          // in strict mode, in the presence of order by, limit must be
+          // specified
+          Integer limit = qb.getParseInfo().getDestLimit(dest);
+          if (limit == null) {
+            String error = StrictChecks.checkNoLimit(conf);
+            if (error != null) {
+              throw new SemanticException(SemanticAnalyzer.generateErrorMessage(obAST, error));
+            }
+          }
+          List<RexNode> originalInputRefs = Lists.transform(srcRel.getRowType().getFieldList(),
+              new Function<RelDataTypeField, RexNode>() {
+                @Override
+                public RexNode apply(RelDataTypeField input) {
+                  return new RexInputRef(input.getIndex(), input.getType());
+                }
+              });
+          originalRR = out_rwsch.duplicate();
+          for (int i = 0; i < inputRR.getColumnInfos().size(); i++) {
+            ColumnInfo colInfo = new ColumnInfo(inputRR.getColumnInfos().get(i));
+            String internalName = SemanticAnalyzer.getColumnInternalName(out_rwsch.getColumnInfos()
+                .size() + i);
+            colInfo.setInternalName(internalName);
+            // if there is any confict, then we do not generate it in the new select
+            // otherwise, we add it into the calciteColLst and generate the new select
+            if (!out_rwsch.putWithCheck(colInfo.getTabAlias(), colInfo.getAlias(), internalName,
+                colInfo)) {
+              LOG.trace("Column already present in RR. skipping.");
+            } else {
+              calciteColLst.add(originalInputRefs.get(i));
+            }
+          }
+          outputRel = genSelectRelNode(calciteColLst, out_rwsch, srcRel);
+          // outputRel is the generated augmented select with extra unselected
+          // columns, and originalRR is the original generated select
+          return new Pair<RelNode, RowResolver>(outputRel, originalRR);
+        } else {
+          outputRel = genSelectRelNode(calciteColLst, out_rwsch, srcRel);
+        }
       }
-
       // 9. Handle select distinct as GBY if there exist windowing functions
       if (selForWindow != null && selExprList.getToken().getType() == HiveParser.TOK_SELECTDI) {
         ImmutableBitSet groupSet = ImmutableBitSet.range(outputRel.getRowType().getFieldList().size());
@@ -3824,7 +3924,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
         this.relToHiveRR.put(outputRel, groupByOutputRowResolver);
       }
 
-      return outputRel;
+      return new Pair<RelNode, RowResolver>(outputRel, null);
     }
 
     private RelNode genUDTFPlan(GenericUDTF genericUDTF, String genericUDTFName, String outputTableAlias,
@@ -4051,51 +4151,19 @@ public class CalcitePlanner extends SemanticAnalyzer {
       srcRel = (gbHavingRel == null) ? srcRel : gbHavingRel;
 
       // 5. Build Rel for Select Clause
-      selectRel = genSelectLogicalPlan(qb, srcRel, starSrcRel, outerNameToPosMap, outerRR);
+      Pair<RelNode, RowResolver> selPair = genSelectLogicalPlan(qb, srcRel, starSrcRel, outerNameToPosMap, outerRR, false);
+      selectRel = selPair.getKey();
       srcRel = (selectRel == null) ? srcRel : selectRel;
 
       // 6. Build Rel for OB Clause
-      Pair<RelNode, RelNode> obTopProjPair = genOBLogicalPlan(qb, srcRel, outerMostQB);
-      obRel = obTopProjPair.getKey();
-      RelNode topConstrainingProjArgsRel = obTopProjPair.getValue();
+      obRel = genOBLogicalPlan(qb, selPair, outerMostQB);
       srcRel = (obRel == null) ? srcRel : obRel;
 
       // 7. Build Rel for Limit Clause
       limitRel = genLimitLogicalPlan(qb, srcRel);
       srcRel = (limitRel == null) ? srcRel : limitRel;
 
-      // 8. Introduce top constraining select if needed.
-      // NOTES:
-      // 1. Calcite can not take an expr in OB; hence it needs to be added as VC
-      // in the input select; In such cases we need to introduce a select on top
-      // to ensure VC is not visible beyond Limit, OB.
-      // 2. Hive can not preserve order across select. In subqueries OB is used
-      // to get a deterministic set of tuples from following limit. Hence we
-      // introduce the constraining select above Limit (if present) instead of
-      // OB.
-      // 3. The top level OB will not introduce constraining select due to Hive
-      // limitation(#2) stated above. The RR for OB will not include VC. Thus
-      // Result Schema will not include exprs used by top OB. During AST Conv,
-      // in the PlanModifierForASTConv we would modify the top level OB to
-      // migrate exprs from input sel to SortRel (Note that Calcite doesn't
-      // support this; but since we are done with Calcite at this point its OK).
-      if (topConstrainingProjArgsRel != null) {
-        List<RexNode> originalInputRefs = Lists.transform(topConstrainingProjArgsRel.getRowType()
-            .getFieldList(), new Function<RelDataTypeField, RexNode>() {
-          @Override
-          public RexNode apply(RelDataTypeField input) {
-            return new RexInputRef(input.getIndex(), input.getType());
-          }
-        });
-        RowResolver topConstrainingProjRR = new RowResolver();
-        if (!RowResolver.add(topConstrainingProjRR,
-            this.relToHiveRR.get(topConstrainingProjArgsRel))) {
-          LOG.warn("Duplicates detected when adding columns to RR: see previous message");
-        }
-        srcRel = genSelectRelNode(originalInputRefs, topConstrainingProjRR, srcRel);
-      }
-
-      // 9. Incase this QB corresponds to subquery then modify its RR to point
+      // 8. Incase this QB corresponds to subquery then modify its RR to point
       // to subquery alias
       // TODO: cleanup this
       if (qb.getParseInfo().getAlias() != null) {

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index d68f832..43a61ce 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -1617,6 +1617,9 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
           throw new SemanticException(generateErrorMessage(ast,
               ErrorMsg.CLUSTERBY_ORDERBY_CONFLICT.getMsg()));
         }
+        // If there are aggregations in order by, we need to remember them in qb.
+        qbp.addAggregationExprsForClause(ctx_1.dest,
+            doPhase1GetAggregationsFromSelect(ast, qb, ctx_1.dest));
         break;
 
       case HiveParser.TOK_GROUPBY:

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java
index f678d0b..632b9c6 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java
@@ -163,7 +163,7 @@ public class TypeCheckProcFactory {
     if (colInfo != null) {
       desc = new ExprNodeColumnDesc(colInfo);
       ASTNode source = input.getExpressionSource(expr);
-      if (source != null) {
+      if (source != null && ctx.getUnparseTranslator() != null) {
         ctx.getUnparseTranslator().addCopyTranslation(expr, source);
       }
       return desc;

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/queries/clientpositive/order_by_expr_1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/order_by_expr_1.q b/ql/src/test/queries/clientpositive/order_by_expr_1.q
new file mode 100644
index 0000000..1d99e6a
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/order_by_expr_1.q
@@ -0,0 +1,44 @@
+set hive.fetch.task.conversion=none;
+
+create table t(a int, b int);
+
+insert into t values (1,2),(1,2),(1,3),(2,4),(20,-100),(-1000,100),(4,5),(3,7),(8,9);
+
+select a, count(a) from t group by a order by count(a), a;
+
+explain
+select
+  interval '2-2' year to month + interval '3-3' year to month,
+  interval '2-2' year to month - interval '3-3' year to month
+from t 
+order by interval '2-2' year to month + interval '3-3' year to month
+limit 2;
+
+select a,b, count(*) from t group by a, b order by a+b;
+select a,b, count(*) from t group by a, b order by count(*), b desc; 
+select a,b,count(*),a+b from t group by a, b order by a+b;
+select a,b from t order by a+b;
+select a,b,a+b from t order by a+b;
+select a,b,a+b from t order by a+b desc;
+select cast(0.99999999999999999999 as decimal(20,19)) as c from t limit 1;
+select cast(0.99999999999999999999 as decimal(20,19)) as c from t order by c limit 1;
+select a from t order by b;
+select a from t order by 0-b;
+select b from t order by 0-b;
+select b from t order by a, 0-b;
+select b from t order by a+1, 0-b;
+select b from t order by 0-b, a+1;
+explain select b from t order by 0-b, a+1;
+select a,b from t order by 0-b;
+select a,b from t order by a, a+1, 0-b;
+select a,b from t order by 0-b, a+1;
+select a+1,b from t order by a, a+1, 0-b;
+select a+1 as c, b from t order by a, a+1, 0-b;
+select a, a+1 as c, b from t order by a, a+1, 0-b;
+select a, a+1 as c, b, 2*b from t order by a, a+1, 0-b;
+explain select a, a+1 as c, b, 2*b from t order by a, a+1, 0-b;
+select a, a+1 as c, b, 2*b from t order by a+1, 0-b;
+select a,b, count(*) as c from t group by a, b order by c, a+b desc; 
+
+select a, max(b) from t group by a order by count(b), a desc; 
+select a, max(b) from t group by a order by count(b), a; 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/queries/clientpositive/order_by_expr_2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/order_by_expr_2.q b/ql/src/test/queries/clientpositive/order_by_expr_2.q
new file mode 100644
index 0000000..043f8ed
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/order_by_expr_2.q
@@ -0,0 +1,11 @@
+set hive.fetch.task.conversion=none;
+
+create table t(a int, b int);
+
+insert into t values (1,2),(1,2),(1,3),(2,4),(20,-100),(-1000,100),(4,5),(3,7),(8,9);
+
+select a as b, b as a from t order by a;
+select a as b, b as a from t order by t.a;
+select a as b from t order by b;
+select a as b from t order by 0-a;
+select a,b,count(*),a+b from t group by a, b order by a+b;

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/annotate_stats_select.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/annotate_stats_select.q.out b/ql/src/test/results/clientpositive/annotate_stats_select.q.out
index 873f1ab..67d134b 100644
--- a/ql/src/test/results/clientpositive/annotate_stats_select.q.out
+++ b/ql/src/test/results/clientpositive/annotate_stats_select.q.out
@@ -883,8 +883,7 @@ POSTHOOK: query: explain select h, 11.0 from (select hell as h from (select i1,
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
-  Stage-2 depends on stages: Stage-1
-  Stage-0 depends on stages: Stage-2
+  Stage-0 depends on stages: Stage-1
 
 STAGE PLANS:
   Stage: Stage-1
@@ -906,28 +905,6 @@ STAGE PLANS:
         Limit
           Number of rows: 10
           Statistics: Num rows: 2 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
-          Limit
-            Number of rows: 10
-            Statistics: Num rows: 2 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
-            File Output Operator
-              compressed: false
-              table:
-                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-
-  Stage: Stage-2
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              sort order: 
-              Statistics: Num rows: 2 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
-              TopN Hash Memory Usage: 0.1
-      Reduce Operator Tree:
-        Limit
-          Number of rows: 10
-          Statistics: Num rows: 2 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
           Select Operator
             expressions: 'hello' (type: string), 11 (type: int)
             outputColumnNames: _col0, _col1

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/cp_sel.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cp_sel.q.out b/ql/src/test/results/clientpositive/cp_sel.q.out
index 1778ccd..af2efeb 100644
--- a/ql/src/test/results/clientpositive/cp_sel.q.out
+++ b/ql/src/test/results/clientpositive/cp_sel.q.out
@@ -27,23 +27,27 @@ STAGE PLANS:
                 value expressions: _col1 (type: string)
       Reduce Operator Tree:
         Select Operator
-          expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string), 'hello' (type: string), 'world' (type: string)
-          outputColumnNames: _col0, _col1, _col2, _col3
+          expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string)
+          outputColumnNames: _col0, _col1
           Statistics: Num rows: 1000 Data size: 10624 Basic stats: COMPLETE Column stats: NONE
           Limit
             Number of rows: 1
             Statistics: Num rows: 1 Data size: 10 Basic stats: COMPLETE Column stats: NONE
-            File Output Operator
-              compressed: false
+            Select Operator
+              expressions: _col0 (type: string), _col1 (type: string), 'hello' (type: string), 'world' (type: string)
+              outputColumnNames: _col0, _col1, _col2, _col3
               Statistics: Num rows: 1 Data size: 10 Basic stats: COMPLETE Column stats: NONE
-              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
+              File Output Operator
+                compressed: false
+                Statistics: Num rows: 1 Data size: 10 Basic stats: COMPLETE Column stats: NONE
+                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
 
   Stage: Stage-0
     Fetch Operator
-      limit: 1
+      limit: -1
       Processor Tree:
         ListSink
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/druid_basic2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/druid_basic2.q.out b/ql/src/test/results/clientpositive/druid_basic2.q.out
index 6177d56..a3f05be 100644
--- a/ql/src/test/results/clientpositive/druid_basic2.q.out
+++ b/ql/src/test/results/clientpositive/druid_basic2.q.out
@@ -559,11 +559,11 @@ STAGE PLANS:
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             GatherStats: false
             Select Operator
-              expressions: robot (type: string), __time (type: timestamp), $f3 (type: float), $f4 (type: float)
-              outputColumnNames: _col0, _col1, _col2, _col3
+              expressions: robot (type: string), __time (type: timestamp), $f3 (type: float), $f4 (type: float), UDFToInteger(robot) (type: int)
+              outputColumnNames: _col0, _col1, _col2, _col3, _col5
               Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
               Reduce Output Operator
-                key expressions: UDFToInteger(_col0) (type: int), _col2 (type: float)
+                key expressions: _col5 (type: int), _col2 (type: float)
                 null sort order: az
                 sort order: +-
                 Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
@@ -632,7 +632,7 @@ STAGE PLANS:
               name: default.druid_table_1
             name: default.druid_table_1
       Truncated Path -> Alias:
-        /druid_table_1 [druid_table_1]
+        /druid_table_1 [$hdt$_0:druid_table_1]
       Needs Tagging: false
       Reduce Operator Tree:
         Select Operator
@@ -667,7 +667,7 @@ STAGE PLANS:
 
   Stage: Stage-0
     Fetch Operator
-      limit: 10
+      limit: -1
       Processor Tree:
         ListSink
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/dynamic_rdd_cache.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/dynamic_rdd_cache.q.out b/ql/src/test/results/clientpositive/dynamic_rdd_cache.q.out
index fc00309..1a0e46c 100644
--- a/ql/src/test/results/clientpositive/dynamic_rdd_cache.q.out
+++ b/ql/src/test/results/clientpositive/dynamic_rdd_cache.q.out
@@ -1109,7 +1109,7 @@ STAGE PLANS:
           Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
           Select Operator
             expressions: _col1 (type: int), _col2 (type: int), _col3 (type: double), _col4 (type: double), _col6 (type: int), _col7 (type: int), _col8 (type: double), _col9 (type: double)
-            outputColumnNames: _col0, _col1, _col3, _col4, _col5, _col6, _col8, _col9
+            outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             File Output Operator
               compressed: true
@@ -1123,10 +1123,10 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             Reduce Output Operator
-              key expressions: _col0 (type: int), _col1 (type: int), _col3 (type: double), _col4 (type: double), _col8 (type: double), _col9 (type: double)
+              key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: double), _col3 (type: double), _col6 (type: double), _col7 (type: double)
               sort order: ++++++
               Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
-              value expressions: _col5 (type: int), _col6 (type: int)
+              value expressions: _col4 (type: int), _col5 (type: int)
       Reduce Operator Tree:
         Select Operator
           expressions: KEY.reducesinkkey0 (type: int), KEY.reducesinkkey1 (type: int), 3 (type: int), KEY.reducesinkkey2 (type: double), KEY.reducesinkkey3 (type: double), VALUE._col0 (type: int), VALUE._col1 (type: int), 4 (type: int), KEY.reducesinkkey4 (type: double), KEY.reducesinkkey5 (type: double)

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out b/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out
index 473d17a..39dd731 100644
--- a/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out
+++ b/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out
@@ -317,8 +317,8 @@ STAGE PLANS:
             predicate: ((grouping(_col2, 1) = 1) or (grouping(_col2, 0) = 1)) (type: boolean)
             Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col0 (type: int), _col1 (type: int), (grouping(_col2, 1) + grouping(_col2, 0)) (type: int)
-              outputColumnNames: _col0, _col1, _col2
+              expressions: _col0 (type: int), _col1 (type: int), (grouping(_col2, 1) + grouping(_col2, 0)) (type: int), CASE WHEN (((grouping(_col2, 1) + grouping(_col2, 0)) = 1)) THEN (_col0) ELSE (null) END (type: int)
+              outputColumnNames: _col0, _col1, _col2, _col3
               Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
                 compressed: false
@@ -332,7 +332,7 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             Reduce Output Operator
-              key expressions: _col2 (type: int), CASE WHEN ((_col2 = 1)) THEN (_col0) ELSE (null) END (type: int)
+              key expressions: _col2 (type: int), _col3 (type: int)
               sort order: -+
               Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
               value expressions: _col0 (type: int), _col1 (type: int)

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/bucket_groupby.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/bucket_groupby.q.out b/ql/src/test/results/clientpositive/llap/bucket_groupby.q.out
index d724131..d68797f 100644
--- a/ql/src/test/results/clientpositive/llap/bucket_groupby.q.out
+++ b/ql/src/test/results/clientpositive/llap/bucket_groupby.q.out
@@ -1626,7 +1626,7 @@ STAGE PLANS:
 
   Stage: Stage-0
     Fetch Operator
-      limit: 10
+      limit: -1
       Processor Tree:
         ListSink
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/explainuser_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/explainuser_1.q.out b/ql/src/test/results/clientpositive/llap/explainuser_1.q.out
index f701cab..8b04bc9 100644
--- a/ql/src/test/results/clientpositive/llap/explainuser_1.q.out
+++ b/ql/src/test/results/clientpositive/llap/explainuser_1.q.out
@@ -358,13 +358,13 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 4 llap
-      File Output Operator [FS_38]
+      File Output Operator [FS_39]
         Select Operator [SEL_37] (rows=1 width=20)
           Output:["_col0","_col1","_col2"]
         <-Reducer 3 [SIMPLE_EDGE] llap
           SHUFFLE [RS_36]
-            Select Operator [SEL_35] (rows=1 width=20)
-              Output:["_col0","_col1","_col2"]
+            Select Operator [SEL_35] (rows=1 width=28)
+              Output:["_col0","_col1","_col2","_col3"]
               Group By Operator [GBY_34] (rows=1 width=20)
                 Output:["_col0","_col1","_col2"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1
               <-Reducer 2 [SIMPLE_EDGE] llap
@@ -376,14 +376,14 @@ Stage-0
                       Output:["_col1","_col4"]
                       Filter Operator [FIL_29] (rows=1 width=20)
                         predicate:(((_col3 + _col6) >= 0) and ((_col3 > 0) or (_col1 >= 0)))
-                        Merge Join Operator [MERGEJOIN_48] (rows=3 width=20)
+                        Merge Join Operator [MERGEJOIN_49] (rows=3 width=20)
                           Conds:RS_25._col0=RS_26._col0(Inner),RS_26._col0=RS_27._col0(Inner),Output:["_col1","_col3","_col4","_col6"]
                         <-Map 1 [SIMPLE_EDGE] llap
                           SHUFFLE [RS_25]
                             PartitionCols:_col0
                             Select Operator [SEL_2] (rows=18 width=84)
                               Output:["_col0","_col1"]
-                              Filter Operator [FIL_45] (rows=18 width=84)
+                              Filter Operator [FIL_46] (rows=18 width=84)
                                 predicate:key is not null
                                 TableScan [TS_0] (rows=20 width=84)
                                   default@cbo_t3,cbo_t3,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int"]
@@ -395,7 +395,7 @@ Stage-0
                             <-Reducer 9 [SIMPLE_EDGE] llap
                               SHUFFLE [RS_22]
                                 Select Operator [SEL_20] (rows=1 width=105)
-                                  Output:["_col0","_col1","_col2","_col3"]
+                                  Output:["_col0","_col1","_col2","_col5"]
                                   Group By Operator [GBY_19] (rows=1 width=101)
                                     Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
                                   <-Map 8 [SIMPLE_EDGE] llap
@@ -403,7 +403,7 @@ Stage-0
                                       PartitionCols:_col0, _col1, _col2
                                       Group By Operator [GBY_17] (rows=2 width=101)
                                         Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(c_int)"],keys:key, c_int, c_float
-                                        Filter Operator [FIL_47] (rows=5 width=93)
+                                        Filter Operator [FIL_48] (rows=5 width=93)
                                           predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)) and key is not null)
                                           TableScan [TS_14] (rows=20 width=88)
                                             default@cbo_t2,cbo_t2,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int","c_float"]
@@ -423,7 +423,7 @@ Stage-0
                                       PartitionCols:_col0, _col1, _col2
                                       Group By Operator [GBY_6] (rows=2 width=101)
                                         Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(c_int)"],keys:key, c_int, c_float
-                                        Filter Operator [FIL_46] (rows=5 width=93)
+                                        Filter Operator [FIL_47] (rows=5 width=93)
                                           predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)) and key is not null)
                                           TableScan [TS_3] (rows=20 width=88)
                                             default@cbo_t1,cbo_t1,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int","c_float"]
@@ -447,69 +447,71 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 4 llap
-      File Output Operator [FS_37]
+      File Output Operator [FS_38]
         Select Operator [SEL_36] (rows=1 width=20)
           Output:["_col0","_col1","_col2"]
         <-Reducer 3 [SIMPLE_EDGE] llap
           SHUFFLE [RS_35]
-            Group By Operator [GBY_33] (rows=1 width=20)
-              Output:["_col0","_col1","_col2"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1
-            <-Reducer 2 [SIMPLE_EDGE] llap
-              SHUFFLE [RS_32]
-                PartitionCols:_col0, _col1
-                Group By Operator [GBY_31] (rows=1 width=20)
-                  Output:["_col0","_col1","_col2"],aggregations:["count()"],keys:_col1, _col4
-                  Select Operator [SEL_30] (rows=1 width=20)
-                    Output:["_col1","_col4"]
-                    Filter Operator [FIL_26] (rows=1 width=20)
-                      predicate:(((_col3 + _col6) >= 0) and ((UDFToLong(_col1) + _col4) >= 0) and ((_col1 >= 1) or (_col4 >= 1)) and ((_col3 > 0) or (_col1 >= 0)))
-                      Merge Join Operator [MERGEJOIN_47] (rows=3 width=20)
-                        Conds:RS_22._col0=RS_23._col0(Inner),RS_23._col0=RS_24._col0(Inner),Output:["_col1","_col3","_col4","_col6"]
-                      <-Map 1 [SIMPLE_EDGE] llap
-                        SHUFFLE [RS_22]
-                          PartitionCols:_col0
-                          Select Operator [SEL_2] (rows=18 width=84)
-                            Output:["_col0","_col1"]
-                            Filter Operator [FIL_44] (rows=18 width=84)
-                              predicate:((c_int > 0) and key is not null)
-                              TableScan [TS_0] (rows=20 width=84)
-                                default@cbo_t3,cbo_t3,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int"]
-                      <-Reducer 7 [SIMPLE_EDGE] llap
-                        SHUFFLE [RS_23]
-                          PartitionCols:_col0
-                          Select Operator [SEL_12] (rows=1 width=97)
-                            Output:["_col0","_col1","_col2"]
-                          <-Reducer 6 [SIMPLE_EDGE] llap
-                            SHUFFLE [RS_11]
-                              Select Operator [SEL_9] (rows=1 width=105)
-                                Output:["_col0","_col1","_col2","_col3"]
-                                Group By Operator [GBY_8] (rows=1 width=101)
-                                  Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
-                                <-Map 5 [SIMPLE_EDGE] llap
-                                  SHUFFLE [RS_7]
-                                    PartitionCols:_col0, _col1, _col2
-                                    Group By Operator [GBY_6] (rows=1 width=101)
-                                      Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(c_int)"],keys:key, c_int, c_float
-                                      Filter Operator [FIL_45] (rows=2 width=93)
-                                        predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)) and (c_float > 0) and ((c_int >= 1) or (c_float >= 1)) and ((UDFToFloat(c_int) + c_float) >= 0) and key is not null)
-                                        TableScan [TS_3] (rows=20 width=88)
-                                          default@cbo_t1,cbo_t1,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int","c_float"]
-                      <-Reducer 9 [SIMPLE_EDGE] llap
-                        SHUFFLE [RS_24]
-                          PartitionCols:_col0
-                          Select Operator [SEL_20] (rows=1 width=89)
-                            Output:["_col0","_col1"]
-                            Group By Operator [GBY_19] (rows=1 width=93)
-                              Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
-                            <-Map 8 [SIMPLE_EDGE] llap
-                              SHUFFLE [RS_18]
-                                PartitionCols:_col0, _col1, _col2
-                                Group By Operator [GBY_17] (rows=1 width=93)
-                                  Output:["_col0","_col1","_col2"],keys:key, c_int, c_float
-                                  Filter Operator [FIL_46] (rows=2 width=93)
-                                    predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)) and (c_float > 0) and ((c_int >= 1) or (c_float >= 1)) and ((UDFToFloat(c_int) + c_float) >= 0) and key is not null)
-                                    TableScan [TS_14] (rows=20 width=88)
-                                      default@cbo_t2,cbo_t2,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int","c_float"]
+            Select Operator [SEL_34] (rows=1 width=28)
+              Output:["_col0","_col1","_col2","_col3"]
+              Group By Operator [GBY_33] (rows=1 width=20)
+                Output:["_col0","_col1","_col2"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1
+              <-Reducer 2 [SIMPLE_EDGE] llap
+                SHUFFLE [RS_32]
+                  PartitionCols:_col0, _col1
+                  Group By Operator [GBY_31] (rows=1 width=20)
+                    Output:["_col0","_col1","_col2"],aggregations:["count()"],keys:_col1, _col4
+                    Select Operator [SEL_30] (rows=1 width=20)
+                      Output:["_col1","_col4"]
+                      Filter Operator [FIL_26] (rows=1 width=20)
+                        predicate:(((_col3 + _col6) >= 0) and ((UDFToLong(_col1) + _col4) >= 0) and ((_col1 >= 1) or (_col4 >= 1)) and ((_col3 > 0) or (_col1 >= 0)))
+                        Merge Join Operator [MERGEJOIN_48] (rows=3 width=20)
+                          Conds:RS_22._col0=RS_23._col0(Inner),RS_23._col0=RS_24._col0(Inner),Output:["_col1","_col3","_col4","_col6"]
+                        <-Map 1 [SIMPLE_EDGE] llap
+                          SHUFFLE [RS_22]
+                            PartitionCols:_col0
+                            Select Operator [SEL_2] (rows=18 width=84)
+                              Output:["_col0","_col1"]
+                              Filter Operator [FIL_45] (rows=18 width=84)
+                                predicate:((c_int > 0) and key is not null)
+                                TableScan [TS_0] (rows=20 width=84)
+                                  default@cbo_t3,cbo_t3,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int"]
+                        <-Reducer 7 [SIMPLE_EDGE] llap
+                          SHUFFLE [RS_23]
+                            PartitionCols:_col0
+                            Select Operator [SEL_12] (rows=1 width=97)
+                              Output:["_col0","_col1","_col2"]
+                            <-Reducer 6 [SIMPLE_EDGE] llap
+                              SHUFFLE [RS_11]
+                                Select Operator [SEL_9] (rows=1 width=105)
+                                  Output:["_col0","_col1","_col2","_col5"]
+                                  Group By Operator [GBY_8] (rows=1 width=101)
+                                    Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                  <-Map 5 [SIMPLE_EDGE] llap
+                                    SHUFFLE [RS_7]
+                                      PartitionCols:_col0, _col1, _col2
+                                      Group By Operator [GBY_6] (rows=1 width=101)
+                                        Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(c_int)"],keys:key, c_int, c_float
+                                        Filter Operator [FIL_46] (rows=2 width=93)
+                                          predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)) and (c_float > 0) and ((c_int >= 1) or (c_float >= 1)) and ((UDFToFloat(c_int) + c_float) >= 0) and key is not null)
+                                          TableScan [TS_3] (rows=20 width=88)
+                                            default@cbo_t1,cbo_t1,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int","c_float"]
+                        <-Reducer 9 [SIMPLE_EDGE] llap
+                          SHUFFLE [RS_24]
+                            PartitionCols:_col0
+                            Select Operator [SEL_20] (rows=1 width=89)
+                              Output:["_col0","_col1"]
+                              Group By Operator [GBY_19] (rows=1 width=93)
+                                Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
+                              <-Map 8 [SIMPLE_EDGE] llap
+                                SHUFFLE [RS_18]
+                                  PartitionCols:_col0, _col1, _col2
+                                  Group By Operator [GBY_17] (rows=1 width=93)
+                                    Output:["_col0","_col1","_col2"],keys:key, c_int, c_float
+                                    Filter Operator [FIL_47] (rows=2 width=93)
+                                      predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)) and (c_float > 0) and ((c_int >= 1) or (c_float >= 1)) and ((UDFToFloat(c_int) + c_float) >= 0) and key is not null)
+                                      TableScan [TS_14] (rows=20 width=88)
+                                        default@cbo_t2,cbo_t2,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int","c_float"]
 
 PREHOOK: query: explain select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by b+c, a desc) cbo_t1 right outer join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0) cbo_t2 on cbo_t1.a=p right outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 2) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c
 PREHOOK: type: QUERY
@@ -560,7 +562,7 @@ Stage-0
                       <-Reducer 5 [SIMPLE_EDGE] llap
                         SHUFFLE [RS_11]
                           Select Operator [SEL_9] (rows=1 width=105)
-                            Output:["_col0","_col1","_col2","_col3"]
+                            Output:["_col0","_col1","_col2","_col5"]
                             Group By Operator [GBY_8] (rows=1 width=101)
                               Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
                             <-Map 4 [SIMPLE_EDGE] llap
@@ -644,7 +646,7 @@ Stage-0
                           <-Reducer 9 [SIMPLE_EDGE] llap
                             SHUFFLE [RS_22]
                               Select Operator [SEL_20] (rows=1 width=105)
-                                Output:["_col0","_col1","_col2","_col3"]
+                                Output:["_col0","_col1","_col2","_col5"]
                                 Group By Operator [GBY_19] (rows=1 width=101)
                                   Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
                                 <-Map 8 [SIMPLE_EDGE] llap
@@ -664,7 +666,7 @@ Stage-0
                           <-Reducer 6 [SIMPLE_EDGE] llap
                             SHUFFLE [RS_11]
                               Select Operator [SEL_9] (rows=1 width=105)
-                                Output:["_col0","_col1","_col2","_col3"]
+                                Output:["_col0","_col1","_col2","_col5"]
                                 Group By Operator [GBY_8] (rows=1 width=101)
                                   Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
                                 <-Map 5 [SIMPLE_EDGE] llap
@@ -1226,10 +1228,10 @@ Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:1
+    limit:-1
     Stage-1
       Reducer 3 llap
-      File Output Operator [FS_10]
+      File Output Operator [FS_11]
         Limit [LIM_9] (rows=1 width=97)
           Number of rows:1
           Select Operator [SEL_8] (rows=10 width=97)
@@ -1300,38 +1302,15 @@ POSTHOOK: query: explain select key from(select key from (select key from cbo_t1
 POSTHOOK: type: QUERY
 Plan optimized by CBO.
 
-Vertex dependency in root stage
-Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-Reducer 3 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
-
 Stage-0
   Fetch Operator
     limit:5
-    Stage-1
-      Reducer 3 llap
-      File Output Operator [FS_13]
-        Limit [LIM_12] (rows=5 width=85)
-          Number of rows:5
-          Limit [LIM_10] (rows=5 width=85)
-            Number of rows:5
-            Select Operator [SEL_9] (rows=5 width=85)
-              Output:["_col0"]
-            <-Reducer 2 [CUSTOM_SIMPLE_EDGE] llap
-              PARTITION_ONLY_SHUFFLE [RS_8]
-                Limit [LIM_7] (rows=5 width=85)
-                  Number of rows:5
-                  Limit [LIM_5] (rows=5 width=85)
-                    Number of rows:5
-                    Select Operator [SEL_4] (rows=5 width=85)
-                      Output:["_col0"]
-                    <-Map 1 [CUSTOM_SIMPLE_EDGE] llap
-                      PARTITION_ONLY_SHUFFLE [RS_3]
-                        Limit [LIM_2] (rows=5 width=85)
-                          Number of rows:5
-                          Select Operator [SEL_1] (rows=20 width=80)
-                            Output:["_col0"]
-                            TableScan [TS_0] (rows=20 width=80)
-                              default@cbo_t1,cbo_t1,Tbl:COMPLETE,Col:COMPLETE,Output:["key"]
+    Limit [LIM_2]
+      Number of rows:5
+      Select Operator [SEL_1]
+        Output:["_col0"]
+        TableScan [TS_0]
+          Output:["key"]
 
 PREHOOK: query: explain select key, c_int from(select key, c_int from (select key, c_int from cbo_t1 order by c_int limit 5)cbo_t1  order by c_int limit 5)cbo_t2  order by c_int limit 5
 PREHOOK: type: QUERY
@@ -1390,18 +1369,18 @@ Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:5
+    limit:-1
     Stage-1
       Reducer 6 llap
-      File Output Operator [FS_45]
-        Limit [LIM_44] (rows=1 width=20)
+      File Output Operator [FS_46]
+        Limit [LIM_44] (rows=1 width=28)
           Number of rows:5
-          Select Operator [SEL_43] (rows=1 width=20)
+          Select Operator [SEL_43] (rows=1 width=28)
             Output:["_col0","_col1","_col2"]
           <-Reducer 5 [SIMPLE_EDGE] llap
             SHUFFLE [RS_42]
-              Select Operator [SEL_41] (rows=1 width=20)
-                Output:["_col0","_col1","_col2"]
+              Select Operator [SEL_41] (rows=1 width=28)
+                Output:["_col0","_col1","_col2","_col3"]
                 Group By Operator [GBY_40] (rows=1 width=20)
                   Output:["_col0","_col1","_col2"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1
                 <-Reducer 4 [SIMPLE_EDGE] llap
@@ -1413,14 +1392,14 @@ Stage-0
                         Output:["_col4","_col6"]
                         Filter Operator [FIL_35] (rows=3 width=20)
                           predicate:(((_col3 > 0) or (_col6 >= 0)) and ((_col3 + _col1) >= 0))
-                          Merge Join Operator [MERGEJOIN_57] (rows=7 width=20)
+                          Merge Join Operator [MERGEJOIN_58] (rows=7 width=20)
                             Conds:RS_31._col0=RS_32._col0(Inner),RS_32._col0=RS_33._col0(Inner),Output:["_col1","_col3","_col4","_col6"]
                           <-Map 10 [SIMPLE_EDGE] llap
                             SHUFFLE [RS_33]
                               PartitionCols:_col0
                               Select Operator [SEL_30] (rows=18 width=84)
                                 Output:["_col0","_col1"]
-                                Filter Operator [FIL_56] (rows=18 width=84)
+                                Filter Operator [FIL_57] (rows=18 width=84)
                                   predicate:key is not null
                                   TableScan [TS_28] (rows=20 width=84)
                                     default@cbo_t3,cbo_t3,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int"]
@@ -1436,7 +1415,7 @@ Stage-0
                                   <-Reducer 2 [SIMPLE_EDGE] llap
                                     SHUFFLE [RS_8]
                                       Select Operator [SEL_6] (rows=3 width=105)
-                                        Output:["_col0","_col1","_col2","_col3"]
+                                        Output:["_col0","_col1","_col2","_col5"]
                                         Group By Operator [GBY_5] (rows=3 width=101)
                                           Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
                                         <-Map 1 [SIMPLE_EDGE] llap
@@ -1444,7 +1423,7 @@ Stage-0
                                             PartitionCols:_col0, _col1, _col2
                                             Group By Operator [GBY_3] (rows=3 width=101)
                                               Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(c_int)"],keys:key, c_int, c_float
-                                              Filter Operator [FIL_53] (rows=6 width=93)
+                                              Filter Operator [FIL_54] (rows=6 width=93)
                                                 predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)))
                                                 TableScan [TS_0] (rows=20 width=88)
                                                   default@cbo_t2,cbo_t2,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int","c_float"]
@@ -1468,7 +1447,7 @@ Stage-0
                                             PartitionCols:_col0, _col1, _col2
                                             Group By Operator [GBY_17] (rows=3 width=101)
                                               Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(c_int)"],keys:key, c_int, c_float
-                                              Filter Operator [FIL_55] (rows=6 width=93)
+                                              Filter Operator [FIL_56] (rows=6 width=93)
                                                 predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)))
                                                 TableScan [TS_14] (rows=20 width=88)
                                                   default@cbo_t1,cbo_t1,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int","c_float"]
@@ -1603,12 +1582,12 @@ Stage-0
                     <-Map 10 [SIMPLE_EDGE] llap
                       SHUFFLE [RS_32]
                         PartitionCols:_col0
-                        Group By Operator [GBY_29] (rows=3 width=85)
+                        Group By Operator [GBY_29] (rows=6 width=85)
                           Output:["_col0"],keys:_col0
-                          Select Operator [SEL_25] (rows=6 width=85)
+                          Select Operator [SEL_25] (rows=18 width=80)
                             Output:["_col0"]
-                            Filter Operator [FIL_50] (rows=6 width=85)
-                              predicate:(UDFToDouble(key) > 0.0)
+                            Filter Operator [FIL_50] (rows=18 width=80)
+                              predicate:key is not null
                               TableScan [TS_23] (rows=20 width=80)
                                 default@cbo_t3,cbo_t3,Tbl:COMPLETE,Col:COMPLETE,Output:["key"]
                     <-Reducer 3 [SIMPLE_EDGE] llap
@@ -1618,8 +1597,8 @@ Stage-0
                           Output:["_col0","_col1"]
                         <-Reducer 2 [SIMPLE_EDGE] llap
                           SHUFFLE [RS_9]
-                            Select Operator [SEL_8] (rows=1 width=101)
-                              Output:["_col0","_col1","_col2"]
+                            Select Operator [SEL_8] (rows=1 width=109)
+                              Output:["_col0","_col1","_col4"]
                               Filter Operator [FIL_7] (rows=1 width=101)
                                 predicate:(((UDFToDouble(_col2) >= 1.0) or (_col3 >= 1)) and ((UDFToDouble(_col2) + UDFToDouble(_col3)) >= 0.0))
                                 Select Operator [SEL_6] (rows=1 width=101)
@@ -1645,7 +1624,7 @@ Stage-0
                           <-Reducer 8 [SIMPLE_EDGE] llap
                             SHUFFLE [RS_20]
                               Select Operator [SEL_18] (rows=1 width=93)
-                                Output:["_col0","_col1"]
+                                Output:["_col0","_col3"]
                                 Group By Operator [GBY_17] (rows=1 width=101)
                                   Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
                                 <-Map 7 [SIMPLE_EDGE] llap
@@ -1653,8 +1632,8 @@ Stage-0
                                     PartitionCols:_col0, _col1, _col2
                                     Group By Operator [GBY_15] (rows=1 width=101)
                                       Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(c_int)"],keys:key, c_int, c_float
-                                      Filter Operator [FIL_49] (rows=1 width=93)
-                                        predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)) and (c_float > 0) and ((c_int >= 1) or (c_float >= 1)) and ((UDFToFloat(c_int) + c_float) >= 0) and (UDFToDouble(key) > 0.0))
+                                      Filter Operator [FIL_49] (rows=2 width=93)
+                                        predicate:(((c_int + 1) >= 0) and ((c_int > 0) or (c_float >= 0)) and (c_float > 0) and ((c_int >= 1) or (c_float >= 1)) and ((UDFToFloat(c_int) + c_float) >= 0) and key is not null)
                                         TableScan [TS_12] (rows=20 width=88)
                                           default@cbo_t2,cbo_t2,Tbl:COMPLETE,Col:COMPLETE,Output:["key","c_int","c_float"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/limit_pushdown.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/limit_pushdown.q.out b/ql/src/test/results/clientpositive/llap/limit_pushdown.q.out
index 0a8df61..57594e0 100644
--- a/ql/src/test/results/clientpositive/llap/limit_pushdown.q.out
+++ b/ql/src/test/results/clientpositive/llap/limit_pushdown.q.out
@@ -1341,11 +1341,11 @@ STAGE PLANS:
                 Select Operator
                   expressions: _col1 (type: double)
                   outputColumnNames: _col0
-                  Statistics: Num rows: 500 Data size: 4000 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 500 Data size: 96000 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
                     key expressions: _col0 (type: double)
                     sort order: +
-                    Statistics: Num rows: 500 Data size: 4000 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 500 Data size: 96000 Basic stats: COMPLETE Column stats: COMPLETE
                     TopN Hash Memory Usage: 2.0E-5
         Reducer 3 
             Execution mode: llap
@@ -1367,7 +1367,7 @@ STAGE PLANS:
 
   Stage: Stage-0
     Fetch Operator
-      limit: 100
+      limit: -1
       Processor Tree:
         ListSink
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/limit_pushdown3.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/limit_pushdown3.q.out b/ql/src/test/results/clientpositive/llap/limit_pushdown3.q.out
index 24645b6..351ee01 100644
--- a/ql/src/test/results/clientpositive/llap/limit_pushdown3.q.out
+++ b/ql/src/test/results/clientpositive/llap/limit_pushdown3.q.out
@@ -1283,11 +1283,11 @@ STAGE PLANS:
                 Select Operator
                   expressions: _col1 (type: double)
                   outputColumnNames: _col0
-                  Statistics: Num rows: 500 Data size: 4000 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 500 Data size: 96000 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
                     key expressions: _col0 (type: double)
                     sort order: +
-                    Statistics: Num rows: 500 Data size: 4000 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 500 Data size: 96000 Basic stats: COMPLETE Column stats: COMPLETE
                     TopN Hash Memory Usage: 2.0E-5
         Reducer 3 
             Execution mode: llap
@@ -1309,7 +1309,7 @@ STAGE PLANS:
 
   Stage: Stage-0
     Fetch Operator
-      limit: 100
+      limit: -1
       Processor Tree:
         ListSink
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/offset_limit_ppd_optimizer.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/offset_limit_ppd_optimizer.q.out b/ql/src/test/results/clientpositive/llap/offset_limit_ppd_optimizer.q.out
index 77062c7..c89ca6b 100644
--- a/ql/src/test/results/clientpositive/llap/offset_limit_ppd_optimizer.q.out
+++ b/ql/src/test/results/clientpositive/llap/offset_limit_ppd_optimizer.q.out
@@ -1166,11 +1166,11 @@ STAGE PLANS:
                 Select Operator
                   expressions: _col1 (type: double)
                   outputColumnNames: _col0
-                  Statistics: Num rows: 500 Data size: 4000 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 500 Data size: 96000 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
                     key expressions: _col0 (type: double)
                     sort order: +
-                    Statistics: Num rows: 500 Data size: 4000 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 500 Data size: 96000 Basic stats: COMPLETE Column stats: COMPLETE
                     TopN Hash Memory Usage: 2.0E-5
         Reducer 3 
             Execution mode: llap
@@ -1193,7 +1193,7 @@ STAGE PLANS:
 
   Stage: Stage-0
     Fetch Operator
-      limit: 70
+      limit: -1
       Processor Tree:
         ListSink
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/subquery_in.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/subquery_in.q.out b/ql/src/test/results/clientpositive/llap/subquery_in.q.out
index d7fd29e..1f9c9e4 100644
--- a/ql/src/test/results/clientpositive/llap/subquery_in.q.out
+++ b/ql/src/test/results/clientpositive/llap/subquery_in.q.out
@@ -3315,13 +3315,13 @@ STAGE PLANS:
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 1 Data size: 223 Basic stats: COMPLETE Column stats: COMPLETE
                 Select Operator
-                  expressions: _col1 (type: string), _col0 (type: string), _col2 (type: int)
-                  outputColumnNames: _col0, _col1, _col2
-                  Statistics: Num rows: 1 Data size: 223 Basic stats: COMPLETE Column stats: COMPLETE
+                  expressions: _col0 (type: string), _col1 (type: string), _col2 (type: int)
+                  outputColumnNames: _col1, _col3, _col4
+                  Statistics: Num rows: 1 Data size: 325 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
-                    key expressions: _col0 (type: string), _col2 (type: int)
+                    key expressions: _col3 (type: string), _col4 (type: int)
                     sort order: ++
-                    Statistics: Num rows: 1 Data size: 223 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 1 Data size: 325 Basic stats: COMPLETE Column stats: COMPLETE
                     value expressions: _col1 (type: string)
         Reducer 3 
             Execution mode: llap

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/vector_coalesce.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_coalesce.q.out b/ql/src/test/results/clientpositive/llap/vector_coalesce.q.out
index 8402104..d6865dd 100644
--- a/ql/src/test/results/clientpositive/llap/vector_coalesce.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_coalesce.q.out
@@ -65,14 +65,18 @@ STAGE PLANS:
                 Select Vectorization:
                     className: VectorSelectOperator
                     native: true
-                    projectedOutputColumns: [5, 0, 1, 2, 3, 4]
-                    selectExpressions: ConstantVectorExpression(val null) -> 5:double
+                    projectedOutputColumns: [0, 1, 2, 3, 4]
                   Limit Vectorization:
                       className: VectorLimitOperator
                       native: true
-                    File Sink Vectorization:
-                        className: VectorFileSinkOperator
-                        native: false
+                    Select Vectorization:
+                        className: VectorSelectOperator
+                        native: true
+                        projectedOutputColumns: [5, 0, 1, 2, 3, 4]
+                        selectExpressions: ConstantVectorExpression(val null) -> 5:double
+                      File Sink Vectorization:
+                          className: VectorFileSinkOperator
+                          native: false
 
   Stage: Stage-0
     Fetch Operator
@@ -170,14 +174,18 @@ STAGE PLANS:
                 Select Vectorization:
                     className: VectorSelectOperator
                     native: true
-                    projectedOutputColumns: [3, 0, 1, 2]
-                    selectExpressions: ConstantVectorExpression(val null) -> 3:tinyint
+                    projectedOutputColumns: [0, 1, 2]
                   Limit Vectorization:
                       className: VectorLimitOperator
                       native: true
-                    File Sink Vectorization:
-                        className: VectorFileSinkOperator
-                        native: false
+                    Select Vectorization:
+                        className: VectorSelectOperator
+                        native: true
+                        projectedOutputColumns: [3, 0, 1, 2]
+                        selectExpressions: ConstantVectorExpression(val null) -> 3:tinyint
+                      File Sink Vectorization:
+                          className: VectorFileSinkOperator
+                          native: false
 
   Stage: Stage-0
     Fetch Operator
@@ -231,8 +239,6 @@ STAGE DEPENDENCIES:
 STAGE PLANS:
   Stage: Stage-1
     Tez
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -246,11 +252,14 @@ STAGE PLANS:
                       Select Vectorization:
                           className: VectorSelectOperator
                           native: true
-                          projectedOutputColumns: []
-                        Reduce Sink Vectorization:
-                            className: VectorReduceSinkEmptyKeyOperator
+                          projectedOutputColumns: [12, 13, 14]
+                          selectExpressions: ConstantVectorExpression(val null) -> 12:float, ConstantVectorExpression(val null) -> 13:bigint, ConstantVectorExpression(val 0.0) -> 14:double
+                        Limit Vectorization:
+                            className: VectorLimitOperator
                             native: true
-                            nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
+                          File Sink Vectorization:
+                              className: VectorFileSinkOperator
+                              native: false
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -258,30 +267,9 @@ STAGE PLANS:
                 enabledConditionsMet: hive.vectorized.use.vectorized.input.format IS true
                 groupByVectorOutput: true
                 inputFileFormats: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
-                allNative: true
-                usesVectorUDFAdaptor: false
-                vectorized: true
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Vectorization:
-                enabled: true
-                enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                groupByVectorOutput: true
                 allNative: false
                 usesVectorUDFAdaptor: false
                 vectorized: true
-            Reduce Operator Tree:
-                Select Vectorization:
-                    className: VectorSelectOperator
-                    native: true
-                    projectedOutputColumns: [0, 1, 2]
-                    selectExpressions: ConstantVectorExpression(val null) -> 0:float, ConstantVectorExpression(val null) -> 1:bigint, ConstantVectorExpression(val 0.0) -> 2:double
-                  Limit Vectorization:
-                      className: VectorLimitOperator
-                      native: true
-                    File Sink Vectorization:
-                        className: VectorFileSinkOperator
-                        native: false
 
   Stage: Stage-0
     Fetch Operator
@@ -439,8 +427,6 @@ STAGE DEPENDENCIES:
 STAGE PLANS:
   Stage: Stage-1
     Tez
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -454,11 +440,14 @@ STAGE PLANS:
                       Select Vectorization:
                           className: VectorSelectOperator
                           native: true
-                          projectedOutputColumns: []
-                        Reduce Sink Vectorization:
-                            className: VectorReduceSinkEmptyKeyOperator
+                          projectedOutputColumns: [12, 13, 14]
+                          selectExpressions: ConstantVectorExpression(val null) -> 12:float, ConstantVectorExpression(val null) -> 13:bigint, ConstantVectorExpression(val null) -> 14:float
+                        Limit Vectorization:
+                            className: VectorLimitOperator
                             native: true
-                            nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
+                          File Sink Vectorization:
+                              className: VectorFileSinkOperator
+                              native: false
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -466,30 +455,9 @@ STAGE PLANS:
                 enabledConditionsMet: hive.vectorized.use.vectorized.input.format IS true
                 groupByVectorOutput: true
                 inputFileFormats: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
-                allNative: true
-                usesVectorUDFAdaptor: false
-                vectorized: true
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Vectorization:
-                enabled: true
-                enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                groupByVectorOutput: true
                 allNative: false
                 usesVectorUDFAdaptor: false
                 vectorized: true
-            Reduce Operator Tree:
-                Select Vectorization:
-                    className: VectorSelectOperator
-                    native: true
-                    projectedOutputColumns: [0, 1, 2]
-                    selectExpressions: ConstantVectorExpression(val null) -> 0:float, ConstantVectorExpression(val null) -> 1:bigint, ConstantVectorExpression(val null) -> 2:float
-                  Limit Vectorization:
-                      className: VectorLimitOperator
-                      native: true
-                    File Sink Vectorization:
-                        className: VectorFileSinkOperator
-                        native: false
 
   Stage: Stage-0
     Fetch Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/vector_date_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_date_1.q.out b/ql/src/test/results/clientpositive/llap/vector_date_1.q.out
index a4f1050..e8f32af 100644
--- a/ql/src/test/results/clientpositive/llap/vector_date_1.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_date_1.q.out
@@ -632,9 +632,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -645,29 +642,18 @@ STAGE PLANS:
                     predicate: ((dt1 = 2001-01-01) and (2001-01-01 = dt1) and (dt1 <> 1970-01-01) and (1970-01-01 <> dt1) and (dt1 > 1970-01-01) and (dt1 >= 1970-01-01) and (1970-01-01 < dt1) and (1970-01-01 <= dt1)) (type: boolean)
                     Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: dt2 (type: date)
-                      outputColumnNames: _col1
+                      expressions: 2001-01-01 (type: date), dt2 (type: date)
+                      outputColumnNames: _col0, _col1
                       Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
-                      Reduce Output Operator
-                        sort order: 
+                      File Output Operator
+                        compressed: false
                         Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col1 (type: date)
+                        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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 2001-01-01 (type: date), VALUE._col0 (type: date)
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 74 Basic stats: COMPLETE Column stats: NONE
-                  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
 
   Stage: Stage-0
     Fetch Operator


[2/7] hive git commit: HIVE-15160: Can't order by an unselected column (Pengcheng Xiong, reviewed by Ashutosh Chauhan)

Posted by px...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query81.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query81.q.out b/ql/src/test/results/clientpositive/perf/query81.q.out
index dfd4639..3acee4d 100644
--- a/ql/src/test/results/clientpositive/perf/query81.q.out
+++ b/ql/src/test/results/clientpositive/perf/query81.q.out
@@ -72,143 +72,145 @@ Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 4
-      File Output Operator [FS_67]
-        Limit [LIM_66] (rows=100 width=860)
-          Number of rows:100
-          Select Operator [SEL_65] (rows=32266667 width=860)
-            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15"]
-          <-Reducer 3 [SIMPLE_EDGE]
-            SHUFFLE [RS_64]
-              Select Operator [SEL_63] (rows=32266667 width=860)
-                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col11","_col12","_col13","_col14","_col15"]
-                Filter Operator [FIL_62] (rows=32266667 width=860)
-                  predicate:(_col2 > CASE WHEN (_col22 is null) THEN (null) ELSE (_col21) END)
-                  Select Operator [SEL_61] (rows=96800003 width=860)
-                    Output:["_col2","_col4","_col5","_col6","_col7","_col8","_col9","_col11","_col12","_col13","_col14","_col16","_col18","_col19","_col20","_col21","_col22"]
-                    Merge Join Operator [MERGEJOIN_105] (rows=96800003 width=860)
-                      Conds:RS_58._col0=RS_59._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col14","_col15","_col16","_col17","_col20","_col21","_col22"]
-                    <-Reducer 10 [SIMPLE_EDGE]
-                      SHUFFLE [RS_59]
-                        PartitionCols:_col0
-                        Merge Join Operator [MERGEJOIN_104] (rows=24200000 width=1014)
-                          Conds:RS_51._col1=RS_52._col2(Left Outer),Output:["_col0","_col2","_col3","_col4"]
-                        <-Reducer 13 [SIMPLE_EDGE]
-                          SHUFFLE [RS_52]
-                            PartitionCols:_col2
-                            Select Operator [SEL_50] (rows=11000000 width=1014)
-                              Output:["_col0","_col1","_col2"]
-                              Group By Operator [GBY_49] (rows=11000000 width=1014)
-                                Output:["_col0","_col1"],aggregations:["avg(_col2)"],keys:_col0
-                                Select Operator [SEL_45] (rows=22000000 width=1014)
-                                  Output:["_col0","_col2"]
-                                  Group By Operator [GBY_44] (rows=22000000 width=1014)
-                                    Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
-                                  <-Reducer 12 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_43]
-                                      PartitionCols:_col0
-                                      Group By Operator [GBY_42] (rows=44000000 width=1014)
-                                        Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col7, _col1
-                                        Merge Join Operator [MERGEJOIN_103] (rows=44000000 width=1014)
-                                          Conds:RS_38._col2=RS_39._col0(Inner),Output:["_col1","_col3","_col7"]
-                                        <-Map 15 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_39]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_34] (rows=40000000 width=1014)
-                                              Output:["_col0","_col1"]
-                                              Filter Operator [FIL_98] (rows=40000000 width=1014)
-                                                predicate:(ca_address_sk is not null and ca_state is not null)
-                                                TableScan [TS_12] (rows=40000000 width=1014)
-                                                  default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state"]
-                                        <-Reducer 11 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_38]
-                                            PartitionCols:_col2
-                                            Merge Join Operator [MERGEJOIN_102] (rows=31678769 width=106)
-                                              Conds:RS_35._col0=RS_36._col0(Inner),Output:["_col1","_col2","_col3"]
-                                            <-Map 14 [SIMPLE_EDGE]
-                                              SHUFFLE [RS_36]
-                                                PartitionCols:_col0
-                                                Select Operator [SEL_31] (rows=36524 width=1119)
-                                                  Output:["_col0"]
-                                                  Filter Operator [FIL_97] (rows=36524 width=1119)
-                                                    predicate:((d_year = 1998) and d_date_sk is not null)
-                                                    TableScan [TS_9] (rows=73049 width=1119)
-                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
-                                            <-Map 6 [SIMPLE_EDGE]
-                                              SHUFFLE [RS_35]
-                                                PartitionCols:_col0
-                                                Select Operator [SEL_28] (rows=28798881 width=106)
-                                                  Output:["_col0","_col1","_col2","_col3"]
-                                                  Filter Operator [FIL_96] (rows=28798881 width=106)
-                                                    predicate:(cr_returned_date_sk is not null and cr_returning_addr_sk is not null)
-                                                    TableScan [TS_6] (rows=28798881 width=106)
-                                                      default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_returned_date_sk","cr_returning_customer_sk","cr_returning_addr_sk","cr_return_amt_inc_tax"]
-                        <-Reducer 9 [SIMPLE_EDGE]
-                          SHUFFLE [RS_51]
-                            PartitionCols:_col1
-                            Select Operator [SEL_25] (rows=22000000 width=1014)
-                              Output:["_col0","_col1","_col2"]
-                              Group By Operator [GBY_24] (rows=22000000 width=1014)
-                                Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
-                              <-Reducer 8 [SIMPLE_EDGE]
-                                SHUFFLE [RS_23]
-                                  PartitionCols:_col0, _col1
-                                  Group By Operator [GBY_22] (rows=44000000 width=1014)
-                                    Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col7, _col1
-                                    Merge Join Operator [MERGEJOIN_101] (rows=44000000 width=1014)
-                                      Conds:RS_18._col2=RS_19._col0(Inner),Output:["_col1","_col3","_col7"]
-                                    <-Map 15 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_19]
+      File Output Operator [FS_68]
+        Select Operator [SEL_67] (rows=100 width=860)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15"]
+          Limit [LIM_66] (rows=100 width=860)
+            Number of rows:100
+            Select Operator [SEL_65] (rows=32266667 width=860)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
+            <-Reducer 3 [SIMPLE_EDGE]
+              SHUFFLE [RS_64]
+                Select Operator [SEL_63] (rows=32266667 width=860)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
+                  Filter Operator [FIL_62] (rows=32266667 width=860)
+                    predicate:(_col2 > CASE WHEN (_col22 is null) THEN (null) ELSE (_col21) END)
+                    Select Operator [SEL_61] (rows=96800003 width=860)
+                      Output:["_col2","_col4","_col5","_col6","_col7","_col8","_col9","_col11","_col12","_col13","_col14","_col16","_col18","_col19","_col20","_col21","_col22"]
+                      Merge Join Operator [MERGEJOIN_106] (rows=96800003 width=860)
+                        Conds:RS_58._col0=RS_59._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col14","_col15","_col16","_col17","_col20","_col21","_col22"]
+                      <-Reducer 10 [SIMPLE_EDGE]
+                        SHUFFLE [RS_59]
+                          PartitionCols:_col0
+                          Merge Join Operator [MERGEJOIN_105] (rows=24200000 width=1014)
+                            Conds:RS_51._col1=RS_52._col2(Left Outer),Output:["_col0","_col2","_col3","_col4"]
+                          <-Reducer 13 [SIMPLE_EDGE]
+                            SHUFFLE [RS_52]
+                              PartitionCols:_col2
+                              Select Operator [SEL_50] (rows=11000000 width=1014)
+                                Output:["_col0","_col1","_col2"]
+                                Group By Operator [GBY_49] (rows=11000000 width=1014)
+                                  Output:["_col0","_col1"],aggregations:["avg(_col2)"],keys:_col0
+                                  Select Operator [SEL_45] (rows=22000000 width=1014)
+                                    Output:["_col0","_col2"]
+                                    Group By Operator [GBY_44] (rows=22000000 width=1014)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                    <-Reducer 12 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_43]
                                         PartitionCols:_col0
-                                        Select Operator [SEL_14] (rows=40000000 width=1014)
-                                          Output:["_col0","_col1"]
-                                          Filter Operator [FIL_95] (rows=40000000 width=1014)
-                                            predicate:ca_address_sk is not null
-                                             Please refer to the previous TableScan [TS_12]
-                                    <-Reducer 7 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_18]
-                                        PartitionCols:_col2
-                                        Merge Join Operator [MERGEJOIN_100] (rows=31678769 width=106)
-                                          Conds:RS_15._col0=RS_16._col0(Inner),Output:["_col1","_col2","_col3"]
-                                        <-Map 14 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_16]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_11] (rows=36524 width=1119)
-                                              Output:["_col0"]
-                                              Filter Operator [FIL_94] (rows=36524 width=1119)
-                                                predicate:((d_year = 1998) and d_date_sk is not null)
-                                                 Please refer to the previous TableScan [TS_9]
-                                        <-Map 6 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_15]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_8] (rows=28798881 width=106)
-                                              Output:["_col0","_col1","_col2","_col3"]
-                                              Filter Operator [FIL_93] (rows=28798881 width=106)
-                                                predicate:(cr_returned_date_sk is not null and cr_returning_addr_sk is not null and cr_returning_customer_sk is not null)
-                                                 Please refer to the previous TableScan [TS_6]
-                    <-Reducer 2 [SIMPLE_EDGE]
-                      SHUFFLE [RS_58]
-                        PartitionCols:_col0
-                        Merge Join Operator [MERGEJOIN_99] (rows=88000001 width=860)
-                          Conds:RS_55._col2=RS_56._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col14","_col15","_col16","_col17"]
-                        <-Map 1 [SIMPLE_EDGE]
-                          SHUFFLE [RS_55]
-                            PartitionCols:_col2
-                            Select Operator [SEL_2] (rows=80000000 width=860)
-                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                              Filter Operator [FIL_91] (rows=80000000 width=860)
-                                predicate:(c_customer_sk is not null and c_current_addr_sk is not null)
-                                TableScan [TS_0] (rows=80000000 width=860)
-                                  default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_customer_id","c_current_addr_sk","c_salutation","c_first_name","c_last_name"]
-                        <-Map 5 [SIMPLE_EDGE]
-                          SHUFFLE [RS_56]
-                            PartitionCols:_col0
-                            Select Operator [SEL_5] (rows=20000000 width=1014)
-                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col8","_col9","_col10","_col11"]
-                              Filter Operator [FIL_92] (rows=20000000 width=1014)
-                                predicate:((ca_state = 'IL') and ca_address_sk is not null)
-                                TableScan [TS_3] (rows=40000000 width=1014)
-                                  default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_street_number","ca_street_name","ca_street_type","ca_suite_number","ca_city","ca_county","ca_state","ca_zip","ca_country","ca_gmt_offset","ca_location_type"]
+                                        Group By Operator [GBY_42] (rows=44000000 width=1014)
+                                          Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col7, _col1
+                                          Merge Join Operator [MERGEJOIN_104] (rows=44000000 width=1014)
+                                            Conds:RS_38._col2=RS_39._col0(Inner),Output:["_col1","_col3","_col7"]
+                                          <-Map 15 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_39]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_34] (rows=40000000 width=1014)
+                                                Output:["_col0","_col1"]
+                                                Filter Operator [FIL_99] (rows=40000000 width=1014)
+                                                  predicate:(ca_address_sk is not null and ca_state is not null)
+                                                  TableScan [TS_12] (rows=40000000 width=1014)
+                                                    default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state"]
+                                          <-Reducer 11 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_38]
+                                              PartitionCols:_col2
+                                              Merge Join Operator [MERGEJOIN_103] (rows=31678769 width=106)
+                                                Conds:RS_35._col0=RS_36._col0(Inner),Output:["_col1","_col2","_col3"]
+                                              <-Map 14 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_36]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_31] (rows=36524 width=1119)
+                                                    Output:["_col0"]
+                                                    Filter Operator [FIL_98] (rows=36524 width=1119)
+                                                      predicate:((d_year = 1998) and d_date_sk is not null)
+                                                      TableScan [TS_9] (rows=73049 width=1119)
+                                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
+                                              <-Map 6 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_35]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_28] (rows=28798881 width=106)
+                                                    Output:["_col0","_col1","_col2","_col3"]
+                                                    Filter Operator [FIL_97] (rows=28798881 width=106)
+                                                      predicate:(cr_returned_date_sk is not null and cr_returning_addr_sk is not null)
+                                                      TableScan [TS_6] (rows=28798881 width=106)
+                                                        default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_returned_date_sk","cr_returning_customer_sk","cr_returning_addr_sk","cr_return_amt_inc_tax"]
+                          <-Reducer 9 [SIMPLE_EDGE]
+                            SHUFFLE [RS_51]
+                              PartitionCols:_col1
+                              Select Operator [SEL_25] (rows=22000000 width=1014)
+                                Output:["_col0","_col1","_col2"]
+                                Group By Operator [GBY_24] (rows=22000000 width=1014)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                <-Reducer 8 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_23]
+                                    PartitionCols:_col0, _col1
+                                    Group By Operator [GBY_22] (rows=44000000 width=1014)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col7, _col1
+                                      Merge Join Operator [MERGEJOIN_102] (rows=44000000 width=1014)
+                                        Conds:RS_18._col2=RS_19._col0(Inner),Output:["_col1","_col3","_col7"]
+                                      <-Map 15 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_19]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_14] (rows=40000000 width=1014)
+                                            Output:["_col0","_col1"]
+                                            Filter Operator [FIL_96] (rows=40000000 width=1014)
+                                              predicate:ca_address_sk is not null
+                                               Please refer to the previous TableScan [TS_12]
+                                      <-Reducer 7 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_18]
+                                          PartitionCols:_col2
+                                          Merge Join Operator [MERGEJOIN_101] (rows=31678769 width=106)
+                                            Conds:RS_15._col0=RS_16._col0(Inner),Output:["_col1","_col2","_col3"]
+                                          <-Map 14 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_16]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_11] (rows=36524 width=1119)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_95] (rows=36524 width=1119)
+                                                  predicate:((d_year = 1998) and d_date_sk is not null)
+                                                   Please refer to the previous TableScan [TS_9]
+                                          <-Map 6 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_15]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_8] (rows=28798881 width=106)
+                                                Output:["_col0","_col1","_col2","_col3"]
+                                                Filter Operator [FIL_94] (rows=28798881 width=106)
+                                                  predicate:(cr_returned_date_sk is not null and cr_returning_addr_sk is not null and cr_returning_customer_sk is not null)
+                                                   Please refer to the previous TableScan [TS_6]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        SHUFFLE [RS_58]
+                          PartitionCols:_col0
+                          Merge Join Operator [MERGEJOIN_100] (rows=88000001 width=860)
+                            Conds:RS_55._col2=RS_56._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col14","_col15","_col16","_col17"]
+                          <-Map 1 [SIMPLE_EDGE]
+                            SHUFFLE [RS_55]
+                              PartitionCols:_col2
+                              Select Operator [SEL_2] (rows=80000000 width=860)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                Filter Operator [FIL_92] (rows=80000000 width=860)
+                                  predicate:(c_customer_sk is not null and c_current_addr_sk is not null)
+                                  TableScan [TS_0] (rows=80000000 width=860)
+                                    default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_customer_id","c_current_addr_sk","c_salutation","c_first_name","c_last_name"]
+                          <-Map 5 [SIMPLE_EDGE]
+                            SHUFFLE [RS_56]
+                              PartitionCols:_col0
+                              Select Operator [SEL_5] (rows=20000000 width=1014)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col8","_col9","_col10","_col11"]
+                                Filter Operator [FIL_93] (rows=20000000 width=1014)
+                                  predicate:((ca_state = 'IL') and ca_address_sk is not null)
+                                  TableScan [TS_3] (rows=40000000 width=1014)
+                                    default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_street_number","ca_street_name","ca_street_type","ca_suite_number","ca_city","ca_county","ca_state","ca_zip","ca_country","ca_gmt_offset","ca_location_type"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query85.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query85.q.out b/ql/src/test/results/clientpositive/perf/query85.q.out
index ba8659e..82df27b 100644
--- a/ql/src/test/results/clientpositive/perf/query85.q.out
+++ b/ql/src/test/results/clientpositive/perf/query85.q.out
@@ -17,10 +17,10 @@ Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 10
-      File Output Operator [FS_55]
+      File Output Operator [FS_56]
         Limit [LIM_54] (rows=100 width=385)
           Number of rows:100
           Select Operator [SEL_53] (rows=1023990 width=385)
@@ -36,14 +36,14 @@ Stage-0
                     PartitionCols:_col0
                     Group By Operator [GBY_48] (rows=2047980 width=385)
                       Output:["_col0","_col1","_col2","_col3"],aggregations:["avg(_col5)","avg(_col17)","avg(_col16)"],keys:_col19
-                      Merge Join Operator [MERGEJOIN_105] (rows=2047980 width=385)
+                      Merge Join Operator [MERGEJOIN_106] (rows=2047980 width=385)
                         Conds:RS_44._col13, _col24, _col25=RS_45._col0, _col1, _col2(Inner),Output:["_col5","_col16","_col17","_col19"]
                       <-Map 16 [SIMPLE_EDGE]
                         SHUFFLE [RS_45]
                           PartitionCols:_col0, _col1, _col2
                           Select Operator [SEL_23] (rows=1861800 width=385)
                             Output:["_col0","_col1","_col2"]
-                            Filter Operator [FIL_98] (rows=1861800 width=385)
+                            Filter Operator [FIL_99] (rows=1861800 width=385)
                               predicate:(((cd_education_status = '4 yr Degree') or (cd_education_status = 'Primary') or (cd_education_status = 'Advanced Degree')) and ((cd_marital_status = 'M') or (cd_marital_status = 'D') or (cd_marital_status = 'U')) and cd_demo_sk is not null and cd_marital_status is not null and cd_education_status is not null)
                               TableScan [TS_18] (rows=1861800 width=385)
                                 default@customer_demographics,cd1,Tbl:COMPLETE,Col:NONE,Output:["cd_demo_sk","cd_marital_status","cd_education_status"]
@@ -52,14 +52,14 @@ Stage-0
                           PartitionCols:_col13, _col24, _col25
                           Filter Operator [FIL_43] (rows=393687 width=135)
                             predicate:(((_col24 = 'M') and (_col25 = '4 yr Degree') and _col6 BETWEEN 100 AND 150) or ((_col24 = 'D') and (_col25 = 'Primary') and _col6 BETWEEN 50 AND 100) or ((_col24 = 'U') and (_col25 = 'Advanced Degree') and _col6 BETWEEN 150 AND 200))
-                            Merge Join Operator [MERGEJOIN_104] (rows=4724247 width=135)
+                            Merge Join Operator [MERGEJOIN_105] (rows=4724247 width=135)
                               Conds:RS_40._col11=RS_41._col0(Inner),Output:["_col5","_col6","_col13","_col16","_col17","_col19","_col24","_col25"]
                             <-Map 16 [SIMPLE_EDGE]
                               SHUFFLE [RS_41]
                                 PartitionCols:_col0
                                 Select Operator [SEL_20] (rows=1861800 width=385)
                                   Output:["_col0","_col1","_col2"]
-                                  Filter Operator [FIL_97] (rows=1861800 width=385)
+                                  Filter Operator [FIL_98] (rows=1861800 width=385)
                                     predicate:(((cd_education_status = '4 yr Degree') or (cd_education_status = 'Primary') or (cd_education_status = 'Advanced Degree')) and ((cd_marital_status = 'M') or (cd_marital_status = 'D') or (cd_marital_status = 'U')) and cd_demo_sk is not null and cd_marital_status is not null and cd_education_status is not null)
                                      Please refer to the previous TableScan [TS_18]
                             <-Reducer 6 [SIMPLE_EDGE]
@@ -67,70 +67,70 @@ Stage-0
                                 PartitionCols:_col11
                                 Filter Operator [FIL_39] (rows=4294770 width=135)
                                   predicate:(((_col21) IN ('KY', 'GA', 'NM') and _col7 BETWEEN 100 AND 200) or ((_col21) IN ('MT', 'OR', 'IN') and _col7 BETWEEN 150 AND 300) or ((_col21) IN ('WI', 'MO', 'WV') and _col7 BETWEEN 50 AND 250))
-                                  Merge Join Operator [MERGEJOIN_103] (rows=25768635 width=135)
+                                  Merge Join Operator [MERGEJOIN_104] (rows=25768635 width=135)
                                     Conds:RS_36._col12=RS_37._col0(Inner),Output:["_col5","_col6","_col7","_col11","_col13","_col16","_col17","_col19","_col21"]
                                   <-Map 15 [SIMPLE_EDGE]
                                     SHUFFLE [RS_37]
                                       PartitionCols:_col0
                                       Select Operator [SEL_17] (rows=10000000 width=1014)
                                         Output:["_col0","_col1"]
-                                        Filter Operator [FIL_96] (rows=10000000 width=1014)
+                                        Filter Operator [FIL_97] (rows=10000000 width=1014)
                                           predicate:((ca_state) IN ('KY', 'GA', 'NM', 'MT', 'OR', 'IN', 'WI', 'MO', 'WV') and (ca_country = 'United States') and ca_address_sk is not null)
                                           TableScan [TS_15] (rows=40000000 width=1014)
                                             default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state","ca_country"]
                                   <-Reducer 5 [SIMPLE_EDGE]
                                     SHUFFLE [RS_36]
                                       PartitionCols:_col12
-                                      Merge Join Operator [MERGEJOIN_102] (rows=23426032 width=135)
+                                      Merge Join Operator [MERGEJOIN_103] (rows=23426032 width=135)
                                         Conds:RS_33._col14=RS_34._col0(Inner),Output:["_col5","_col6","_col7","_col11","_col12","_col13","_col16","_col17","_col19"]
                                       <-Map 14 [SIMPLE_EDGE]
                                         SHUFFLE [RS_34]
                                           PartitionCols:_col0
                                           Select Operator [SEL_14] (rows=72 width=200)
                                             Output:["_col0","_col1"]
-                                            Filter Operator [FIL_95] (rows=72 width=200)
+                                            Filter Operator [FIL_96] (rows=72 width=200)
                                               predicate:r_reason_sk is not null
                                               TableScan [TS_12] (rows=72 width=200)
                                                 default@reason,reason,Tbl:COMPLETE,Col:NONE,Output:["r_reason_sk","r_reason_desc"]
                                       <-Reducer 4 [SIMPLE_EDGE]
                                         SHUFFLE [RS_33]
                                           PartitionCols:_col14
-                                          Merge Join Operator [MERGEJOIN_101] (rows=21296393 width=135)
+                                          Merge Join Operator [MERGEJOIN_102] (rows=21296393 width=135)
                                             Conds:RS_30._col2, _col4=RS_31._col0, _col5(Inner),Output:["_col5","_col6","_col7","_col11","_col12","_col13","_col14","_col16","_col17"]
                                           <-Map 13 [SIMPLE_EDGE]
                                             SHUFFLE [RS_31]
                                               PartitionCols:_col0, _col5
                                               Select Operator [SEL_11] (rows=14398467 width=92)
                                                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
-                                                Filter Operator [FIL_94] (rows=14398467 width=92)
+                                                Filter Operator [FIL_95] (rows=14398467 width=92)
                                                   predicate:(wr_item_sk is not null and wr_order_number is not null and wr_refunded_cdemo_sk is not null and wr_returning_cdemo_sk is not null and wr_refunded_addr_sk is not null and wr_reason_sk is not null)
                                                   TableScan [TS_9] (rows=14398467 width=92)
                                                     default@web_returns,web_returns,Tbl:COMPLETE,Col:NONE,Output:["wr_item_sk","wr_refunded_cdemo_sk","wr_refunded_addr_sk","wr_returning_cdemo_sk","wr_reason_sk","wr_order_number","wr_fee","wr_refunded_cash"]
                                           <-Reducer 3 [SIMPLE_EDGE]
                                             SHUFFLE [RS_30]
                                               PartitionCols:_col2, _col4
-                                              Merge Join Operator [MERGEJOIN_100] (rows=19360357 width=135)
+                                              Merge Join Operator [MERGEJOIN_101] (rows=19360357 width=135)
                                                 Conds:RS_27._col1=RS_28._col0(Inner),Output:["_col2","_col4","_col5","_col6","_col7"]
                                               <-Map 12 [SIMPLE_EDGE]
                                                 SHUFFLE [RS_28]
                                                   PartitionCols:_col0
                                                   Select Operator [SEL_8] (rows=36524 width=1119)
                                                     Output:["_col0"]
-                                                    Filter Operator [FIL_93] (rows=36524 width=1119)
+                                                    Filter Operator [FIL_94] (rows=36524 width=1119)
                                                       predicate:((d_year = 1998) and d_date_sk is not null)
                                                       TableScan [TS_6] (rows=73049 width=1119)
                                                         default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
                                               <-Reducer 2 [SIMPLE_EDGE]
                                                 SHUFFLE [RS_27]
                                                   PartitionCols:_col1
-                                                  Merge Join Operator [MERGEJOIN_99] (rows=17600325 width=135)
+                                                  Merge Join Operator [MERGEJOIN_100] (rows=17600325 width=135)
                                                     Conds:RS_24._col0=RS_25._col2(Inner),Output:["_col1","_col2","_col4","_col5","_col6","_col7"]
                                                   <-Map 1 [SIMPLE_EDGE]
                                                     SHUFFLE [RS_24]
                                                       PartitionCols:_col0
                                                       Select Operator [SEL_2] (rows=4602 width=585)
                                                         Output:["_col0"]
-                                                        Filter Operator [FIL_91] (rows=4602 width=585)
+                                                        Filter Operator [FIL_92] (rows=4602 width=585)
                                                           predicate:wp_web_page_sk is not null
                                                           TableScan [TS_0] (rows=4602 width=585)
                                                             default@web_page,web_page,Tbl:COMPLETE,Col:NONE,Output:["wp_web_page_sk"]
@@ -139,7 +139,7 @@ Stage-0
                                                       PartitionCols:_col2
                                                       Select Operator [SEL_5] (rows=16000296 width=135)
                                                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
-                                                        Filter Operator [FIL_92] (rows=16000296 width=135)
+                                                        Filter Operator [FIL_93] (rows=16000296 width=135)
                                                           predicate:((ws_sales_price BETWEEN 100 AND 150 or ws_sales_price BETWEEN 50 AND 100 or ws_sales_price BETWEEN 150 AND 200) and (ws_net_profit BETWEEN 100 AND 200 or ws_net_profit BETWEEN 150 AND 300 or ws_net_profit BETWEEN 50 AND 250) and ws_order_number is not null and ws_item_sk is not null and ws_web_page_sk is not null and ws_sold_date_sk is not null)
                                                           TableScan [TS_3] (rows=144002668 width=135)
                                                             default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_item_sk","ws_web_page_sk","ws_order_number","ws_quantity","ws_sales_price","ws_net_profit"]

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query86.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query86.q.out b/ql/src/test/results/clientpositive/perf/query86.q.out
index 734e6a4..bc86291 100644
--- a/ql/src/test/results/clientpositive/perf/query86.q.out
+++ b/ql/src/test/results/clientpositive/perf/query86.q.out
@@ -59,10 +59,10 @@ Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 6
-      File Output Operator [FS_29]
+      File Output Operator [FS_30]
         Limit [LIM_28] (rows=100 width=135)
           Number of rows:100
           Select Operator [SEL_27] (rows=261364852 width=135)
@@ -70,7 +70,7 @@ Stage-0
           <-Reducer 5 [SIMPLE_EDGE]
             SHUFFLE [RS_26]
               Select Operator [SEL_24] (rows=261364852 width=135)
-                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                 PTF Operator [PTF_23] (rows=261364852 width=135)
                   Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col4 DESC NULLS LAST","partition by:":"(grouping(_col5, 1) + grouping(_col5, 0)), CASE WHEN ((grouping(_col5, 0) = 0)) THEN (_col0) ELSE (null) END"}]
                   Select Operator [SEL_22] (rows=261364852 width=135)
@@ -89,28 +89,28 @@ Stage-0
                               Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col2)"],keys:_col0, _col1, 0
                               Select Operator [SEL_15] (rows=174243235 width=135)
                                 Output:["_col0","_col1","_col2"]
-                                Merge Join Operator [MERGEJOIN_39] (rows=174243235 width=135)
+                                Merge Join Operator [MERGEJOIN_40] (rows=174243235 width=135)
                                   Conds:RS_12._col1=RS_13._col0(Inner),Output:["_col2","_col6","_col7"]
                                 <-Map 8 [SIMPLE_EDGE]
                                   SHUFFLE [RS_13]
                                     PartitionCols:_col0
                                     Select Operator [SEL_8] (rows=462000 width=1436)
                                       Output:["_col0","_col1","_col2"]
-                                      Filter Operator [FIL_37] (rows=462000 width=1436)
+                                      Filter Operator [FIL_38] (rows=462000 width=1436)
                                         predicate:i_item_sk is not null
                                         TableScan [TS_6] (rows=462000 width=1436)
                                           default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_class","i_category"]
                                 <-Reducer 2 [SIMPLE_EDGE]
                                   SHUFFLE [RS_12]
                                     PartitionCols:_col1
-                                    Merge Join Operator [MERGEJOIN_38] (rows=158402938 width=135)
+                                    Merge Join Operator [MERGEJOIN_39] (rows=158402938 width=135)
                                       Conds:RS_9._col0=RS_10._col0(Inner),Output:["_col1","_col2"]
                                     <-Map 1 [SIMPLE_EDGE]
                                       SHUFFLE [RS_9]
                                         PartitionCols:_col0
                                         Select Operator [SEL_2] (rows=144002668 width=135)
                                           Output:["_col0","_col1","_col2"]
-                                          Filter Operator [FIL_35] (rows=144002668 width=135)
+                                          Filter Operator [FIL_36] (rows=144002668 width=135)
                                             predicate:(ws_sold_date_sk is not null and ws_item_sk is not null)
                                             TableScan [TS_0] (rows=144002668 width=135)
                                               default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_item_sk","ws_net_paid"]
@@ -119,7 +119,7 @@ Stage-0
                                         PartitionCols:_col0
                                         Select Operator [SEL_5] (rows=8116 width=1119)
                                           Output:["_col0"]
-                                          Filter Operator [FIL_36] (rows=8116 width=1119)
+                                          Filter Operator [FIL_37] (rows=8116 width=1119)
                                             predicate:(d_month_seq BETWEEN 1212 AND 1223 and d_date_sk is not null)
                                             TableScan [TS_3] (rows=73049 width=1119)
                                               default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_month_seq"]

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query89.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query89.q.out b/ql/src/test/results/clientpositive/perf/query89.q.out
index 66481f7..27467bd 100644
--- a/ql/src/test/results/clientpositive/perf/query89.q.out
+++ b/ql/src/test/results/clientpositive/perf/query89.q.out
@@ -64,10 +64,10 @@ Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 7
-      File Output Operator [FS_36]
+      File Output Operator [FS_37]
         Limit [LIM_35] (rows=100 width=88)
           Number of rows:100
           Select Operator [SEL_34] (rows=191662559 width=88)
@@ -75,8 +75,8 @@ Stage-0
           <-Reducer 6 [SIMPLE_EDGE]
             SHUFFLE [RS_33]
               Select Operator [SEL_30] (rows=191662559 width=88)
-                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
-                Filter Operator [FIL_46] (rows=191662559 width=88)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                Filter Operator [FIL_47] (rows=191662559 width=88)
                   predicate:CASE WHEN ((avg_window_0 <> 0)) THEN (((abs((_col6 - avg_window_0)) / avg_window_0) > 0.1)) ELSE (null) END
                   Select Operator [SEL_29] (rows=383325119 width=88)
                     Output:["avg_window_0","_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
@@ -96,42 +96,42 @@ Stage-0
                                 PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
                                 Group By Operator [GBY_22] (rows=766650239 width=88)
                                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col3)"],keys:_col5, _col6, _col7, _col10, _col12, _col13
-                                  Merge Join Operator [MERGEJOIN_53] (rows=766650239 width=88)
+                                  Merge Join Operator [MERGEJOIN_54] (rows=766650239 width=88)
                                     Conds:RS_18._col2=RS_19._col0(Inner),Output:["_col3","_col5","_col6","_col7","_col10","_col12","_col13"]
                                   <-Map 10 [SIMPLE_EDGE]
                                     SHUFFLE [RS_19]
                                       PartitionCols:_col0
                                       Select Operator [SEL_11] (rows=1704 width=1910)
                                         Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_50] (rows=1704 width=1910)
+                                        Filter Operator [FIL_51] (rows=1704 width=1910)
                                           predicate:s_store_sk is not null
                                           TableScan [TS_9] (rows=1704 width=1910)
                                             default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_store_name","s_company_name"]
                                   <-Reducer 3 [SIMPLE_EDGE]
                                     SHUFFLE [RS_18]
                                       PartitionCols:_col2
-                                      Merge Join Operator [MERGEJOIN_52] (rows=696954748 width=88)
+                                      Merge Join Operator [MERGEJOIN_53] (rows=696954748 width=88)
                                         Conds:RS_15._col0=RS_16._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col7","_col10"]
                                       <-Map 9 [SIMPLE_EDGE]
                                         SHUFFLE [RS_16]
                                           PartitionCols:_col0
                                           Select Operator [SEL_8] (rows=36525 width=1119)
                                             Output:["_col0","_col2"]
-                                            Filter Operator [FIL_49] (rows=36525 width=1119)
+                                            Filter Operator [FIL_50] (rows=36525 width=1119)
                                               predicate:((d_year) IN (2000) and d_date_sk is not null)
                                               TableScan [TS_6] (rows=73049 width=1119)
                                                 default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
                                       <-Reducer 2 [SIMPLE_EDGE]
                                         SHUFFLE [RS_15]
                                           PartitionCols:_col0
-                                          Merge Join Operator [MERGEJOIN_51] (rows=633595212 width=88)
+                                          Merge Join Operator [MERGEJOIN_52] (rows=633595212 width=88)
                                             Conds:RS_12._col1=RS_13._col0(Inner),Output:["_col0","_col2","_col3","_col5","_col6","_col7"]
                                           <-Map 1 [SIMPLE_EDGE]
                                             SHUFFLE [RS_12]
                                               PartitionCols:_col1
                                               Select Operator [SEL_2] (rows=575995635 width=88)
                                                 Output:["_col0","_col1","_col2","_col3"]
-                                                Filter Operator [FIL_47] (rows=575995635 width=88)
+                                                Filter Operator [FIL_48] (rows=575995635 width=88)
                                                   predicate:(ss_item_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
                                                   TableScan [TS_0] (rows=575995635 width=88)
                                                     default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_sales_price"]
@@ -140,7 +140,7 @@ Stage-0
                                               PartitionCols:_col0
                                               Select Operator [SEL_5] (rows=231000 width=1436)
                                                 Output:["_col0","_col1","_col2","_col3"]
-                                                Filter Operator [FIL_48] (rows=231000 width=1436)
+                                                Filter Operator [FIL_49] (rows=231000 width=1436)
                                                   predicate:(((i_class) IN ('wallpaper', 'parenting', 'musical') or (i_class) IN ('womens', 'birdal', 'pants')) and ((i_category) IN ('Home', 'Books', 'Electronics') or (i_category) IN ('Shoes', 'Jewelry', 'Men')) and (((i_category) IN ('Home', 'Books', 'Electronics') and (i_class) IN ('wallpaper', 'parenting', 'musical')) or ((i_category) IN ('Shoes', 'Jewelry', 'Men') and (i_class) IN ('womens', 'birdal', 'pants'))) and i_item_sk is not null)
                                                   TableScan [TS_3] (rows=462000 width=1436)
                                                     default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_brand","i_class","i_category"]

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query91.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query91.q.out b/ql/src/test/results/clientpositive/perf/query91.q.out
index e592bba..0ee7e43 100644
--- a/ql/src/test/results/clientpositive/perf/query91.q.out
+++ b/ql/src/test/results/clientpositive/perf/query91.q.out
@@ -19,7 +19,7 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 6
-      File Output Operator [FS_47]
+      File Output Operator [FS_48]
         Select Operator [SEL_46] (rows=58564004 width=860)
           Output:["_col0","_col1","_col2","_col3"]
         <-Reducer 5 [SIMPLE_EDGE]
@@ -33,49 +33,49 @@ Stage-0
                   PartitionCols:_col0, _col1, _col2, _col3, _col4
                   Group By Operator [GBY_41] (rows=117128008 width=860)
                     Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col3)"],keys:_col8, _col9, _col10, _col18, _col19
-                    Merge Join Operator [MERGEJOIN_81] (rows=117128008 width=860)
+                    Merge Join Operator [MERGEJOIN_82] (rows=117128008 width=860)
                       Conds:RS_37._col1=RS_38._col2(Inner),Output:["_col3","_col8","_col9","_col10","_col18","_col19"]
                     <-Reducer 12 [SIMPLE_EDGE]
                       SHUFFLE [RS_38]
                         PartitionCols:_col2
                         Select Operator [SEL_30] (rows=106480005 width=860)
                           Output:["_col2","_col7","_col8"]
-                          Merge Join Operator [MERGEJOIN_80] (rows=106480005 width=860)
+                          Merge Join Operator [MERGEJOIN_81] (rows=106480005 width=860)
                             Conds:RS_27._col2=RS_28._col0(Inner),Output:["_col0","_col5","_col6"]
                           <-Map 15 [SIMPLE_EDGE]
                             SHUFFLE [RS_28]
                               PartitionCols:_col0
                               Select Operator [SEL_20] (rows=3600 width=107)
                                 Output:["_col0"]
-                                Filter Operator [FIL_75] (rows=3600 width=107)
+                                Filter Operator [FIL_76] (rows=3600 width=107)
                                   predicate:((hd_buy_potential like '0-500%') and hd_demo_sk is not null)
                                   TableScan [TS_18] (rows=7200 width=107)
                                     default@household_demographics,household_demographics,Tbl:COMPLETE,Col:NONE,Output:["hd_demo_sk","hd_buy_potential"]
                           <-Reducer 11 [SIMPLE_EDGE]
                             SHUFFLE [RS_27]
                               PartitionCols:_col2
-                              Merge Join Operator [MERGEJOIN_79] (rows=96800003 width=860)
+                              Merge Join Operator [MERGEJOIN_80] (rows=96800003 width=860)
                                 Conds:RS_24._col3=RS_25._col0(Inner),Output:["_col0","_col2","_col5","_col6"]
                               <-Map 14 [SIMPLE_EDGE]
                                 SHUFFLE [RS_25]
                                   PartitionCols:_col0
                                   Select Operator [SEL_17] (rows=20000000 width=1014)
                                     Output:["_col0"]
-                                    Filter Operator [FIL_74] (rows=20000000 width=1014)
+                                    Filter Operator [FIL_75] (rows=20000000 width=1014)
                                       predicate:((ca_gmt_offset = -7) and ca_address_sk is not null)
                                       TableScan [TS_15] (rows=40000000 width=1014)
                                         default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_gmt_offset"]
                               <-Reducer 10 [SIMPLE_EDGE]
                                 SHUFFLE [RS_24]
                                   PartitionCols:_col3
-                                  Merge Join Operator [MERGEJOIN_78] (rows=88000001 width=860)
+                                  Merge Join Operator [MERGEJOIN_79] (rows=88000001 width=860)
                                     Conds:RS_21._col1=RS_22._col0(Inner),Output:["_col0","_col2","_col3","_col5","_col6"]
                                   <-Map 13 [SIMPLE_EDGE]
                                     SHUFFLE [RS_22]
                                       PartitionCols:_col0
                                       Select Operator [SEL_14] (rows=930900 width=385)
                                         Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_73] (rows=930900 width=385)
+                                        Filter Operator [FIL_74] (rows=930900 width=385)
                                           predicate:(((cd_education_status = 'Unknown') or (cd_education_status = 'Advanced Degree')) and ((cd_marital_status = 'M') or (cd_marital_status = 'W')) and (((cd_marital_status = 'M') and (cd_education_status = 'Unknown')) or ((cd_marital_status = 'W') and (cd_education_status = 'Advanced Degree'))) and cd_demo_sk is not null)
                                           TableScan [TS_12] (rows=1861800 width=385)
                                             default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:NONE,Output:["cd_demo_sk","cd_marital_status","cd_education_status"]
@@ -84,35 +84,35 @@ Stage-0
                                       PartitionCols:_col1
                                       Select Operator [SEL_11] (rows=80000000 width=860)
                                         Output:["_col0","_col1","_col2","_col3"]
-                                        Filter Operator [FIL_72] (rows=80000000 width=860)
+                                        Filter Operator [FIL_73] (rows=80000000 width=860)
                                           predicate:(c_customer_sk is not null and c_current_addr_sk is not null and c_current_cdemo_sk is not null and c_current_hdemo_sk is not null)
                                           TableScan [TS_9] (rows=80000000 width=860)
                                             default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_hdemo_sk","c_current_addr_sk"]
                     <-Reducer 3 [SIMPLE_EDGE]
                       SHUFFLE [RS_37]
                         PartitionCols:_col1
-                        Merge Join Operator [MERGEJOIN_77] (rows=34846646 width=106)
+                        Merge Join Operator [MERGEJOIN_78] (rows=34846646 width=106)
                           Conds:RS_34._col2=RS_35._col0(Inner),Output:["_col1","_col3","_col8","_col9","_col10"]
                         <-Map 8 [SIMPLE_EDGE]
                           SHUFFLE [RS_35]
                             PartitionCols:_col0
                             Select Operator [SEL_8] (rows=60 width=2045)
                               Output:["_col0","_col1","_col2","_col3"]
-                              Filter Operator [FIL_71] (rows=60 width=2045)
+                              Filter Operator [FIL_72] (rows=60 width=2045)
                                 predicate:cc_call_center_sk is not null
                                 TableScan [TS_6] (rows=60 width=2045)
                                   default@call_center,call_center,Tbl:COMPLETE,Col:NONE,Output:["cc_call_center_sk","cc_call_center_id","cc_name","cc_manager"]
                         <-Reducer 2 [SIMPLE_EDGE]
                           SHUFFLE [RS_34]
                             PartitionCols:_col2
-                            Merge Join Operator [MERGEJOIN_76] (rows=31678769 width=106)
+                            Merge Join Operator [MERGEJOIN_77] (rows=31678769 width=106)
                               Conds:RS_31._col0=RS_32._col0(Inner),Output:["_col1","_col2","_col3"]
                             <-Map 1 [SIMPLE_EDGE]
                               SHUFFLE [RS_31]
                                 PartitionCols:_col0
                                 Select Operator [SEL_2] (rows=28798881 width=106)
                                   Output:["_col0","_col1","_col2","_col3"]
-                                  Filter Operator [FIL_69] (rows=28798881 width=106)
+                                  Filter Operator [FIL_70] (rows=28798881 width=106)
                                     predicate:(cr_call_center_sk is not null and cr_returned_date_sk is not null and cr_returning_customer_sk is not null)
                                     TableScan [TS_0] (rows=28798881 width=106)
                                       default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_returned_date_sk","cr_returning_customer_sk","cr_call_center_sk","cr_net_loss"]
@@ -121,7 +121,7 @@ Stage-0
                                 PartitionCols:_col0
                                 Select Operator [SEL_5] (rows=18262 width=1119)
                                   Output:["_col0"]
-                                  Filter Operator [FIL_70] (rows=18262 width=1119)
+                                  Filter Operator [FIL_71] (rows=18262 width=1119)
                                     predicate:((d_year = 1999) and (d_moy = 11) and d_date_sk is not null)
                                     TableScan [TS_3] (rows=73049 width=1119)
                                       default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/pointlookup2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/pointlookup2.q.out b/ql/src/test/results/clientpositive/pointlookup2.q.out
index 3438c74..158e885 100644
--- a/ql/src/test/results/clientpositive/pointlookup2.q.out
+++ b/ql/src/test/results/clientpositive/pointlookup2.q.out
@@ -374,7 +374,7 @@ STAGE PLANS:
               name: default.pcr_t1
             name: default.pcr_t1
       Truncated Path -> Alias:
-        /pcr_t1/ds=2000-04-08 [$hdt$_0:t1, $hdt$_1:t2]
+        /pcr_t1/ds=2000-04-08 [$hdt$_0:$hdt$_0:t1, $hdt$_0:$hdt$_1:t2]
       Needs Tagging: true
       Reduce Operator Tree:
         Join Operator
@@ -385,24 +385,28 @@ STAGE PLANS:
             1 _col0 (type: int)
           outputColumnNames: _col0, _col1, _col3, _col4
           Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            GlobalTableId: 0
+          Select Operator
+            expressions: _col0 (type: int), _col1 (type: string), _col3 (type: int), _col4 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3
+            Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              GlobalTableId: 0
 #### A masked pattern was here ####
-            NumFilesPerFileSink: 1
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                properties:
-                  column.name.delimiter ,
-                  columns _col0,_col1,_col3,_col4
-                  columns.types int,string,int,string
-                  escape.delim \
-                  serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-            TotalFiles: 1
-            GatherStats: false
-            MultiFileSpray: false
+              NumFilesPerFileSink: 1
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  properties:
+                    column.name.delimiter ,
+                    columns _col0,_col1,_col2,_col3
+                    columns.types int,string,int,string
+                    escape.delim \
+                    serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+              TotalFiles: 1
+              GatherStats: false
+              MultiFileSpray: false
 
   Stage: Stage-2
     Map Reduce
@@ -415,7 +419,7 @@ STAGE PLANS:
               sort order: +
               Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
               tag: -1
-              value expressions: _col1 (type: string), _col3 (type: int), _col4 (type: string)
+              value expressions: _col1 (type: string), _col2 (type: int), _col3 (type: string)
               auto parallelism: false
       Path -> Alias:
 #### A masked pattern was here ####
@@ -427,7 +431,7 @@ STAGE PLANS:
             output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
             properties:
               column.name.delimiter ,
-              columns _col0,_col1,_col3,_col4
+              columns _col0,_col1,_col2,_col3
               columns.types int,string,int,string
               escape.delim \
               serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -437,7 +441,7 @@ STAGE PLANS:
               output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
               properties:
                 column.name.delimiter ,
-                columns _col0,_col1,_col3,_col4
+                columns _col0,_col1,_col2,_col3
                 columns.types int,string,int,string
                 escape.delim \
                 serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -640,8 +644,8 @@ STAGE PLANS:
               name: default.pcr_t1
             name: default.pcr_t1
       Truncated Path -> Alias:
-        /pcr_t1/ds=2000-04-08 [$hdt$_0:t1]
-        /pcr_t1/ds=2000-04-09 [$hdt$_1:t2]
+        /pcr_t1/ds=2000-04-08 [$hdt$_0:$hdt$_0:t1]
+        /pcr_t1/ds=2000-04-09 [$hdt$_0:$hdt$_1:t2]
       Needs Tagging: true
       Reduce Operator Tree:
         Join Operator
@@ -652,24 +656,28 @@ STAGE PLANS:
             1 _col0 (type: int)
           outputColumnNames: _col0, _col1, _col3, _col4
           Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            GlobalTableId: 0
+          Select Operator
+            expressions: _col0 (type: int), _col1 (type: string), _col3 (type: int), _col4 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3
+            Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              GlobalTableId: 0
 #### A masked pattern was here ####
-            NumFilesPerFileSink: 1
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                properties:
-                  column.name.delimiter ,
-                  columns _col0,_col1,_col3,_col4
-                  columns.types int,string,int,string
-                  escape.delim \
-                  serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-            TotalFiles: 1
-            GatherStats: false
-            MultiFileSpray: false
+              NumFilesPerFileSink: 1
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  properties:
+                    column.name.delimiter ,
+                    columns _col0,_col1,_col2,_col3
+                    columns.types int,string,int,string
+                    escape.delim \
+                    serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+              TotalFiles: 1
+              GatherStats: false
+              MultiFileSpray: false
 
   Stage: Stage-2
     Map Reduce
@@ -682,7 +690,7 @@ STAGE PLANS:
               sort order: +
               Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
               tag: -1
-              value expressions: _col1 (type: string), _col3 (type: int), _col4 (type: string)
+              value expressions: _col1 (type: string), _col2 (type: int), _col3 (type: string)
               auto parallelism: false
       Path -> Alias:
 #### A masked pattern was here ####
@@ -694,7 +702,7 @@ STAGE PLANS:
             output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
             properties:
               column.name.delimiter ,
-              columns _col0,_col1,_col3,_col4
+              columns _col0,_col1,_col2,_col3
               columns.types int,string,int,string
               escape.delim \
               serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -704,7 +712,7 @@ STAGE PLANS:
               output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
               properties:
                 column.name.delimiter ,
-                columns _col0,_col1,_col3,_col4
+                columns _col0,_col1,_col2,_col3
                 columns.types int,string,int,string
                 escape.delim \
                 serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/pointlookup3.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/pointlookup3.q.out b/ql/src/test/results/clientpositive/pointlookup3.q.out
index 2c3e39f..eb61e17 100644
--- a/ql/src/test/results/clientpositive/pointlookup3.q.out
+++ b/ql/src/test/results/clientpositive/pointlookup3.q.out
@@ -307,7 +307,7 @@ STAGE PLANS:
               name: default.pcr_t1
             name: default.pcr_t1
       Truncated Path -> Alias:
-        /pcr_t1/ds1=2000-04-08/ds2=2001-04-08 [pcr_t1]
+        /pcr_t1/ds1=2000-04-08/ds2=2001-04-08 [$hdt$_0:pcr_t1]
       Needs Tagging: false
       Reduce Operator Tree:
         Select Operator
@@ -458,7 +458,7 @@ STAGE PLANS:
               name: default.pcr_t1
             name: default.pcr_t1
       Truncated Path -> Alias:
-        /pcr_t1/ds1=2000-04-08/ds2=2001-04-08 [$hdt$_0:t1, $hdt$_1:t2]
+        /pcr_t1/ds1=2000-04-08/ds2=2001-04-08 [$hdt$_0:$hdt$_0:t1, $hdt$_0:$hdt$_1:t2]
       Needs Tagging: true
       Reduce Operator Tree:
         Join Operator
@@ -469,24 +469,28 @@ STAGE PLANS:
             1 _col0 (type: int)
           outputColumnNames: _col0, _col1, _col3, _col4, _col5, _col6
           Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            GlobalTableId: 0
+          Select Operator
+            expressions: _col0 (type: int), _col1 (type: string), _col3 (type: string), _col4 (type: int), _col5 (type: string), _col6 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
+            Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              GlobalTableId: 0
 #### A masked pattern was here ####
-            NumFilesPerFileSink: 1
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                properties:
-                  column.name.delimiter ,
-                  columns _col0,_col1,_col3,_col4,_col5,_col6
-                  columns.types int,string,string,int,string,string
-                  escape.delim \
-                  serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-            TotalFiles: 1
-            GatherStats: false
-            MultiFileSpray: false
+              NumFilesPerFileSink: 1
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  properties:
+                    column.name.delimiter ,
+                    columns _col0,_col1,_col2,_col3,_col4,_col5
+                    columns.types int,string,string,int,string,string
+                    escape.delim \
+                    serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+              TotalFiles: 1
+              GatherStats: false
+              MultiFileSpray: false
 
   Stage: Stage-2
     Map Reduce
@@ -499,7 +503,7 @@ STAGE PLANS:
               sort order: +
               Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
               tag: -1
-              value expressions: _col1 (type: string), _col3 (type: string), _col4 (type: int), _col5 (type: string), _col6 (type: string)
+              value expressions: _col1 (type: string), _col2 (type: string), _col3 (type: int), _col4 (type: string), _col5 (type: string)
               auto parallelism: false
       Path -> Alias:
 #### A masked pattern was here ####
@@ -511,7 +515,7 @@ STAGE PLANS:
             output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
             properties:
               column.name.delimiter ,
-              columns _col0,_col1,_col3,_col4,_col5,_col6
+              columns _col0,_col1,_col2,_col3,_col4,_col5
               columns.types int,string,string,int,string,string
               escape.delim \
               serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -521,7 +525,7 @@ STAGE PLANS:
               output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
               properties:
                 column.name.delimiter ,
-                columns _col0,_col1,_col3,_col4,_col5,_col6
+                columns _col0,_col1,_col2,_col3,_col4,_col5
                 columns.types int,string,string,int,string,string
                 escape.delim \
                 serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -726,8 +730,8 @@ STAGE PLANS:
               name: default.pcr_t1
             name: default.pcr_t1
       Truncated Path -> Alias:
-        /pcr_t1/ds1=2000-04-08/ds2=2001-04-08 [$hdt$_0:t1]
-        /pcr_t1/ds1=2000-04-09/ds2=2001-04-09 [$hdt$_1:t2]
+        /pcr_t1/ds1=2000-04-08/ds2=2001-04-08 [$hdt$_0:$hdt$_0:t1]
+        /pcr_t1/ds1=2000-04-09/ds2=2001-04-09 [$hdt$_0:$hdt$_1:t2]
       Needs Tagging: true
       Reduce Operator Tree:
         Join Operator
@@ -738,24 +742,28 @@ STAGE PLANS:
             1 _col0 (type: int)
           outputColumnNames: _col0, _col1, _col3, _col4, _col5, _col7
           Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            GlobalTableId: 0
+          Select Operator
+            expressions: _col0 (type: int), _col1 (type: string), _col3 (type: string), _col4 (type: int), _col5 (type: string), _col7 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
+            Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              GlobalTableId: 0
 #### A masked pattern was here ####
-            NumFilesPerFileSink: 1
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                properties:
-                  column.name.delimiter ,
-                  columns _col0,_col1,_col3,_col4,_col5,_col7
-                  columns.types int,string,string,int,string,string
-                  escape.delim \
-                  serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-            TotalFiles: 1
-            GatherStats: false
-            MultiFileSpray: false
+              NumFilesPerFileSink: 1
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  properties:
+                    column.name.delimiter ,
+                    columns _col0,_col1,_col2,_col3,_col4,_col5
+                    columns.types int,string,string,int,string,string
+                    escape.delim \
+                    serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+              TotalFiles: 1
+              GatherStats: false
+              MultiFileSpray: false
 
   Stage: Stage-2
     Map Reduce
@@ -768,7 +776,7 @@ STAGE PLANS:
               sort order: +
               Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
               tag: -1
-              value expressions: _col1 (type: string), _col3 (type: string), _col4 (type: int), _col5 (type: string), _col7 (type: string)
+              value expressions: _col1 (type: string), _col2 (type: string), _col3 (type: int), _col4 (type: string), _col5 (type: string)
               auto parallelism: false
       Path -> Alias:
 #### A masked pattern was here ####
@@ -780,7 +788,7 @@ STAGE PLANS:
             output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
             properties:
               column.name.delimiter ,
-              columns _col0,_col1,_col3,_col4,_col5,_col7
+              columns _col0,_col1,_col2,_col3,_col4,_col5
               columns.types int,string,string,int,string,string
               escape.delim \
               serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -790,7 +798,7 @@ STAGE PLANS:
               output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
               properties:
                 column.name.delimiter ,
-                columns _col0,_col1,_col3,_col4,_col5,_col7
+                columns _col0,_col1,_col2,_col3,_col4,_col5
                 columns.types int,string,string,int,string,string
                 escape.delim \
                 serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/ppd_udf_case.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/ppd_udf_case.q.out b/ql/src/test/results/clientpositive/ppd_udf_case.q.out
index 7678d03..3cf8e81 100644
--- a/ql/src/test/results/clientpositive/ppd_udf_case.q.out
+++ b/ql/src/test/results/clientpositive/ppd_udf_case.q.out
@@ -71,19 +71,23 @@ STAGE PLANS:
             1 
           outputColumnNames: _col1, _col3, _col5, _col7
           Statistics: Num rows: 250000 Data size: 5562000 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+          Select Operator
+            expressions: _col1 (type: string), _col3 (type: string), _col5 (type: string), _col7 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3
+            Statistics: Num rows: 250000 Data size: 5562000 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
 
   Stage: Stage-2
     Map Reduce
       Map Operator Tree:
           TableScan
             Reduce Output Operator
-              key expressions: _col1 (type: string), _col3 (type: string), _col5 (type: string), _col7 (type: string)
+              key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string)
               sort order: ++++
               Statistics: Num rows: 250000 Data size: 5562000 Basic stats: COMPLETE Column stats: NONE
       Reduce Operator Tree:
@@ -215,19 +219,23 @@ STAGE PLANS:
             1 
           outputColumnNames: _col1, _col3, _col5, _col7
           Statistics: Num rows: 250000 Data size: 5562000 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+          Select Operator
+            expressions: _col1 (type: string), _col3 (type: string), _col5 (type: string), _col7 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3
+            Statistics: Num rows: 250000 Data size: 5562000 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
 
   Stage: Stage-2
     Map Reduce
       Map Operator Tree:
           TableScan
             Reduce Output Operator
-              key expressions: _col1 (type: string), _col3 (type: string), _col5 (type: string), _col7 (type: string)
+              key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string)
               sort order: ++++
               Statistics: Num rows: 250000 Data size: 5562000 Basic stats: COMPLETE Column stats: NONE
       Reduce Operator Tree:

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/spark/dynamic_rdd_cache.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/dynamic_rdd_cache.q.out b/ql/src/test/results/clientpositive/spark/dynamic_rdd_cache.q.out
index bcb50cf..38ea9bd 100644
--- a/ql/src/test/results/clientpositive/spark/dynamic_rdd_cache.q.out
+++ b/ql/src/test/results/clientpositive/spark/dynamic_rdd_cache.q.out
@@ -1071,13 +1071,13 @@ STAGE PLANS:
                 Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
                 Select Operator
                   expressions: _col1 (type: int), _col2 (type: int), _col3 (type: double), _col4 (type: double), _col6 (type: int), _col7 (type: int), _col8 (type: double), _col9 (type: double)
-                  outputColumnNames: _col0, _col1, _col3, _col4, _col5, _col6, _col8, _col9
+                  outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7
                   Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
                   Reduce Output Operator
-                    key expressions: _col0 (type: int), _col1 (type: int), _col3 (type: double), _col4 (type: double), _col8 (type: double), _col9 (type: double)
+                    key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: double), _col3 (type: double), _col6 (type: double), _col7 (type: double)
                     sort order: ++++++
                     Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
-                    value expressions: _col5 (type: int), _col6 (type: int)
+                    value expressions: _col4 (type: int), _col5 (type: int)
         Reducer 7 
             Reduce Operator Tree:
               Select Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/spark/limit_pushdown.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/limit_pushdown.q.out b/ql/src/test/results/clientpositive/spark/limit_pushdown.q.out
index ede0096..19c1e5f 100644
--- a/ql/src/test/results/clientpositive/spark/limit_pushdown.q.out
+++ b/ql/src/test/results/clientpositive/spark/limit_pushdown.q.out
@@ -1315,7 +1315,7 @@ STAGE PLANS:
 
   Stage: Stage-0
     Fetch Operator
-      limit: 100
+      limit: -1
       Processor Tree:
         ListSink
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/spark/pcr.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/pcr.q.out b/ql/src/test/results/clientpositive/spark/pcr.q.out
index 77ac020..dc8c1ab 100644
--- a/ql/src/test/results/clientpositive/spark/pcr.q.out
+++ b/ql/src/test/results/clientpositive/spark/pcr.q.out
@@ -1468,10 +1468,10 @@ STAGE PLANS:
                     Statistics: Num rows: 20 Data size: 160 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
                       expressions: value (type: string)
-                      outputColumnNames: _col1
+                      outputColumnNames: _col0
                       Statistics: Num rows: 20 Data size: 160 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
-                        key expressions: _col1 (type: string)
+                        key expressions: _col0 (type: string)
                         null sort order: a
                         sort order: +
                         Statistics: Num rows: 20 Data size: 160 Basic stats: COMPLETE Column stats: NONE
@@ -2497,14 +2497,18 @@ STAGE PLANS:
                   1 _col0 (type: int)
                 outputColumnNames: _col0, _col1, _col3, _col4
                 Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: int)
-                  null sort order: a
-                  sort order: +
+                Select Operator
+                  expressions: _col0 (type: int), _col1 (type: string), _col3 (type: int), _col4 (type: string)
+                  outputColumnNames: _col0, _col1, _col2, _col3
                   Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-                  tag: -1
-                  value expressions: _col1 (type: string), _col3 (type: int), _col4 (type: string)
-                  auto parallelism: false
+                  Reduce Output Operator
+                    key expressions: _col0 (type: int)
+                    null sort order: a
+                    sort order: +
+                    Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
+                    tag: -1
+                    value expressions: _col1 (type: string), _col2 (type: int), _col3 (type: string)
+                    auto parallelism: false
         Reducer 3 
             Needs Tagging: false
             Reduce Operator Tree:
@@ -2766,14 +2770,18 @@ STAGE PLANS:
                   1 _col0 (type: int)
                 outputColumnNames: _col0, _col1, _col3, _col4
                 Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: int)
-                  null sort order: a
-                  sort order: +
+                Select Operator
+                  expressions: _col0 (type: int), _col1 (type: string), _col3 (type: int), _col4 (type: string)
+                  outputColumnNames: _col0, _col1, _col2, _col3
                   Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-                  tag: -1
-                  value expressions: _col1 (type: string), _col3 (type: int), _col4 (type: string)
-                  auto parallelism: false
+                  Reduce Output Operator
+                    key expressions: _col0 (type: int)
+                    null sort order: a
+                    sort order: +
+                    Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
+                    tag: -1
+                    value expressions: _col1 (type: string), _col2 (type: int), _col3 (type: string)
+                    auto parallelism: false
         Reducer 3 
             Needs Tagging: false
             Reduce Operator Tree:
@@ -4131,10 +4139,10 @@ STAGE PLANS:
                     Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
                       expressions: key (type: string), value (type: string), hr (type: string)
-                      outputColumnNames: _col0, _col1, _col3
+                      outputColumnNames: _col0, _col1, _col2
                       Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
-                        key expressions: _col0 (type: string), _col3 (type: string)
+                        key expressions: _col0 (type: string), _col2 (type: string)
                         null sort order: aa
                         sort order: ++
                         Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE


[6/7] hive git commit: HIVE-15160: Can't order by an unselected column (Pengcheng Xiong, reviewed by Ashutosh Chauhan)

Posted by px...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/vector_decimal_2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_decimal_2.q.out b/ql/src/test/results/clientpositive/llap/vector_decimal_2.q.out
index 144356c..947ac81 100644
--- a/ql/src/test/results/clientpositive/llap/vector_decimal_2.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_decimal_2.q.out
@@ -1054,9 +1054,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1064,26 +1061,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 3.14 (type: decimal(4,2))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 3.14 (type: decimal(4,2))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1114,9 +1103,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1124,26 +1110,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 3.14 (type: decimal(4,2))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 3.14 (type: decimal(4,2))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1174,9 +1152,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1184,26 +1159,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 1355944339.1234567 (type: decimal(30,8))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 1355944339.1234567 (type: decimal(30,8))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1234,9 +1201,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1244,26 +1208,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 1 (type: decimal(10,0))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 1 (type: decimal(10,0))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1285,9 +1241,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1295,26 +1248,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 1 (type: decimal(10,0))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 1 (type: decimal(10,0))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1345,9 +1290,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1355,26 +1297,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 3 (type: decimal(10,0))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 3 (type: decimal(10,0))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1405,9 +1339,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1415,26 +1346,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 3 (type: decimal(10,0))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 3 (type: decimal(10,0))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1465,9 +1388,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1475,26 +1395,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 3 (type: decimal(10,0))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 3 (type: decimal(10,0))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1525,9 +1437,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1535,26 +1444,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 3 (type: decimal(10,0))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 3 (type: decimal(10,0))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1585,9 +1486,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1595,26 +1493,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 1 (type: decimal(20,19))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 1 (type: decimal(20,19))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator
@@ -1645,9 +1535,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -1655,26 +1542,18 @@ STAGE PLANS:
                   alias: decimal_2
                   Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
+                    expressions: 0.99999999999999999999 (type: decimal(20,20))
+                    outputColumnNames: _col0
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      sort order: 
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 1 Data size: 112 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 0.99999999999999999999 (type: decimal(20,20))
-                outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 1 Data size: 112 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
 
   Stage: Stage-0
     Fetch Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/vector_decimal_round.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_decimal_round.q.out b/ql/src/test/results/clientpositive/llap/vector_decimal_round.q.out
index 00bb50a..b617564 100644
--- a/ql/src/test/results/clientpositive/llap/vector_decimal_round.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_decimal_round.q.out
@@ -161,19 +161,19 @@ STAGE PLANS:
                       native: true
                       projectedOutputColumns: [0]
                   Select Operator
-                    expressions: dec (type: decimal(10,0))
-                    outputColumnNames: _col0
+                    expressions: dec (type: decimal(10,0)), round(dec, -1) (type: decimal(11,0))
+                    outputColumnNames: _col0, _col2
                     Select Vectorization:
                         className: VectorSelectOperator
                         native: true
-                        projectedOutputColumns: [0]
+                        projectedOutputColumns: [0, 1]
+                        selectExpressions: FuncRoundWithNumDigitsDecimalToDecimal(col 0, decimalPlaces -1) -> 1:decimal(11,0)
                     Statistics: Num rows: 1 Data size: 3 Basic stats: COMPLETE Column stats: NONE
                     Reduce Output Operator
-                      key expressions: round(_col0, -1) (type: decimal(11,0))
+                      key expressions: _col2 (type: decimal(11,0))
                       sort order: +
                       Reduce Sink Vectorization:
                           className: VectorReduceSinkObjectHashOperator
-                          keyExpressions: FuncRoundWithNumDigitsDecimalToDecimal(col 0, decimalPlaces -1) -> 1:decimal(11,0)
                           native: true
                           nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
                       Statistics: Num rows: 1 Data size: 3 Basic stats: COMPLETE Column stats: NONE
@@ -372,11 +372,11 @@ STAGE PLANS:
                   alias: decimal_tbl_rc
                   Statistics: Num rows: 1 Data size: 3 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: dec (type: decimal(10,0))
-                    outputColumnNames: _col0
+                    expressions: dec (type: decimal(10,0)), round(dec, -1) (type: decimal(11,0))
+                    outputColumnNames: _col0, _col2
                     Statistics: Num rows: 1 Data size: 3 Basic stats: COMPLETE Column stats: NONE
                     Reduce Output Operator
-                      key expressions: round(_col0, -1) (type: decimal(11,0))
+                      key expressions: _col2 (type: decimal(11,0))
                       sort order: +
                       Statistics: Num rows: 1 Data size: 3 Basic stats: COMPLETE Column stats: NONE
                       value expressions: _col0 (type: decimal(10,0))
@@ -589,19 +589,19 @@ STAGE PLANS:
                       native: true
                       projectedOutputColumns: [0]
                   Select Operator
-                    expressions: dec (type: decimal(10,0))
-                    outputColumnNames: _col0
+                    expressions: dec (type: decimal(10,0)), round(dec, -1) (type: decimal(11,0))
+                    outputColumnNames: _col0, _col2
                     Select Vectorization:
                         className: VectorSelectOperator
                         native: true
-                        projectedOutputColumns: [0]
+                        projectedOutputColumns: [0, 1]
+                        selectExpressions: FuncRoundWithNumDigitsDecimalToDecimal(col 0, decimalPlaces -1) -> 1:decimal(11,0)
                     Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: NONE
                     Reduce Output Operator
-                      key expressions: round(_col0, -1) (type: decimal(11,0))
+                      key expressions: _col2 (type: decimal(11,0))
                       sort order: +
                       Reduce Sink Vectorization:
                           className: VectorReduceSinkObjectHashOperator
-                          keyExpressions: FuncRoundWithNumDigitsDecimalToDecimal(col 0, decimalPlaces -1) -> 1:decimal(11,0)
                           native: true
                           nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
                       Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: NONE

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_grouping.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_grouping.q.out b/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_grouping.q.out
index 5af9e61..98cd4d1 100644
--- a/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_grouping.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_grouping.q.out
@@ -377,11 +377,11 @@ STAGE PLANS:
                   predicate: ((grouping(_col2, 1) = 1) or (grouping(_col2, 0) = 1)) (type: boolean)
                   Statistics: Num rows: 12 Data size: 80 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col0 (type: int), _col1 (type: int), (grouping(_col2, 1) + grouping(_col2, 0)) (type: int)
-                    outputColumnNames: _col0, _col1, _col2
+                    expressions: _col0 (type: int), _col1 (type: int), (grouping(_col2, 1) + grouping(_col2, 0)) (type: int), CASE WHEN (((grouping(_col2, 1) + grouping(_col2, 0)) = 1)) THEN (_col0) ELSE (null) END (type: int)
+                    outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 12 Data size: 80 Basic stats: COMPLETE Column stats: NONE
                     Reduce Output Operator
-                      key expressions: _col2 (type: int), CASE WHEN ((_col2 = 1)) THEN (_col0) ELSE (null) END (type: int)
+                      key expressions: _col2 (type: int), _col3 (type: int)
                       sort order: -+
                       Statistics: Num rows: 12 Data size: 80 Basic stats: COMPLETE Column stats: NONE
                       value expressions: _col0 (type: int), _col1 (type: int)

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_limit.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_limit.q.out b/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_limit.q.out
index f731cee..18e032a 100644
--- a/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_limit.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_limit.q.out
@@ -429,7 +429,7 @@ STAGE PLANS:
 
   Stage: Stage-0
     Fetch Operator
-      limit: 10
+      limit: -1
       Processor Tree:
         ListSink
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/vector_interval_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_interval_1.q.out b/ql/src/test/results/clientpositive/llap/vector_interval_1.q.out
index 8d4f12e..bc3486f 100644
--- a/ql/src/test/results/clientpositive/llap/vector_interval_1.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_interval_1.q.out
@@ -78,7 +78,7 @@ STAGE PLANS:
                       projectedOutputColumns: [0, 1, 2, 3]
                   Select Operator
                     expressions: str1 (type: string), CAST( str1 AS INTERVAL YEAR TO MONTH) (type: interval_year_month), CAST( str2 AS INTERVAL DAY TO SECOND) (type: interval_day_time)
-                    outputColumnNames: _col0, _col2, _col4
+                    outputColumnNames: _col0, _col1, _col2
                     Select Vectorization:
                         className: VectorSelectOperator
                         native: true
@@ -93,7 +93,7 @@ STAGE PLANS:
                           native: true
                           nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
                       Statistics: Num rows: 2 Data size: 442 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col2 (type: interval_year_month), _col4 (type: interval_day_time)
+                      value expressions: _col1 (type: interval_year_month), _col2 (type: interval_day_time)
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -206,7 +206,7 @@ STAGE PLANS:
                       projectedOutputColumns: [0, 1, 2, 3]
                   Select Operator
                     expressions: dt (type: date), (CAST( str1 AS INTERVAL YEAR TO MONTH) + CAST( str1 AS INTERVAL YEAR TO MONTH)) (type: interval_year_month), (1-2 + CAST( str1 AS INTERVAL YEAR TO MONTH)) (type: interval_year_month), (CAST( str1 AS INTERVAL YEAR TO MONTH) - CAST( str1 AS INTERVAL YEAR TO MONTH)) (type: interval_year_month), (1-2 - CAST( str1 AS INTERVAL YEAR TO MONTH)) (type: interval_year_month)
-                    outputColumnNames: _col0, _col2, _col3, _col5, _col6
+                    outputColumnNames: _col0, _col1, _col2, _col3, _col4
                     Select Vectorization:
                         className: VectorSelectOperator
                         native: true
@@ -221,7 +221,7 @@ STAGE PLANS:
                           native: true
                           nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
                       Statistics: Num rows: 2 Data size: 442 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col2 (type: interval_year_month), _col3 (type: interval_year_month), _col5 (type: interval_year_month), _col6 (type: interval_year_month)
+                      value expressions: _col1 (type: interval_year_month), _col2 (type: interval_year_month), _col3 (type: interval_year_month), _col4 (type: interval_year_month)
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -342,7 +342,7 @@ STAGE PLANS:
                       projectedOutputColumns: [0, 1, 2, 3]
                   Select Operator
                     expressions: dt (type: date), (CAST( str2 AS INTERVAL DAY TO SECOND) + CAST( str2 AS INTERVAL DAY TO SECOND)) (type: interval_day_time), (1 02:03:04.000000000 + CAST( str2 AS INTERVAL DAY TO SECOND)) (type: interval_day_time), (CAST( str2 AS INTERVAL DAY TO SECOND) - CAST( str2 AS INTERVAL DAY TO SECOND)) (type: interval_day_time), (1 02:03:04.000000000 - CAST( str2 AS INTERVAL DAY TO SECOND)) (type: interval_day_time)
-                    outputColumnNames: _col0, _col2, _col3, _col5, _col6
+                    outputColumnNames: _col0, _col1, _col2, _col3, _col4
                     Select Vectorization:
                         className: VectorSelectOperator
                         native: true
@@ -357,7 +357,7 @@ STAGE PLANS:
                           native: true
                           nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
                       Statistics: Num rows: 2 Data size: 442 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col2 (type: interval_day_time), _col3 (type: interval_day_time), _col5 (type: interval_day_time), _col6 (type: interval_day_time)
+                      value expressions: _col1 (type: interval_day_time), _col2 (type: interval_day_time), _col3 (type: interval_day_time), _col4 (type: interval_day_time)
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/llap/vector_interval_arithmetic.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_interval_arithmetic.q.out b/ql/src/test/results/clientpositive/llap/vector_interval_arithmetic.q.out
index 1d14092..2d4db5e 100644
--- a/ql/src/test/results/clientpositive/llap/vector_interval_arithmetic.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_interval_arithmetic.q.out
@@ -619,9 +619,6 @@ STAGE PLANS:
   Stage: Stage-1
     Tez
 #### A masked pattern was here ####
-      Edges:
-        Reducer 2 <- Map 1 (SIMPLE_EDGE)
-#### A masked pattern was here ####
       Vertices:
         Map 1 
             Map Operator Tree:
@@ -632,21 +629,30 @@ STAGE PLANS:
                       native: true
                       projectedOutputColumns: [0, 1]
                   Select Operator
+                    expressions: 5-5 (type: interval_year_month), -1-1 (type: interval_year_month)
+                    outputColumnNames: _col0, _col1
                     Select Vectorization:
                         className: VectorSelectOperator
                         native: true
-                        projectedOutputColumns: []
+                        projectedOutputColumns: [2, 3]
+                        selectExpressions: ConstantVectorExpression(val 65) -> 2:long, ConstantVectorExpression(val -13) -> 3:long
                     Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE
-                    Reduce Output Operator
-                      key expressions: CAST( 5-5 AS INTERVAL YEAR TO MONTH) (type: interval_year_month)
-                      sort order: +
-                      Reduce Sink Vectorization:
-                          className: VectorReduceSinkObjectHashOperator
-                          keyExpressions: VectorUDFAdaptor(CAST( 5-5 AS INTERVAL YEAR TO MONTH)) -> 2:interval_year_month
+                    Limit
+                      Number of rows: 2
+                      Limit Vectorization:
+                          className: VectorLimitOperator
                           native: true
-                          nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
-                      Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE
-                      TopN Hash Memory Usage: 0.1
+                      Statistics: Num rows: 2 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+                      File Output Operator
+                        compressed: false
+                        File Sink Vectorization:
+                            className: VectorFileSinkOperator
+                            native: false
+                        Statistics: Num rows: 2 Data size: 32 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
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -654,44 +660,9 @@ STAGE PLANS:
                 enabledConditionsMet: hive.vectorized.use.vectorized.input.format IS true
                 groupByVectorOutput: true
                 inputFileFormats: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
-                allNative: true
-                usesVectorUDFAdaptor: true
-                vectorized: true
-        Reducer 2 
-            Execution mode: vectorized, llap
-            Reduce Vectorization:
-                enabled: true
-                enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                groupByVectorOutput: true
                 allNative: false
                 usesVectorUDFAdaptor: false
                 vectorized: true
-            Reduce Operator Tree:
-              Select Operator
-                expressions: 5-5 (type: interval_year_month), -1-1 (type: interval_year_month)
-                outputColumnNames: _col0, _col1
-                Select Vectorization:
-                    className: VectorSelectOperator
-                    native: true
-                    projectedOutputColumns: [1, 2]
-                    selectExpressions: ConstantVectorExpression(val 65) -> 1:long, ConstantVectorExpression(val -13) -> 2:long
-                Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE
-                Limit
-                  Number of rows: 2
-                  Limit Vectorization:
-                      className: VectorLimitOperator
-                      native: true
-                  Statistics: Num rows: 2 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
-                  File Output Operator
-                    compressed: false
-                    File Sink Vectorization:
-                        className: VectorFileSinkOperator
-                        native: false
-                    Statistics: Num rows: 2 Data size: 32 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
 
   Stage: Stage-0
     Fetch Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/order3.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/order3.q.out b/ql/src/test/results/clientpositive/order3.q.out
index 898f7a8..d3db1b9 100644
--- a/ql/src/test/results/clientpositive/order3.q.out
+++ b/ql/src/test/results/clientpositive/order3.q.out
@@ -256,23 +256,27 @@ STAGE PLANS:
               value expressions: _col1 (type: bigint)
       Reduce Operator Tree:
         Select Operator
-          expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: bigint), 'AAA' (type: string)
-          outputColumnNames: _col0, _col1, _col2
+          expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: bigint)
+          outputColumnNames: _col0, _col1
           Statistics: Num rows: 7 Data size: 70 Basic stats: COMPLETE Column stats: NONE
           Limit
             Number of rows: 3
             Statistics: Num rows: 3 Data size: 30 Basic stats: COMPLETE Column stats: NONE
-            File Output Operator
-              compressed: false
+            Select Operator
+              expressions: _col0 (type: int), _col1 (type: bigint), 'AAA' (type: string)
+              outputColumnNames: _col0, _col1, _col2
               Statistics: Num rows: 3 Data size: 30 Basic stats: COMPLETE Column stats: NONE
-              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
+              File Output Operator
+                compressed: false
+                Statistics: Num rows: 3 Data size: 30 Basic stats: COMPLETE Column stats: NONE
+                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
 
   Stage: Stage-0
     Fetch Operator
-      limit: 3
+      limit: -1
       Processor Tree:
         ListSink
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/order_by_expr_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/order_by_expr_1.q.out b/ql/src/test/results/clientpositive/order_by_expr_1.q.out
new file mode 100644
index 0000000..39babb7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/order_by_expr_1.q.out
@@ -0,0 +1,566 @@
+PREHOOK: query: create table t(a int, b int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t
+POSTHOOK: query: create table t(a int, b int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t
+PREHOOK: query: insert into t values (1,2),(1,2),(1,3),(2,4),(20,-100),(-1000,100),(4,5),(3,7),(8,9)
+PREHOOK: type: QUERY
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values (1,2),(1,2),(1,3),(2,4),(20,-100),(-1000,100),(4,5),(3,7),(8,9)
+POSTHOOK: type: QUERY
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.a EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
+POSTHOOK: Lineage: t.b EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, type:string, comment:), ]
+PREHOOK: query: select a, count(a) from t group by a order by count(a), a
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a, count(a) from t group by a order by count(a), a
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	1
+2	1
+3	1
+4	1
+8	1
+20	1
+1	3
+PREHOOK: query: explain
+select
+  interval '2-2' year to month + interval '3-3' year to month,
+  interval '2-2' year to month - interval '3-3' year to month
+from t 
+order by interval '2-2' year to month + interval '3-3' year to month
+limit 2
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select
+  interval '2-2' year to month + interval '3-3' year to month,
+  interval '2-2' year to month - interval '3-3' year to month
+from t 
+order by interval '2-2' year to month + interval '3-3' year to month
+limit 2
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: t
+            Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: COMPLETE
+            Select Operator
+              expressions: 5-5 (type: interval_year_month), -1-1 (type: interval_year_month)
+              outputColumnNames: _col0, _col1
+              Statistics: Num rows: 9 Data size: 144 Basic stats: COMPLETE Column stats: COMPLETE
+              Limit
+                Number of rows: 2
+                Statistics: Num rows: 2 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 2 Data size: 32 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
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: 2
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select a,b, count(*) from t group by a, b order by a+b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b, count(*) from t group by a, b order by a+b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100	1
+20	-100	1
+1	2	2
+1	3	1
+2	4	1
+4	5	1
+3	7	1
+8	9	1
+PREHOOK: query: select a,b, count(*) from t group by a, b order by count(*), b desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b, count(*) from t group by a, b order by count(*), b desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100	1
+8	9	1
+3	7	1
+4	5	1
+2	4	1
+1	3	1
+20	-100	1
+1	2	2
+PREHOOK: query: select a,b,count(*),a+b from t group by a, b order by a+b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b,count(*),a+b from t group by a, b order by a+b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100	1	-900
+20	-100	1	-80
+1	2	2	3
+1	3	1	4
+2	4	1	6
+4	5	1	9
+3	7	1	10
+8	9	1	17
+PREHOOK: query: select a,b from t order by a+b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b from t order by a+b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100
+20	-100
+1	2
+1	2
+1	3
+2	4
+4	5
+3	7
+8	9
+PREHOOK: query: select a,b,a+b from t order by a+b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b,a+b from t order by a+b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100	-900
+20	-100	-80
+1	2	3
+1	2	3
+1	3	4
+2	4	6
+4	5	9
+3	7	10
+8	9	17
+PREHOOK: query: select a,b,a+b from t order by a+b desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b,a+b from t order by a+b desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+8	9	17
+3	7	10
+4	5	9
+2	4	6
+1	3	4
+1	2	3
+1	2	3
+20	-100	-80
+-1000	100	-900
+PREHOOK: query: select cast(0.99999999999999999999 as decimal(20,19)) as c from t limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(0.99999999999999999999 as decimal(20,19)) as c from t limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+1.0000000000000000000
+PREHOOK: query: select cast(0.99999999999999999999 as decimal(20,19)) as c from t order by c limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(0.99999999999999999999 as decimal(20,19)) as c from t order by c limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+1.0000000000000000000
+PREHOOK: query: select a from t order by b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a from t order by b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+20
+1
+1
+1
+2
+4
+3
+8
+-1000
+PREHOOK: query: select a from t order by 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a from t order by 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000
+8
+3
+4
+2
+1
+1
+1
+20
+PREHOOK: query: select b from t order by 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select b from t order by 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+100
+9
+7
+5
+4
+3
+2
+2
+-100
+PREHOOK: query: select b from t order by a, 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select b from t order by a, 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+100
+3
+2
+2
+4
+7
+5
+9
+-100
+PREHOOK: query: select b from t order by a+1, 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select b from t order by a+1, 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+100
+3
+2
+2
+4
+7
+5
+9
+-100
+PREHOOK: query: select b from t order by 0-b, a+1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select b from t order by 0-b, a+1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+100
+9
+7
+5
+4
+3
+2
+2
+-100
+PREHOOK: query: explain select b from t order by 0-b, a+1
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select b from t order by 0-b, a+1
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: t
+            Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+            Select Operator
+              expressions: b (type: int), (0 - b) (type: int), (a + 1) (type: int)
+              outputColumnNames: _col0, _col1, _col2
+              Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+              Reduce Output Operator
+                key expressions: _col1 (type: int), _col2 (type: int)
+                sort order: ++
+                Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+                value expressions: _col0 (type: int)
+      Reduce Operator Tree:
+        Select Operator
+          expressions: VALUE._col0 (type: int)
+          outputColumnNames: _col0
+          Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+          File Output Operator
+            compressed: false
+            Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+            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
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select a,b from t order by 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b from t order by 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100
+8	9
+3	7
+4	5
+2	4
+1	3
+1	2
+1	2
+20	-100
+PREHOOK: query: select a,b from t order by a, a+1, 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b from t order by a, a+1, 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100
+1	3
+1	2
+1	2
+2	4
+3	7
+4	5
+8	9
+20	-100
+PREHOOK: query: select a,b from t order by 0-b, a+1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b from t order by 0-b, a+1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100
+8	9
+3	7
+4	5
+2	4
+1	3
+1	2
+1	2
+20	-100
+PREHOOK: query: select a+1,b from t order by a, a+1, 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a+1,b from t order by a, a+1, 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-999	100
+2	3
+2	2
+2	2
+3	4
+4	7
+5	5
+9	9
+21	-100
+PREHOOK: query: select a+1 as c, b from t order by a, a+1, 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a+1 as c, b from t order by a, a+1, 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-999	100
+2	3
+2	2
+2	2
+3	4
+4	7
+5	5
+9	9
+21	-100
+PREHOOK: query: select a, a+1 as c, b from t order by a, a+1, 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a, a+1 as c, b from t order by a, a+1, 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	-999	100
+1	2	3
+1	2	2
+1	2	2
+2	3	4
+3	4	7
+4	5	5
+8	9	9
+20	21	-100
+PREHOOK: query: select a, a+1 as c, b, 2*b from t order by a, a+1, 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a, a+1 as c, b, 2*b from t order by a, a+1, 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	-999	100	200
+1	2	3	6
+1	2	2	4
+1	2	2	4
+2	3	4	8
+3	4	7	14
+4	5	5	10
+8	9	9	18
+20	21	-100	-200
+PREHOOK: query: explain select a, a+1 as c, b, 2*b from t order by a, a+1, 0-b
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select a, a+1 as c, b, 2*b from t order by a, a+1, 0-b
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: t
+            Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+            Select Operator
+              expressions: a (type: int), b (type: int), (2 * b) (type: int), (a + 1) (type: int), (0 - b) (type: int)
+              outputColumnNames: _col0, _col2, _col3, _col4, _col5
+              Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+              Reduce Output Operator
+                key expressions: _col0 (type: int), _col4 (type: int), _col5 (type: int)
+                sort order: +++
+                Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+                value expressions: _col2 (type: int), _col3 (type: int)
+      Reduce Operator Tree:
+        Select Operator
+          expressions: KEY.reducesinkkey0 (type: int), KEY.reducesinkkey1 (type: int), VALUE._col0 (type: int), VALUE._col1 (type: int)
+          outputColumnNames: _col0, _col1, _col2, _col3
+          Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+          File Output Operator
+            compressed: false
+            Statistics: Num rows: 9 Data size: 37 Basic stats: COMPLETE Column stats: NONE
+            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
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select a, a+1 as c, b, 2*b from t order by a+1, 0-b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a, a+1 as c, b, 2*b from t order by a+1, 0-b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	-999	100	200
+1	2	3	6
+1	2	2	4
+1	2	2	4
+2	3	4	8
+3	4	7	14
+4	5	5	10
+8	9	9	18
+20	21	-100	-200
+PREHOOK: query: select a,b, count(*) as c from t group by a, b order by c, a+b desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b, count(*) as c from t group by a, b order by c, a+b desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+8	9	1
+3	7	1
+4	5	1
+2	4	1
+1	3	1
+20	-100	1
+-1000	100	1
+1	2	2
+PREHOOK: query: select a, max(b) from t group by a order by count(b), a desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a, max(b) from t group by a order by count(b), a desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+20	-100
+8	9
+4	5
+3	7
+2	4
+-1000	100
+1	3
+PREHOOK: query: select a, max(b) from t group by a order by count(b), a
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a, max(b) from t group by a order by count(b), a
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100
+2	4
+3	7
+4	5
+8	9
+20	-100
+1	3

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/order_by_expr_2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/order_by_expr_2.q.out b/ql/src/test/results/clientpositive/order_by_expr_2.q.out
new file mode 100644
index 0000000..4b835b0
--- /dev/null
+++ b/ql/src/test/results/clientpositive/order_by_expr_2.q.out
@@ -0,0 +1,100 @@
+PREHOOK: query: create table t(a int, b int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t
+POSTHOOK: query: create table t(a int, b int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t
+PREHOOK: query: insert into t values (1,2),(1,2),(1,3),(2,4),(20,-100),(-1000,100),(4,5),(3,7),(8,9)
+PREHOOK: type: QUERY
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values (1,2),(1,2),(1,3),(2,4),(20,-100),(-1000,100),(4,5),(3,7),(8,9)
+POSTHOOK: type: QUERY
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.a EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
+POSTHOOK: Lineage: t.b EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, type:string, comment:), ]
+PREHOOK: query: select a as b, b as a from t order by a
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a as b, b as a from t order by a
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+20	-100
+1	2
+1	2
+1	3
+2	4
+4	5
+3	7
+8	9
+-1000	100
+PREHOOK: query: select a as b, b as a from t order by t.a
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a as b, b as a from t order by t.a
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100
+1	3
+1	2
+1	2
+2	4
+3	7
+4	5
+8	9
+20	-100
+PREHOOK: query: select a as b from t order by b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a as b from t order by b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000
+1
+1
+1
+2
+3
+4
+8
+20
+PREHOOK: query: select a as b from t order by 0-a
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a as b from t order by 0-a
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+20
+8
+4
+3
+2
+1
+1
+1
+-1000
+PREHOOK: query: select a,b,count(*),a+b from t group by a, b order by a+b
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select a,b,count(*),a+b from t group by a, b order by a+b
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+-1000	100	1	-900
+20	-100	1	-80
+1	2	2	3
+1	3	1	4
+2	4	1	6
+4	5	1	9
+3	7	1	10
+8	9	1	17

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/pcr.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/pcr.q.out b/ql/src/test/results/clientpositive/pcr.q.out
index a1301fd..ffb1d91 100644
--- a/ql/src/test/results/clientpositive/pcr.q.out
+++ b/ql/src/test/results/clientpositive/pcr.q.out
@@ -1427,10 +1427,10 @@ STAGE PLANS:
               Statistics: Num rows: 20 Data size: 160 Basic stats: COMPLETE Column stats: NONE
               Select Operator
                 expressions: value (type: string)
-                outputColumnNames: _col1
+                outputColumnNames: _col0
                 Statistics: Num rows: 20 Data size: 160 Basic stats: COMPLETE Column stats: NONE
                 Reduce Output Operator
-                  key expressions: _col1 (type: string)
+                  key expressions: _col0 (type: string)
                   null sort order: a
                   sort order: +
                   Statistics: Num rows: 20 Data size: 160 Basic stats: COMPLETE Column stats: NONE
@@ -1534,8 +1534,8 @@ STAGE PLANS:
               name: default.pcr_t1
             name: default.pcr_t1
       Truncated Path -> Alias:
-        /pcr_t1/ds=2000-04-08 [pcr_t1]
-        /pcr_t1/ds=2000-04-09 [pcr_t1]
+        /pcr_t1/ds=2000-04-08 [$hdt$_0:pcr_t1]
+        /pcr_t1/ds=2000-04-09 [$hdt$_0:pcr_t1]
       Needs Tagging: false
       Reduce Operator Tree:
         Select Operator
@@ -2366,7 +2366,7 @@ STAGE PLANS:
               name: default.pcr_t1
             name: default.pcr_t1
       Truncated Path -> Alias:
-        /pcr_t1/ds=2000-04-08 [$hdt$_0:t1, $hdt$_1:t2]
+        /pcr_t1/ds=2000-04-08 [$hdt$_0:$hdt$_0:t1, $hdt$_0:$hdt$_1:t2]
       Needs Tagging: true
       Reduce Operator Tree:
         Join Operator
@@ -2377,24 +2377,28 @@ STAGE PLANS:
             1 _col0 (type: int)
           outputColumnNames: _col0, _col1, _col3, _col4
           Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            GlobalTableId: 0
+          Select Operator
+            expressions: _col0 (type: int), _col1 (type: string), _col3 (type: int), _col4 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3
+            Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              GlobalTableId: 0
 #### A masked pattern was here ####
-            NumFilesPerFileSink: 1
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                properties:
-                  column.name.delimiter ,
-                  columns _col0,_col1,_col3,_col4
-                  columns.types int,string,int,string
-                  escape.delim \
-                  serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-            TotalFiles: 1
-            GatherStats: false
-            MultiFileSpray: false
+              NumFilesPerFileSink: 1
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  properties:
+                    column.name.delimiter ,
+                    columns _col0,_col1,_col2,_col3
+                    columns.types int,string,int,string
+                    escape.delim \
+                    serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+              TotalFiles: 1
+              GatherStats: false
+              MultiFileSpray: false
 
   Stage: Stage-2
     Map Reduce
@@ -2407,7 +2411,7 @@ STAGE PLANS:
               sort order: +
               Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
               tag: -1
-              value expressions: _col1 (type: string), _col3 (type: int), _col4 (type: string)
+              value expressions: _col1 (type: string), _col2 (type: int), _col3 (type: string)
               auto parallelism: false
       Path -> Alias:
 #### A masked pattern was here ####
@@ -2419,7 +2423,7 @@ STAGE PLANS:
             output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
             properties:
               column.name.delimiter ,
-              columns _col0,_col1,_col3,_col4
+              columns _col0,_col1,_col2,_col3
               columns.types int,string,int,string
               escape.delim \
               serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -2429,7 +2433,7 @@ STAGE PLANS:
               output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
               properties:
                 column.name.delimiter ,
-                columns _col0,_col1,_col3,_col4
+                columns _col0,_col1,_col2,_col3
                 columns.types int,string,int,string
                 escape.delim \
                 serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -2672,8 +2676,8 @@ STAGE PLANS:
               name: default.pcr_t1
             name: default.pcr_t1
       Truncated Path -> Alias:
-        /pcr_t1/ds=2000-04-08 [$hdt$_0:t1]
-        /pcr_t1/ds=2000-04-09 [$hdt$_1:t2]
+        /pcr_t1/ds=2000-04-08 [$hdt$_0:$hdt$_0:t1]
+        /pcr_t1/ds=2000-04-09 [$hdt$_0:$hdt$_1:t2]
       Needs Tagging: true
       Reduce Operator Tree:
         Join Operator
@@ -2684,24 +2688,28 @@ STAGE PLANS:
             1 _col0 (type: int)
           outputColumnNames: _col0, _col1, _col3, _col4
           Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            GlobalTableId: 0
+          Select Operator
+            expressions: _col0 (type: int), _col1 (type: string), _col3 (type: int), _col4 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3
+            Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              GlobalTableId: 0
 #### A masked pattern was here ####
-            NumFilesPerFileSink: 1
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                properties:
-                  column.name.delimiter ,
-                  columns _col0,_col1,_col3,_col4
-                  columns.types int,string,int,string
-                  escape.delim \
-                  serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-            TotalFiles: 1
-            GatherStats: false
-            MultiFileSpray: false
+              NumFilesPerFileSink: 1
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  properties:
+                    column.name.delimiter ,
+                    columns _col0,_col1,_col2,_col3
+                    columns.types int,string,int,string
+                    escape.delim \
+                    serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+              TotalFiles: 1
+              GatherStats: false
+              MultiFileSpray: false
 
   Stage: Stage-2
     Map Reduce
@@ -2714,7 +2722,7 @@ STAGE PLANS:
               sort order: +
               Statistics: Num rows: 22 Data size: 176 Basic stats: COMPLETE Column stats: NONE
               tag: -1
-              value expressions: _col1 (type: string), _col3 (type: int), _col4 (type: string)
+              value expressions: _col1 (type: string), _col2 (type: int), _col3 (type: string)
               auto parallelism: false
       Path -> Alias:
 #### A masked pattern was here ####
@@ -2726,7 +2734,7 @@ STAGE PLANS:
             output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
             properties:
               column.name.delimiter ,
-              columns _col0,_col1,_col3,_col4
+              columns _col0,_col1,_col2,_col3
               columns.types int,string,int,string
               escape.delim \
               serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -2736,7 +2744,7 @@ STAGE PLANS:
               output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
               properties:
                 column.name.delimiter ,
-                columns _col0,_col1,_col3,_col4
+                columns _col0,_col1,_col2,_col3
                 columns.types int,string,int,string
                 escape.delim \
                 serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
@@ -4846,10 +4854,10 @@ STAGE PLANS:
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
               Select Operator
                 expressions: key (type: string), value (type: string), hr (type: string)
-                outputColumnNames: _col0, _col1, _col3
+                outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
                 Reduce Output Operator
-                  key expressions: _col0 (type: string), _col3 (type: string)
+                  key expressions: _col0 (type: string), _col2 (type: string)
                   null sort order: aa
                   sort order: ++
                   Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
@@ -4956,8 +4964,8 @@ STAGE PLANS:
               name: default.srcpart
             name: default.srcpart
       Truncated Path -> Alias:
-        /srcpart/ds=2008-04-08/hr=11 [srcpart]
-        /srcpart/ds=2008-04-08/hr=12 [srcpart]
+        /srcpart/ds=2008-04-08/hr=11 [$hdt$_0:srcpart]
+        /srcpart/ds=2008-04-08/hr=12 [$hdt$_0:srcpart]
       Needs Tagging: false
       Reduce Operator Tree:
         Select Operator
@@ -5139,8 +5147,8 @@ STAGE PLANS:
               name: default.srcpart
             name: default.srcpart
       Truncated Path -> Alias:
-        /srcpart/ds=2008-04-08/hr=11 [srcpart]
-        /srcpart/ds=2008-04-09/hr=11 [srcpart]
+        /srcpart/ds=2008-04-08/hr=11 [$hdt$_0:srcpart]
+        /srcpart/ds=2008-04-09/hr=11 [$hdt$_0:srcpart]
       Needs Tagging: false
       Reduce Operator Tree:
         Select Operator


[4/7] hive git commit: HIVE-15160: Can't order by an unselected column (Pengcheng Xiong, reviewed by Ashutosh Chauhan)

Posted by px...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query64.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query64.q.out b/ql/src/test/results/clientpositive/perf/query64.q.out
index 7f97e39..0d2fc21 100644
--- a/ql/src/test/results/clientpositive/perf/query64.q.out
+++ b/ql/src/test/results/clientpositive/perf/query64.q.out
@@ -53,16 +53,16 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 11
-      File Output Operator [FS_263]
+      File Output Operator [FS_264]
         Select Operator [SEL_262] (rows=273897192 width=88)
           Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20"]
         <-Reducer 10 [SIMPLE_EDGE]
           SHUFFLE [RS_261]
             Select Operator [SEL_260] (rows=273897192 width=88)
-              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col20"]
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18"]
               Filter Operator [FIL_259] (rows=273897192 width=88)
                 predicate:(_col30 <= _col13)
-                Merge Join Operator [MERGEJOIN_610] (rows=821691577 width=88)
+                Merge Join Operator [MERGEJOIN_611] (rows=821691577 width=88)
                   Conds:RS_256._col2, _col1, _col3=RS_257._col2, _col1, _col3(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col13","_col14","_col15","_col16","_col30","_col31","_col32","_col33"]
                 <-Reducer 19 [SIMPLE_EDGE]
                   SHUFFLE [RS_257]
@@ -80,79 +80,79 @@ Stage-0
                               Output:["_col7","_col9","_col14","_col15","_col16","_col17","_col21","_col22","_col23","_col24","_col26","_col27","_col45","_col46","_col47","_col48","_col51"]
                               Filter Operator [FIL_249] (rows=1493984654 width=88)
                                 predicate:(_col56 <> _col19)
-                                Merge Join Operator [MERGEJOIN_609] (rows=1493984654 width=88)
+                                Merge Join Operator [MERGEJOIN_610] (rows=1493984654 width=88)
                                   Conds:RS_246._col39=RS_247._col0(Inner),Output:["_col7","_col9","_col14","_col15","_col16","_col17","_col19","_col21","_col22","_col23","_col24","_col26","_col27","_col45","_col46","_col47","_col48","_col51","_col56"]
                                 <-Map 40 [SIMPLE_EDGE]
                                   SHUFFLE [RS_247]
                                     PartitionCols:_col0
                                     Select Operator [SEL_227] (rows=1861800 width=385)
                                       Output:["_col0","_col1"]
-                                      Filter Operator [FIL_573] (rows=1861800 width=385)
+                                      Filter Operator [FIL_574] (rows=1861800 width=385)
                                         predicate:cd_demo_sk is not null
                                         TableScan [TS_22] (rows=1861800 width=385)
                                           default@customer_demographics,cd2,Tbl:COMPLETE,Col:NONE,Output:["cd_demo_sk","cd_marital_status"]
                                 <-Reducer 17 [SIMPLE_EDGE]
                                   SHUFFLE [RS_246]
                                     PartitionCols:_col39
-                                    Merge Join Operator [MERGEJOIN_608] (rows=1358167838 width=88)
+                                    Merge Join Operator [MERGEJOIN_609] (rows=1358167838 width=88)
                                       Conds:RS_243._col0=RS_244._col18(Inner),Output:["_col7","_col9","_col14","_col15","_col16","_col17","_col19","_col21","_col22","_col23","_col24","_col26","_col27","_col39","_col45","_col46","_col47","_col48","_col51"]
                                     <-Reducer 16 [SIMPLE_EDGE]
                                       SHUFFLE [RS_243]
                                         PartitionCols:_col0
-                                        Merge Join Operator [MERGEJOIN_597] (rows=128840811 width=860)
+                                        Merge Join Operator [MERGEJOIN_598] (rows=128840811 width=860)
                                           Conds:RS_240._col1=RS_241._col0(Inner),Output:["_col0","_col7","_col9","_col14","_col15","_col16","_col17","_col19"]
                                         <-Map 40 [SIMPLE_EDGE]
                                           SHUFFLE [RS_241]
                                             PartitionCols:_col0
                                             Select Operator [SEL_152] (rows=1861800 width=385)
                                               Output:["_col0","_col1"]
-                                              Filter Operator [FIL_561] (rows=1861800 width=385)
+                                              Filter Operator [FIL_562] (rows=1861800 width=385)
                                                 predicate:cd_demo_sk is not null
                                                  Please refer to the previous TableScan [TS_22]
                                         <-Reducer 15 [SIMPLE_EDGE]
                                           SHUFFLE [RS_240]
                                             PartitionCols:_col1
-                                            Merge Join Operator [MERGEJOIN_596] (rows=117128008 width=860)
+                                            Merge Join Operator [MERGEJOIN_597] (rows=117128008 width=860)
                                               Conds:RS_237._col3=RS_238._col0(Inner),Output:["_col0","_col1","_col7","_col9","_col14","_col15","_col16","_col17"]
                                             <-Map 39 [SIMPLE_EDGE]
                                               SHUFFLE [RS_238]
                                                 PartitionCols:_col0
                                                 Select Operator [SEL_149] (rows=40000000 width=1014)
                                                   Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                  Filter Operator [FIL_560] (rows=40000000 width=1014)
+                                                  Filter Operator [FIL_561] (rows=40000000 width=1014)
                                                     predicate:ca_address_sk is not null
                                                     TableScan [TS_19] (rows=40000000 width=1014)
                                                       default@customer_address,ad2,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_street_number","ca_street_name","ca_city","ca_zip"]
                                             <-Reducer 14 [SIMPLE_EDGE]
                                               SHUFFLE [RS_237]
                                                 PartitionCols:_col3
-                                                Merge Join Operator [MERGEJOIN_595] (rows=106480005 width=860)
+                                                Merge Join Operator [MERGEJOIN_596] (rows=106480005 width=860)
                                                   Conds:RS_234._col2=RS_235._col0(Inner),Output:["_col0","_col1","_col3","_col7","_col9"]
                                                 <-Reducer 13 [SIMPLE_EDGE]
                                                   SHUFFLE [RS_234]
                                                     PartitionCols:_col2
-                                                    Merge Join Operator [MERGEJOIN_593] (rows=96800003 width=860)
+                                                    Merge Join Operator [MERGEJOIN_594] (rows=96800003 width=860)
                                                       Conds:RS_231._col4=RS_232._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col7","_col9"]
                                                     <-Map 20 [SIMPLE_EDGE]
                                                       SHUFFLE [RS_232]
                                                         PartitionCols:_col0
                                                         Select Operator [SEL_136] (rows=73049 width=1119)
                                                           Output:["_col0","_col1"]
-                                                          Filter Operator [FIL_557] (rows=73049 width=1119)
+                                                          Filter Operator [FIL_558] (rows=73049 width=1119)
                                                             predicate:d_date_sk is not null
                                                             TableScan [TS_3] (rows=73049 width=1119)
                                                               default@date_dim,d2,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
                                                     <-Reducer 12 [SIMPLE_EDGE]
                                                       SHUFFLE [RS_231]
                                                         PartitionCols:_col4
-                                                        Merge Join Operator [MERGEJOIN_592] (rows=88000001 width=860)
+                                                        Merge Join Operator [MERGEJOIN_593] (rows=88000001 width=860)
                                                           Conds:RS_228._col5=RS_229._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col7"]
                                                         <-Map 20 [SIMPLE_EDGE]
                                                           SHUFFLE [RS_229]
                                                             PartitionCols:_col0
                                                             Select Operator [SEL_133] (rows=73049 width=1119)
                                                               Output:["_col0","_col1"]
-                                                              Filter Operator [FIL_556] (rows=73049 width=1119)
+                                                              Filter Operator [FIL_557] (rows=73049 width=1119)
                                                                 predicate:d_date_sk is not null
                                                                  Please refer to the previous TableScan [TS_3]
                                                         <-Map 1 [SIMPLE_EDGE]
@@ -160,21 +160,21 @@ Stage-0
                                                             PartitionCols:_col5
                                                             Select Operator [SEL_130] (rows=80000000 width=860)
                                                               Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                                              Filter Operator [FIL_555] (rows=80000000 width=860)
+                                                              Filter Operator [FIL_556] (rows=80000000 width=860)
                                                                 predicate:(c_customer_sk is not null and c_first_sales_date_sk is not null and c_first_shipto_date_sk is not null and c_current_cdemo_sk is not null and c_current_hdemo_sk is not null and c_current_addr_sk is not null)
                                                                 TableScan [TS_0] (rows=80000000 width=860)
                                                                   default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_hdemo_sk","c_current_addr_sk","c_first_shipto_date_sk","c_first_sales_date_sk"]
                                                 <-Reducer 36 [SIMPLE_EDGE]
                                                   SHUFFLE [RS_235]
                                                     PartitionCols:_col0
-                                                    Merge Join Operator [MERGEJOIN_594] (rows=7920 width=107)
+                                                    Merge Join Operator [MERGEJOIN_595] (rows=7920 width=107)
                                                       Conds:RS_143._col1=RS_144._col0(Inner),Output:["_col0"]
                                                     <-Map 33 [SIMPLE_EDGE]
                                                       SHUFFLE [RS_143]
                                                         PartitionCols:_col1
                                                         Select Operator [SEL_139] (rows=7200 width=107)
                                                           Output:["_col0","_col1"]
-                                                          Filter Operator [FIL_558] (rows=7200 width=107)
+                                                          Filter Operator [FIL_559] (rows=7200 width=107)
                                                             predicate:(hd_demo_sk is not null and hd_income_band_sk is not null)
                                                             TableScan [TS_9] (rows=7200 width=107)
                                                               default@household_demographics,hd2,Tbl:COMPLETE,Col:NONE,Output:["hd_demo_sk","hd_income_band_sk"]
@@ -183,7 +183,7 @@ Stage-0
                                                         PartitionCols:_col0
                                                         Select Operator [SEL_142] (rows=20 width=12)
                                                           Output:["_col0"]
-                                                          Filter Operator [FIL_559] (rows=20 width=12)
+                                                          Filter Operator [FIL_560] (rows=20 width=12)
                                                             predicate:ib_income_band_sk is not null
                                                             TableScan [TS_12] (rows=20 width=12)
                                                               default@income_band,ib2,Tbl:COMPLETE,Col:NONE,Output:["ib_income_band_sk"]
@@ -192,94 +192,94 @@ Stage-0
                                         PartitionCols:_col18
                                         Select Operator [SEL_224] (rows=1234698008 width=88)
                                           Output:["_col1","_col2","_col3","_col4","_col6","_col7","_col18","_col19","_col25","_col26","_col27","_col28","_col31"]
-                                          Merge Join Operator [MERGEJOIN_607] (rows=1234698008 width=88)
+                                          Merge Join Operator [MERGEJOIN_608] (rows=1234698008 width=88)
                                             Conds:RS_221._col13=RS_222._col0(Inner),Output:["_col10","_col11","_col17","_col18","_col19","_col20","_col23","_col28","_col29","_col31","_col32","_col33","_col34"]
                                           <-Map 39 [SIMPLE_EDGE]
                                             SHUFFLE [RS_222]
                                               PartitionCols:_col0
                                               Select Operator [SEL_208] (rows=40000000 width=1014)
                                                 Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                Filter Operator [FIL_572] (rows=40000000 width=1014)
+                                                Filter Operator [FIL_573] (rows=40000000 width=1014)
                                                   predicate:ca_address_sk is not null
                                                    Please refer to the previous TableScan [TS_19]
                                           <-Reducer 31 [SIMPLE_EDGE]
                                             SHUFFLE [RS_221]
                                               PartitionCols:_col13
-                                              Merge Join Operator [MERGEJOIN_606] (rows=1122452711 width=88)
+                                              Merge Join Operator [MERGEJOIN_607] (rows=1122452711 width=88)
                                                 Conds:RS_218._col14=RS_219._col0(Inner),Output:["_col10","_col11","_col13","_col17","_col18","_col19","_col20","_col23","_col28","_col29"]
                                               <-Map 55 [SIMPLE_EDGE]
                                                 SHUFFLE [RS_219]
                                                   PartitionCols:_col0
                                                   Select Operator [SEL_205] (rows=1704 width=1910)
                                                     Output:["_col0","_col1","_col2"]
-                                                    Filter Operator [FIL_571] (rows=1704 width=1910)
+                                                    Filter Operator [FIL_572] (rows=1704 width=1910)
                                                       predicate:(s_store_sk is not null and s_store_name is not null and s_zip is not null)
                                                       TableScan [TS_75] (rows=1704 width=1910)
                                                         default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_store_name","s_zip"]
                                               <-Reducer 30 [SIMPLE_EDGE]
                                                 SHUFFLE [RS_218]
                                                   PartitionCols:_col14
-                                                  Merge Join Operator [MERGEJOIN_605] (rows=1020411534 width=88)
+                                                  Merge Join Operator [MERGEJOIN_606] (rows=1020411534 width=88)
                                                     Conds:RS_215._col9=RS_216._col0(Inner),Output:["_col10","_col11","_col13","_col14","_col17","_col18","_col19","_col20","_col23"]
                                                   <-Reducer 29 [SIMPLE_EDGE]
                                                     SHUFFLE [RS_215]
                                                       PartitionCols:_col9
-                                                      Merge Join Operator [MERGEJOIN_604] (rows=927646829 width=88)
+                                                      Merge Join Operator [MERGEJOIN_605] (rows=927646829 width=88)
                                                         Conds:RS_212._col0=RS_213._col9(Inner),Output:["_col9","_col10","_col11","_col13","_col14","_col17","_col18","_col19","_col20","_col23"]
                                                       <-Reducer 28 [SIMPLE_EDGE]
                                                         SHUFFLE [RS_213]
                                                           PartitionCols:_col9
                                                           Select Operator [SEL_186] (rows=843315281 width=88)
                                                             Output:["_col6","_col7","_col8","_col9","_col10","_col11","_col14","_col15","_col16","_col17","_col20"]
-                                                            Merge Join Operator [MERGEJOIN_602] (rows=843315281 width=88)
+                                                            Merge Join Operator [MERGEJOIN_603] (rows=843315281 width=88)
                                                               Conds:RS_183._col7=RS_184._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col9","_col10","_col11","_col12","_col15"]
                                                             <-Map 48 [SIMPLE_EDGE]
                                                               SHUFFLE [RS_184]
                                                                 PartitionCols:_col0
                                                                 Select Operator [SEL_173] (rows=2300 width=1179)
                                                                   Output:["_col0"]
-                                                                  Filter Operator [FIL_568] (rows=2300 width=1179)
+                                                                  Filter Operator [FIL_569] (rows=2300 width=1179)
                                                                     predicate:p_promo_sk is not null
                                                                     TableScan [TS_43] (rows=2300 width=1179)
                                                                       default@promotion,promotion,Tbl:COMPLETE,Col:NONE,Output:["p_promo_sk"]
                                                             <-Reducer 27 [SIMPLE_EDGE]
                                                               SHUFFLE [RS_183]
                                                                 PartitionCols:_col7
-                                                                Merge Join Operator [MERGEJOIN_601] (rows=766650239 width=88)
+                                                                Merge Join Operator [MERGEJOIN_602] (rows=766650239 width=88)
                                                                   Conds:RS_180._col0=RS_181._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col9","_col10","_col11","_col12","_col15"]
                                                                 <-Map 20 [SIMPLE_EDGE]
                                                                   SHUFFLE [RS_181]
                                                                     PartitionCols:_col0
                                                                     Select Operator [SEL_170] (rows=36524 width=1119)
                                                                       Output:["_col0"]
-                                                                      Filter Operator [FIL_567] (rows=36524 width=1119)
+                                                                      Filter Operator [FIL_568] (rows=36524 width=1119)
                                                                         predicate:((d_year = 2001) and d_date_sk is not null)
                                                                          Please refer to the previous TableScan [TS_3]
                                                                 <-Reducer 45 [SIMPLE_EDGE]
                                                                   SHUFFLE [RS_180]
                                                                     PartitionCols:_col0
-                                                                    Merge Join Operator [MERGEJOIN_600] (rows=696954748 width=88)
+                                                                    Merge Join Operator [MERGEJOIN_601] (rows=696954748 width=88)
                                                                       Conds:RS_177._col1, _col8=RS_178._col0, _col1(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col9","_col10","_col11","_col12","_col15"]
                                                                     <-Map 47 [SIMPLE_EDGE]
                                                                       SHUFFLE [RS_178]
                                                                         PartitionCols:_col0, _col1
                                                                         Select Operator [SEL_167] (rows=57591150 width=77)
                                                                           Output:["_col0","_col1"]
-                                                                          Filter Operator [FIL_566] (rows=57591150 width=77)
+                                                                          Filter Operator [FIL_567] (rows=57591150 width=77)
                                                                             predicate:(sr_item_sk is not null and sr_ticket_number is not null)
                                                                             TableScan [TS_37] (rows=57591150 width=77)
                                                                               default@store_returns,store_returns,Tbl:COMPLETE,Col:NONE,Output:["sr_item_sk","sr_ticket_number"]
                                                                     <-Reducer 44 [SIMPLE_EDGE]
                                                                       SHUFFLE [RS_177]
                                                                         PartitionCols:_col1, _col8
-                                                                        Merge Join Operator [MERGEJOIN_599] (rows=633595212 width=88)
+                                                                        Merge Join Operator [MERGEJOIN_600] (rows=633595212 width=88)
                                                                           Conds:RS_174._col1=RS_175._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col15"]
                                                                         <-Map 41 [SIMPLE_EDGE]
                                                                           SHUFFLE [RS_174]
                                                                             PartitionCols:_col1
                                                                             Select Operator [SEL_161] (rows=575995635 width=88)
                                                                               Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
-                                                                              Filter Operator [FIL_564] (rows=575995635 width=88)
+                                                                              Filter Operator [FIL_565] (rows=575995635 width=88)
                                                                                 predicate:(ss_item_sk is not null and ss_ticket_number is not null and ss_customer_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_cdemo_sk is not null and ss_promo_sk is not null and ss_hdemo_sk is not null and ss_addr_sk is not null)
                                                                                 TableScan [TS_31] (rows=575995635 width=88)
                                                                                   default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_cdemo_sk","ss_hdemo_sk","ss_addr_sk","ss_store_sk","ss_promo_sk","ss_ticket_number","ss_wholesale_cost","ss_list_price","ss_coupon_amt"]
@@ -288,21 +288,21 @@ Stage-0
                                                                             PartitionCols:_col0
                                                                             Select Operator [SEL_164] (rows=2851 width=1436)
                                                                               Output:["_col0","_col3"]
-                                                                              Filter Operator [FIL_565] (rows=2851 width=1436)
+                                                                              Filter Operator [FIL_566] (rows=2851 width=1436)
                                                                                 predicate:((i_color) IN ('maroon', 'burnished', 'dim', 'steel', 'navajo', 'chocolate') and i_current_price BETWEEN 35 AND 45 and i_current_price BETWEEN 36 AND 50 and i_item_sk is not null)
                                                                                 TableScan [TS_34] (rows=462000 width=1436)
                                                                                   default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_current_price","i_color","i_product_name"]
                                                       <-Reducer 37 [SIMPLE_EDGE]
                                                         SHUFFLE [RS_212]
                                                           PartitionCols:_col0
-                                                          Merge Join Operator [MERGEJOIN_598] (rows=7920 width=107)
+                                                          Merge Join Operator [MERGEJOIN_599] (rows=7920 width=107)
                                                             Conds:RS_209._col1=RS_210._col0(Inner),Output:["_col0"]
                                                           <-Map 33 [SIMPLE_EDGE]
                                                             SHUFFLE [RS_209]
                                                               PartitionCols:_col1
                                                               Select Operator [SEL_155] (rows=7200 width=107)
                                                                 Output:["_col0","_col1"]
-                                                                Filter Operator [FIL_562] (rows=7200 width=107)
+                                                                Filter Operator [FIL_563] (rows=7200 width=107)
                                                                   predicate:(hd_demo_sk is not null and hd_income_band_sk is not null)
                                                                    Please refer to the previous TableScan [TS_9]
                                                           <-Map 38 [SIMPLE_EDGE]
@@ -310,7 +310,7 @@ Stage-0
                                                               PartitionCols:_col0
                                                               Select Operator [SEL_158] (rows=20 width=12)
                                                                 Output:["_col0"]
-                                                                Filter Operator [FIL_563] (rows=20 width=12)
+                                                                Filter Operator [FIL_564] (rows=20 width=12)
                                                                   predicate:ib_income_band_sk is not null
                                                                    Please refer to the previous TableScan [TS_12]
                                                   <-Reducer 53 [SIMPLE_EDGE]
@@ -329,14 +329,14 @@ Stage-0
                                                                 Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","sum(_col2)"],keys:_col0
                                                                 Select Operator [SEL_196] (rows=316788826 width=135)
                                                                   Output:["_col0","_col1","_col2"]
-                                                                  Merge Join Operator [MERGEJOIN_603] (rows=316788826 width=135)
+                                                                  Merge Join Operator [MERGEJOIN_604] (rows=316788826 width=135)
                                                                     Conds:RS_193._col0, _col1=RS_194._col0, _col1(Inner),Output:["_col0","_col2","_col5","_col6","_col7"]
                                                                   <-Map 49 [SIMPLE_EDGE]
                                                                     SHUFFLE [RS_193]
                                                                       PartitionCols:_col0, _col1
                                                                       Select Operator [SEL_189] (rows=287989836 width=135)
                                                                         Output:["_col0","_col1","_col2"]
-                                                                        Filter Operator [FIL_569] (rows=287989836 width=135)
+                                                                        Filter Operator [FIL_570] (rows=287989836 width=135)
                                                                           predicate:(cs_order_number is not null and cs_item_sk is not null)
                                                                           TableScan [TS_59] (rows=287989836 width=135)
                                                                             default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_item_sk","cs_order_number","cs_ext_list_price"]
@@ -345,7 +345,7 @@ Stage-0
                                                                       PartitionCols:_col0, _col1
                                                                       Select Operator [SEL_192] (rows=28798881 width=106)
                                                                         Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                                        Filter Operator [FIL_570] (rows=28798881 width=106)
+                                                                        Filter Operator [FIL_571] (rows=28798881 width=106)
                                                                           predicate:(cr_order_number is not null and cr_item_sk is not null)
                                                                           TableScan [TS_62] (rows=28798881 width=106)
                                                                             default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_item_sk","cr_order_number","cr_refunded_cash","cr_reversed_charge","cr_store_credit"]
@@ -365,111 +365,111 @@ Stage-0
                               Output:["_col7","_col9","_col14","_col15","_col16","_col17","_col21","_col22","_col23","_col24","_col26","_col27","_col45","_col46","_col47","_col48","_col51"]
                               Filter Operator [FIL_121] (rows=1493984654 width=88)
                                 predicate:(_col56 <> _col19)
-                                Merge Join Operator [MERGEJOIN_591] (rows=1493984654 width=88)
+                                Merge Join Operator [MERGEJOIN_592] (rows=1493984654 width=88)
                                   Conds:RS_118._col39=RS_119._col0(Inner),Output:["_col7","_col9","_col14","_col15","_col16","_col17","_col19","_col21","_col22","_col23","_col24","_col26","_col27","_col45","_col46","_col47","_col48","_col51","_col56"]
                                 <-Map 40 [SIMPLE_EDGE]
                                   SHUFFLE [RS_119]
                                     PartitionCols:_col0
                                     Select Operator [SEL_99] (rows=1861800 width=385)
                                       Output:["_col0","_col1"]
-                                      Filter Operator [FIL_554] (rows=1861800 width=385)
+                                      Filter Operator [FIL_555] (rows=1861800 width=385)
                                         predicate:cd_demo_sk is not null
                                          Please refer to the previous TableScan [TS_22]
                                 <-Reducer 7 [SIMPLE_EDGE]
                                   SHUFFLE [RS_118]
                                     PartitionCols:_col39
-                                    Merge Join Operator [MERGEJOIN_590] (rows=1358167838 width=88)
+                                    Merge Join Operator [MERGEJOIN_591] (rows=1358167838 width=88)
                                       Conds:RS_115._col0=RS_116._col18(Inner),Output:["_col7","_col9","_col14","_col15","_col16","_col17","_col19","_col21","_col22","_col23","_col24","_col26","_col27","_col39","_col45","_col46","_col47","_col48","_col51"]
                                     <-Reducer 26 [SIMPLE_EDGE]
                                       SHUFFLE [RS_116]
                                         PartitionCols:_col18
                                         Select Operator [SEL_96] (rows=1234698008 width=88)
                                           Output:["_col1","_col2","_col3","_col4","_col6","_col7","_col18","_col19","_col25","_col26","_col27","_col28","_col31"]
-                                          Merge Join Operator [MERGEJOIN_589] (rows=1234698008 width=88)
+                                          Merge Join Operator [MERGEJOIN_590] (rows=1234698008 width=88)
                                             Conds:RS_93._col13=RS_94._col0(Inner),Output:["_col10","_col11","_col17","_col18","_col19","_col20","_col23","_col28","_col29","_col31","_col32","_col33","_col34"]
                                           <-Map 39 [SIMPLE_EDGE]
                                             SHUFFLE [RS_94]
                                               PartitionCols:_col0
                                               Select Operator [SEL_80] (rows=40000000 width=1014)
                                                 Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                Filter Operator [FIL_553] (rows=40000000 width=1014)
+                                                Filter Operator [FIL_554] (rows=40000000 width=1014)
                                                   predicate:ca_address_sk is not null
                                                    Please refer to the previous TableScan [TS_19]
                                           <-Reducer 25 [SIMPLE_EDGE]
                                             SHUFFLE [RS_93]
                                               PartitionCols:_col13
-                                              Merge Join Operator [MERGEJOIN_588] (rows=1122452711 width=88)
+                                              Merge Join Operator [MERGEJOIN_589] (rows=1122452711 width=88)
                                                 Conds:RS_90._col14=RS_91._col0(Inner),Output:["_col10","_col11","_col13","_col17","_col18","_col19","_col20","_col23","_col28","_col29"]
                                               <-Map 55 [SIMPLE_EDGE]
                                                 SHUFFLE [RS_91]
                                                   PartitionCols:_col0
                                                   Select Operator [SEL_77] (rows=1704 width=1910)
                                                     Output:["_col0","_col1","_col2"]
-                                                    Filter Operator [FIL_552] (rows=1704 width=1910)
+                                                    Filter Operator [FIL_553] (rows=1704 width=1910)
                                                       predicate:(s_store_sk is not null and s_store_name is not null and s_zip is not null)
                                                        Please refer to the previous TableScan [TS_75]
                                               <-Reducer 24 [SIMPLE_EDGE]
                                                 SHUFFLE [RS_90]
                                                   PartitionCols:_col14
-                                                  Merge Join Operator [MERGEJOIN_587] (rows=1020411534 width=88)
+                                                  Merge Join Operator [MERGEJOIN_588] (rows=1020411534 width=88)
                                                     Conds:RS_87._col9=RS_88._col0(Inner),Output:["_col10","_col11","_col13","_col14","_col17","_col18","_col19","_col20","_col23"]
                                                   <-Reducer 23 [SIMPLE_EDGE]
                                                     SHUFFLE [RS_87]
                                                       PartitionCols:_col9
-                                                      Merge Join Operator [MERGEJOIN_586] (rows=927646829 width=88)
+                                                      Merge Join Operator [MERGEJOIN_587] (rows=927646829 width=88)
                                                         Conds:RS_84._col0=RS_85._col9(Inner),Output:["_col9","_col10","_col11","_col13","_col14","_col17","_col18","_col19","_col20","_col23"]
                                                       <-Reducer 22 [SIMPLE_EDGE]
                                                         SHUFFLE [RS_85]
                                                           PartitionCols:_col9
                                                           Select Operator [SEL_58] (rows=843315281 width=88)
                                                             Output:["_col6","_col7","_col8","_col9","_col10","_col11","_col14","_col15","_col16","_col17","_col20"]
-                                                            Merge Join Operator [MERGEJOIN_584] (rows=843315281 width=88)
+                                                            Merge Join Operator [MERGEJOIN_585] (rows=843315281 width=88)
                                                               Conds:RS_55._col7=RS_56._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col9","_col10","_col11","_col12","_col15"]
                                                             <-Map 48 [SIMPLE_EDGE]
                                                               SHUFFLE [RS_56]
                                                                 PartitionCols:_col0
                                                                 Select Operator [SEL_45] (rows=2300 width=1179)
                                                                   Output:["_col0"]
-                                                                  Filter Operator [FIL_549] (rows=2300 width=1179)
+                                                                  Filter Operator [FIL_550] (rows=2300 width=1179)
                                                                     predicate:p_promo_sk is not null
                                                                      Please refer to the previous TableScan [TS_43]
                                                             <-Reducer 21 [SIMPLE_EDGE]
                                                               SHUFFLE [RS_55]
                                                                 PartitionCols:_col7
-                                                                Merge Join Operator [MERGEJOIN_583] (rows=766650239 width=88)
+                                                                Merge Join Operator [MERGEJOIN_584] (rows=766650239 width=88)
                                                                   Conds:RS_52._col0=RS_53._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col9","_col10","_col11","_col12","_col15"]
                                                                 <-Map 20 [SIMPLE_EDGE]
                                                                   SHUFFLE [RS_53]
                                                                     PartitionCols:_col0
                                                                     Select Operator [SEL_42] (rows=36524 width=1119)
                                                                       Output:["_col0"]
-                                                                      Filter Operator [FIL_548] (rows=36524 width=1119)
+                                                                      Filter Operator [FIL_549] (rows=36524 width=1119)
                                                                         predicate:((d_year = 2000) and d_date_sk is not null)
                                                                          Please refer to the previous TableScan [TS_3]
                                                                 <-Reducer 43 [SIMPLE_EDGE]
                                                                   SHUFFLE [RS_52]
                                                                     PartitionCols:_col0
-                                                                    Merge Join Operator [MERGEJOIN_582] (rows=696954748 width=88)
+                                                                    Merge Join Operator [MERGEJOIN_583] (rows=696954748 width=88)
                                                                       Conds:RS_49._col1, _col8=RS_50._col0, _col1(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col9","_col10","_col11","_col12","_col15"]
                                                                     <-Map 47 [SIMPLE_EDGE]
                                                                       SHUFFLE [RS_50]
                                                                         PartitionCols:_col0, _col1
                                                                         Select Operator [SEL_39] (rows=57591150 width=77)
                                                                           Output:["_col0","_col1"]
-                                                                          Filter Operator [FIL_547] (rows=57591150 width=77)
+                                                                          Filter Operator [FIL_548] (rows=57591150 width=77)
                                                                             predicate:(sr_item_sk is not null and sr_ticket_number is not null)
                                                                              Please refer to the previous TableScan [TS_37]
                                                                     <-Reducer 42 [SIMPLE_EDGE]
                                                                       SHUFFLE [RS_49]
                                                                         PartitionCols:_col1, _col8
-                                                                        Merge Join Operator [MERGEJOIN_581] (rows=633595212 width=88)
+                                                                        Merge Join Operator [MERGEJOIN_582] (rows=633595212 width=88)
                                                                           Conds:RS_46._col1=RS_47._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col15"]
                                                                         <-Map 41 [SIMPLE_EDGE]
                                                                           SHUFFLE [RS_46]
                                                                             PartitionCols:_col1
                                                                             Select Operator [SEL_33] (rows=575995635 width=88)
                                                                               Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
-                                                                              Filter Operator [FIL_545] (rows=575995635 width=88)
+                                                                              Filter Operator [FIL_546] (rows=575995635 width=88)
                                                                                 predicate:(ss_item_sk is not null and ss_ticket_number is not null and ss_customer_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_cdemo_sk is not null and ss_promo_sk is not null and ss_hdemo_sk is not null and ss_addr_sk is not null)
                                                                                  Please refer to the previous TableScan [TS_31]
                                                                         <-Map 46 [SIMPLE_EDGE]
@@ -477,20 +477,20 @@ Stage-0
                                                                             PartitionCols:_col0
                                                                             Select Operator [SEL_36] (rows=2851 width=1436)
                                                                               Output:["_col0","_col3"]
-                                                                              Filter Operator [FIL_546] (rows=2851 width=1436)
+                                                                              Filter Operator [FIL_547] (rows=2851 width=1436)
                                                                                 predicate:((i_color) IN ('maroon', 'burnished', 'dim', 'steel', 'navajo', 'chocolate') and i_current_price BETWEEN 35 AND 45 and i_current_price BETWEEN 36 AND 50 and i_item_sk is not null)
                                                                                  Please refer to the previous TableScan [TS_34]
                                                       <-Reducer 35 [SIMPLE_EDGE]
                                                         SHUFFLE [RS_84]
                                                           PartitionCols:_col0
-                                                          Merge Join Operator [MERGEJOIN_580] (rows=7920 width=107)
+                                                          Merge Join Operator [MERGEJOIN_581] (rows=7920 width=107)
                                                             Conds:RS_81._col1=RS_82._col0(Inner),Output:["_col0"]
                                                           <-Map 33 [SIMPLE_EDGE]
                                                             SHUFFLE [RS_81]
                                                               PartitionCols:_col1
                                                               Select Operator [SEL_27] (rows=7200 width=107)
                                                                 Output:["_col0","_col1"]
-                                                                Filter Operator [FIL_543] (rows=7200 width=107)
+                                                                Filter Operator [FIL_544] (rows=7200 width=107)
                                                                   predicate:(hd_demo_sk is not null and hd_income_band_sk is not null)
                                                                    Please refer to the previous TableScan [TS_9]
                                                           <-Map 38 [SIMPLE_EDGE]
@@ -498,7 +498,7 @@ Stage-0
                                                               PartitionCols:_col0
                                                               Select Operator [SEL_30] (rows=20 width=12)
                                                                 Output:["_col0"]
-                                                                Filter Operator [FIL_544] (rows=20 width=12)
+                                                                Filter Operator [FIL_545] (rows=20 width=12)
                                                                   predicate:ib_income_band_sk is not null
                                                                    Please refer to the previous TableScan [TS_12]
                                                   <-Reducer 51 [SIMPLE_EDGE]
@@ -517,14 +517,14 @@ Stage-0
                                                                 Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","sum(_col2)"],keys:_col0
                                                                 Select Operator [SEL_68] (rows=316788826 width=135)
                                                                   Output:["_col0","_col1","_col2"]
-                                                                  Merge Join Operator [MERGEJOIN_585] (rows=316788826 width=135)
+                                                                  Merge Join Operator [MERGEJOIN_586] (rows=316788826 width=135)
                                                                     Conds:RS_65._col0, _col1=RS_66._col0, _col1(Inner),Output:["_col0","_col2","_col5","_col6","_col7"]
                                                                   <-Map 49 [SIMPLE_EDGE]
                                                                     SHUFFLE [RS_65]
                                                                       PartitionCols:_col0, _col1
                                                                       Select Operator [SEL_61] (rows=287989836 width=135)
                                                                         Output:["_col0","_col1","_col2"]
-                                                                        Filter Operator [FIL_550] (rows=287989836 width=135)
+                                                                        Filter Operator [FIL_551] (rows=287989836 width=135)
                                                                           predicate:(cs_order_number is not null and cs_item_sk is not null)
                                                                            Please refer to the previous TableScan [TS_59]
                                                                   <-Map 54 [SIMPLE_EDGE]
@@ -532,64 +532,64 @@ Stage-0
                                                                       PartitionCols:_col0, _col1
                                                                       Select Operator [SEL_64] (rows=28798881 width=106)
                                                                         Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                                        Filter Operator [FIL_551] (rows=28798881 width=106)
+                                                                        Filter Operator [FIL_552] (rows=28798881 width=106)
                                                                           predicate:(cr_order_number is not null and cr_item_sk is not null)
                                                                            Please refer to the previous TableScan [TS_62]
                                     <-Reducer 6 [SIMPLE_EDGE]
                                       SHUFFLE [RS_115]
                                         PartitionCols:_col0
-                                        Merge Join Operator [MERGEJOIN_579] (rows=128840811 width=860)
+                                        Merge Join Operator [MERGEJOIN_580] (rows=128840811 width=860)
                                           Conds:RS_112._col1=RS_113._col0(Inner),Output:["_col0","_col7","_col9","_col14","_col15","_col16","_col17","_col19"]
                                         <-Map 40 [SIMPLE_EDGE]
                                           SHUFFLE [RS_113]
                                             PartitionCols:_col0
                                             Select Operator [SEL_24] (rows=1861800 width=385)
                                               Output:["_col0","_col1"]
-                                              Filter Operator [FIL_542] (rows=1861800 width=385)
+                                              Filter Operator [FIL_543] (rows=1861800 width=385)
                                                 predicate:cd_demo_sk is not null
                                                  Please refer to the previous TableScan [TS_22]
                                         <-Reducer 5 [SIMPLE_EDGE]
                                           SHUFFLE [RS_112]
                                             PartitionCols:_col1
-                                            Merge Join Operator [MERGEJOIN_578] (rows=117128008 width=860)
+                                            Merge Join Operator [MERGEJOIN_579] (rows=117128008 width=860)
                                               Conds:RS_109._col3=RS_110._col0(Inner),Output:["_col0","_col1","_col7","_col9","_col14","_col15","_col16","_col17"]
                                             <-Map 39 [SIMPLE_EDGE]
                                               SHUFFLE [RS_110]
                                                 PartitionCols:_col0
                                                 Select Operator [SEL_21] (rows=40000000 width=1014)
                                                   Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                  Filter Operator [FIL_541] (rows=40000000 width=1014)
+                                                  Filter Operator [FIL_542] (rows=40000000 width=1014)
                                                     predicate:ca_address_sk is not null
                                                      Please refer to the previous TableScan [TS_19]
                                             <-Reducer 4 [SIMPLE_EDGE]
                                               SHUFFLE [RS_109]
                                                 PartitionCols:_col3
-                                                Merge Join Operator [MERGEJOIN_577] (rows=106480005 width=860)
+                                                Merge Join Operator [MERGEJOIN_578] (rows=106480005 width=860)
                                                   Conds:RS_106._col2=RS_107._col0(Inner),Output:["_col0","_col1","_col3","_col7","_col9"]
                                                 <-Reducer 3 [SIMPLE_EDGE]
                                                   SHUFFLE [RS_106]
                                                     PartitionCols:_col2
-                                                    Merge Join Operator [MERGEJOIN_575] (rows=96800003 width=860)
+                                                    Merge Join Operator [MERGEJOIN_576] (rows=96800003 width=860)
                                                       Conds:RS_103._col4=RS_104._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col7","_col9"]
                                                     <-Map 20 [SIMPLE_EDGE]
                                                       SHUFFLE [RS_104]
                                                         PartitionCols:_col0
                                                         Select Operator [SEL_8] (rows=73049 width=1119)
                                                           Output:["_col0","_col1"]
-                                                          Filter Operator [FIL_538] (rows=73049 width=1119)
+                                                          Filter Operator [FIL_539] (rows=73049 width=1119)
                                                             predicate:d_date_sk is not null
                                                              Please refer to the previous TableScan [TS_3]
                                                     <-Reducer 2 [SIMPLE_EDGE]
                                                       SHUFFLE [RS_103]
                                                         PartitionCols:_col4
-                                                        Merge Join Operator [MERGEJOIN_574] (rows=88000001 width=860)
+                                                        Merge Join Operator [MERGEJOIN_575] (rows=88000001 width=860)
                                                           Conds:RS_100._col5=RS_101._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col7"]
                                                         <-Map 20 [SIMPLE_EDGE]
                                                           SHUFFLE [RS_101]
                                                             PartitionCols:_col0
                                                             Select Operator [SEL_5] (rows=73049 width=1119)
                                                               Output:["_col0","_col1"]
-                                                              Filter Operator [FIL_537] (rows=73049 width=1119)
+                                                              Filter Operator [FIL_538] (rows=73049 width=1119)
                                                                 predicate:d_date_sk is not null
                                                                  Please refer to the previous TableScan [TS_3]
                                                         <-Map 1 [SIMPLE_EDGE]
@@ -597,20 +597,20 @@ Stage-0
                                                             PartitionCols:_col5
                                                             Select Operator [SEL_2] (rows=80000000 width=860)
                                                               Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                                              Filter Operator [FIL_536] (rows=80000000 width=860)
+                                                              Filter Operator [FIL_537] (rows=80000000 width=860)
                                                                 predicate:(c_customer_sk is not null and c_first_sales_date_sk is not null and c_first_shipto_date_sk is not null and c_current_cdemo_sk is not null and c_current_hdemo_sk is not null and c_current_addr_sk is not null)
                                                                  Please refer to the previous TableScan [TS_0]
                                                 <-Reducer 34 [SIMPLE_EDGE]
                                                   SHUFFLE [RS_107]
                                                     PartitionCols:_col0
-                                                    Merge Join Operator [MERGEJOIN_576] (rows=7920 width=107)
+                                                    Merge Join Operator [MERGEJOIN_577] (rows=7920 width=107)
                                                       Conds:RS_15._col1=RS_16._col0(Inner),Output:["_col0"]
                                                     <-Map 33 [SIMPLE_EDGE]
                                                       SHUFFLE [RS_15]
                                                         PartitionCols:_col1
                                                         Select Operator [SEL_11] (rows=7200 width=107)
                                                           Output:["_col0","_col1"]
-                                                          Filter Operator [FIL_539] (rows=7200 width=107)
+                                                          Filter Operator [FIL_540] (rows=7200 width=107)
                                                             predicate:(hd_demo_sk is not null and hd_income_band_sk is not null)
                                                              Please refer to the previous TableScan [TS_9]
                                                     <-Map 38 [SIMPLE_EDGE]
@@ -618,7 +618,7 @@ Stage-0
                                                         PartitionCols:_col0
                                                         Select Operator [SEL_14] (rows=20 width=12)
                                                           Output:["_col0"]
-                                                          Filter Operator [FIL_540] (rows=20 width=12)
+                                                          Filter Operator [FIL_541] (rows=20 width=12)
                                                             predicate:ib_income_band_sk is not null
                                                              Please refer to the previous TableScan [TS_12]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query66.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query66.q.out b/ql/src/test/results/clientpositive/perf/query66.q.out
index ec7b6af..19cd0fb 100644
--- a/ql/src/test/results/clientpositive/perf/query66.q.out
+++ b/ql/src/test/results/clientpositive/perf/query66.q.out
@@ -454,18 +454,18 @@ Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 9
-      File Output Operator [FS_76]
-        Limit [LIM_75] (rows=100 width=135)
-          Number of rows:100
-          Select Operator [SEL_74] (rows=158120068 width=135)
-            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41","_col42","_col43"]
-          <-Reducer 8 [SIMPLE_EDGE]
-            SHUFFLE [RS_73]
-              Select Operator [SEL_72] (rows=158120068 width=135)
-                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41","_col42","_col43"]
+      File Output Operator [FS_77]
+        Select Operator [SEL_76] (rows=100 width=135)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41","_col42","_col43"]
+          Limit [LIM_75] (rows=100 width=135)
+            Number of rows:100
+            Select Operator [SEL_74] (rows=158120068 width=135)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"]
+            <-Reducer 8 [SIMPLE_EDGE]
+              SHUFFLE [RS_73]
                 Group By Operator [GBY_71] (rows=158120068 width=135)
                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","sum(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)","sum(VALUE._col12)","sum(VALUE._col13)","sum(VALUE._col14)","sum(VALUE._col15)","sum(VALUE._col16)","sum(VALUE._col17)","sum(VALUE._col18)","sum(VALUE._col19)","sum(VALUE._col20)","sum(VALUE._col21)","sum(VALUE._col22)","sum(VALUE._col23)","sum(VALUE._col24)","sum(VALUE._col25)","sum(VALUE._col26)","sum(VALUE._col27)","sum(VALUE._col28)","sum(VALUE._col29)
 ","sum(VALUE._col30)","sum(VALUE._col31)","sum(VALUE._col32)","sum(VALUE._col33)","sum(VALUE._col34)","sum(VALUE._col35)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
                 <-Union 7 [SIMPLE_EDGE]
@@ -485,56 +485,56 @@ Stage-0
                                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
                                 Select Operator [SEL_60] (rows=421645953 width=135)
                                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"]
-                                  Merge Join Operator [MERGEJOIN_122] (rows=421645953 width=135)
+                                  Merge Join Operator [MERGEJOIN_123] (rows=421645953 width=135)
                                     Conds:RS_57._col3=RS_58._col0(Inner),Output:["_col4","_col5","_col6","_col11","_col15","_col16","_col17","_col18","_col19","_col20"]
                                   <-Map 18 [SIMPLE_EDGE]
                                     SHUFFLE [RS_58]
                                       PartitionCols:_col0
                                       Select Operator [SEL_47] (rows=27 width=1029)
                                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
-                                        Filter Operator [FIL_114] (rows=27 width=1029)
+                                        Filter Operator [FIL_115] (rows=27 width=1029)
                                           predicate:w_warehouse_sk is not null
                                           TableScan [TS_12] (rows=27 width=1029)
                                             default@warehouse,warehouse,Tbl:COMPLETE,Col:NONE,Output:["w_warehouse_sk","w_warehouse_name","w_warehouse_sq_ft","w_city","w_county","w_state","w_country"]
                                   <-Reducer 13 [SIMPLE_EDGE]
                                     SHUFFLE [RS_57]
                                       PartitionCols:_col3
-                                      Merge Join Operator [MERGEJOIN_121] (rows=383314495 width=135)
+                                      Merge Join Operator [MERGEJOIN_122] (rows=383314495 width=135)
                                         Conds:RS_54._col2=RS_55._col0(Inner),Output:["_col3","_col4","_col5","_col6","_col11"]
                                       <-Map 17 [SIMPLE_EDGE]
                                         SHUFFLE [RS_55]
                                           PartitionCols:_col0
                                           Select Operator [SEL_44] (rows=1 width=0)
                                             Output:["_col0"]
-                                            Filter Operator [FIL_113] (rows=1 width=0)
+                                            Filter Operator [FIL_114] (rows=1 width=0)
                                               predicate:((sm_carrier) IN ('DIAMOND', 'AIRBORNE') and sm_ship_mode_sk is not null)
                                               TableScan [TS_9] (rows=1 width=0)
                                                 default@ship_mode,ship_mode,Tbl:PARTIAL,Col:NONE,Output:["sm_ship_mode_sk","sm_carrier"]
                                       <-Reducer 12 [SIMPLE_EDGE]
                                         SHUFFLE [RS_54]
                                           PartitionCols:_col2
-                                          Merge Join Operator [MERGEJOIN_120] (rows=348467716 width=135)
+                                          Merge Join Operator [MERGEJOIN_121] (rows=348467716 width=135)
                                             Conds:RS_51._col0=RS_52._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6","_col11"]
                                           <-Map 16 [SIMPLE_EDGE]
                                             SHUFFLE [RS_52]
                                               PartitionCols:_col0
                                               Select Operator [SEL_41] (rows=36524 width=1119)
                                                 Output:["_col0","_col2"]
-                                                Filter Operator [FIL_112] (rows=36524 width=1119)
+                                                Filter Operator [FIL_113] (rows=36524 width=1119)
                                                   predicate:((d_year = 2002) and d_date_sk is not null)
                                                   TableScan [TS_6] (rows=73049 width=1119)
                                                     default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
                                           <-Reducer 11 [SIMPLE_EDGE]
                                             SHUFFLE [RS_51]
                                               PartitionCols:_col0
-                                              Merge Join Operator [MERGEJOIN_119] (rows=316788826 width=135)
+                                              Merge Join Operator [MERGEJOIN_120] (rows=316788826 width=135)
                                                 Conds:RS_48._col1=RS_49._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6"]
                                               <-Map 10 [SIMPLE_EDGE]
                                                 SHUFFLE [RS_49]
                                                   PartitionCols:_col0
                                                   Select Operator [SEL_38] (rows=9600 width=471)
                                                     Output:["_col0"]
-                                                    Filter Operator [FIL_111] (rows=9600 width=471)
+                                                    Filter Operator [FIL_112] (rows=9600 width=471)
                                                       predicate:(t_time BETWEEN 49530 AND 78330 and t_time_sk is not null)
                                                       TableScan [TS_3] (rows=86400 width=471)
                                                         default@time_dim,time_dim,Tbl:COMPLETE,Col:NONE,Output:["t_time_sk","t_time"]
@@ -543,7 +543,7 @@ Stage-0
                                                   PartitionCols:_col1
                                                   Select Operator [SEL_35] (rows=287989836 width=135)
                                                     Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
-                                                    Filter Operator [FIL_110] (rows=287989836 width=135)
+                                                    Filter Operator [FIL_111] (rows=287989836 width=135)
                                                       predicate:(cs_warehouse_sk is not null and cs_sold_date_sk is not null and cs_sold_time_sk is not null and cs_ship_mode_sk is not null)
                                                       TableScan [TS_33] (rows=287989836 width=135)
                                                         default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_sold_time_sk","cs_ship_mode_sk","cs_warehouse_sk","cs_quantity","cs_ext_sales_price","cs_net_paid_inc_ship_tax"]
@@ -563,53 +563,53 @@ Stage-0
                                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
                                 Select Operator [SEL_27] (rows=210834322 width=135)
                                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"]
-                                  Merge Join Operator [MERGEJOIN_118] (rows=210834322 width=135)
+                                  Merge Join Operator [MERGEJOIN_119] (rows=210834322 width=135)
                                     Conds:RS_24._col3=RS_25._col0(Inner),Output:["_col4","_col5","_col6","_col11","_col15","_col16","_col17","_col18","_col19","_col20"]
                                   <-Map 18 [SIMPLE_EDGE]
                                     SHUFFLE [RS_25]
                                       PartitionCols:_col0
                                       Select Operator [SEL_14] (rows=27 width=1029)
                                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
-                                        Filter Operator [FIL_109] (rows=27 width=1029)
+                                        Filter Operator [FIL_110] (rows=27 width=1029)
                                           predicate:w_warehouse_sk is not null
                                            Please refer to the previous TableScan [TS_12]
                                   <-Reducer 4 [SIMPLE_EDGE]
                                     SHUFFLE [RS_24]
                                       PartitionCols:_col3
-                                      Merge Join Operator [MERGEJOIN_117] (rows=191667562 width=135)
+                                      Merge Join Operator [MERGEJOIN_118] (rows=191667562 width=135)
                                         Conds:RS_21._col2=RS_22._col0(Inner),Output:["_col3","_col4","_col5","_col6","_col11"]
                                       <-Map 17 [SIMPLE_EDGE]
                                         SHUFFLE [RS_22]
                                           PartitionCols:_col0
                                           Select Operator [SEL_11] (rows=1 width=0)
                                             Output:["_col0"]
-                                            Filter Operator [FIL_108] (rows=1 width=0)
+                                            Filter Operator [FIL_109] (rows=1 width=0)
                                               predicate:((sm_carrier) IN ('DIAMOND', 'AIRBORNE') and sm_ship_mode_sk is not null)
                                                Please refer to the previous TableScan [TS_9]
                                       <-Reducer 3 [SIMPLE_EDGE]
                                         SHUFFLE [RS_21]
                                           PartitionCols:_col2
-                                          Merge Join Operator [MERGEJOIN_116] (rows=174243235 width=135)
+                                          Merge Join Operator [MERGEJOIN_117] (rows=174243235 width=135)
                                             Conds:RS_18._col0=RS_19._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6","_col11"]
                                           <-Map 16 [SIMPLE_EDGE]
                                             SHUFFLE [RS_19]
                                               PartitionCols:_col0
                                               Select Operator [SEL_8] (rows=36524 width=1119)
                                                 Output:["_col0","_col2"]
-                                                Filter Operator [FIL_107] (rows=36524 width=1119)
+                                                Filter Operator [FIL_108] (rows=36524 width=1119)
                                                   predicate:((d_year = 2002) and d_date_sk is not null)
                                                    Please refer to the previous TableScan [TS_6]
                                           <-Reducer 2 [SIMPLE_EDGE]
                                             SHUFFLE [RS_18]
                                               PartitionCols:_col0
-                                              Merge Join Operator [MERGEJOIN_115] (rows=158402938 width=135)
+                                              Merge Join Operator [MERGEJOIN_116] (rows=158402938 width=135)
                                                 Conds:RS_15._col1=RS_16._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6"]
                                               <-Map 10 [SIMPLE_EDGE]
                                                 SHUFFLE [RS_16]
                                                   PartitionCols:_col0
                                                   Select Operator [SEL_5] (rows=9600 width=471)
                                                     Output:["_col0"]
-                                                    Filter Operator [FIL_106] (rows=9600 width=471)
+                                                    Filter Operator [FIL_107] (rows=9600 width=471)
                                                       predicate:(t_time BETWEEN 49530 AND 78330 and t_time_sk is not null)
                                                        Please refer to the previous TableScan [TS_3]
                                               <-Map 1 [SIMPLE_EDGE]
@@ -617,7 +617,7 @@ Stage-0
                                                   PartitionCols:_col1
                                                   Select Operator [SEL_2] (rows=144002668 width=135)
                                                     Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
-                                                    Filter Operator [FIL_105] (rows=144002668 width=135)
+                                                    Filter Operator [FIL_106] (rows=144002668 width=135)
                                                       predicate:(ws_warehouse_sk is not null and ws_sold_date_sk is not null and ws_sold_time_sk is not null and ws_ship_mode_sk is not null)
                                                       TableScan [TS_0] (rows=144002668 width=135)
                                                         default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_sold_time_sk","ws_ship_mode_sk","ws_warehouse_sk","ws_quantity","ws_sales_price","ws_net_paid_inc_tax"]


[5/7] hive git commit: HIVE-15160: Can't order by an unselected column (Pengcheng Xiong, reviewed by Ashutosh Chauhan)

Posted by px...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query31.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query31.q.out b/ql/src/test/results/clientpositive/perf/query31.q.out
index 9e3dad4..b456244 100644
--- a/ql/src/test/results/clientpositive/perf/query31.q.out
+++ b/ql/src/test/results/clientpositive/perf/query31.q.out
@@ -32,16 +32,16 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 6
-      File Output Operator [FS_135]
+      File Output Operator [FS_136]
         Select Operator [SEL_134] (rows=287493839 width=88)
           Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
         <-Reducer 5 [SIMPLE_EDGE]
           SHUFFLE [RS_133]
             Select Operator [SEL_132] (rows=287493839 width=88)
-              Output:["_col0","_col2","_col3","_col4","_col5"]
+              Output:["_col0","_col1","_col2","_col3","_col4"]
               Filter Operator [FIL_130] (rows=287493839 width=88)
                 predicate:(CASE WHEN ((_col1 > 0)) THEN (CASE WHEN ((_col9 > 0)) THEN (((_col11 / _col9) > (_col5 / _col1))) ELSE ((null > (_col5 / _col1))) END) ELSE (CASE WHEN ((_col9 > 0)) THEN (((_col11 / _col9) > null)) ELSE (null) END) END and CASE WHEN ((_col3 > 0)) THEN (CASE WHEN ((_col7 > 0)) THEN (((_col9 / _col7) > (_col1 / _col3))) ELSE ((null > (_col1 / _col3))) END) ELSE (CASE WHEN ((_col7 > 0)) THEN (((_col9 / _col7) > null)) ELSE (null) END) END)
-                Merge Join Operator [MERGEJOIN_269] (rows=1149975359 width=88)
+                Merge Join Operator [MERGEJOIN_270] (rows=1149975359 width=88)
                   Conds:RS_125._col0=RS_126._col0(Inner),RS_125._col0=RS_127._col0(Inner),RS_125._col0=RS_128._col0(Inner),Output:["_col0","_col1","_col3","_col5","_col7","_col9","_col11"]
                 <-Reducer 12 [SIMPLE_EDGE]
                   SHUFFLE [RS_127]
@@ -53,28 +53,28 @@ Stage-0
                         PartitionCols:_col0
                         Group By Operator [GBY_56] (rows=696954748 width=88)
                           Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
-                          Merge Join Operator [MERGEJOIN_261] (rows=696954748 width=88)
+                          Merge Join Operator [MERGEJOIN_262] (rows=696954748 width=88)
                             Conds:RS_52._col1=RS_53._col0(Inner),Output:["_col2","_col7"]
                           <-Map 24 [SIMPLE_EDGE]
                             SHUFFLE [RS_53]
                               PartitionCols:_col0
                               Select Operator [SEL_48] (rows=40000000 width=1014)
                                 Output:["_col0","_col1"]
-                                Filter Operator [FIL_246] (rows=40000000 width=1014)
+                                Filter Operator [FIL_247] (rows=40000000 width=1014)
                                   predicate:(ca_address_sk is not null and ca_county is not null)
                                   TableScan [TS_6] (rows=40000000 width=1014)
                                     default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_county"]
                           <-Reducer 10 [SIMPLE_EDGE]
                             SHUFFLE [RS_52]
                               PartitionCols:_col1
-                              Merge Join Operator [MERGEJOIN_260] (rows=633595212 width=88)
+                              Merge Join Operator [MERGEJOIN_261] (rows=633595212 width=88)
                                 Conds:RS_49._col0=RS_50._col0(Inner),Output:["_col1","_col2"]
                               <-Map 13 [SIMPLE_EDGE]
                                 SHUFFLE [RS_50]
                                   PartitionCols:_col0
                                   Select Operator [SEL_45] (rows=18262 width=1119)
                                     Output:["_col0"]
-                                    Filter Operator [FIL_245] (rows=18262 width=1119)
+                                    Filter Operator [FIL_246] (rows=18262 width=1119)
                                       predicate:((d_qoy = 3) and (d_year = 1998) and d_date_sk is not null)
                                       TableScan [TS_3] (rows=73049 width=1119)
                                         default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_qoy"]
@@ -83,14 +83,14 @@ Stage-0
                                   PartitionCols:_col0
                                   Select Operator [SEL_42] (rows=575995635 width=88)
                                     Output:["_col0","_col1","_col2"]
-                                    Filter Operator [FIL_244] (rows=575995635 width=88)
+                                    Filter Operator [FIL_245] (rows=575995635 width=88)
                                       predicate:(ss_sold_date_sk is not null and ss_addr_sk is not null)
                                       TableScan [TS_0] (rows=575995635 width=88)
                                         default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_addr_sk","ss_ext_sales_price"]
                 <-Reducer 17 [SIMPLE_EDGE]
                   SHUFFLE [RS_128]
                     PartitionCols:_col0
-                    Merge Join Operator [MERGEJOIN_268] (rows=191667561 width=135)
+                    Merge Join Operator [MERGEJOIN_269] (rows=191667561 width=135)
                       Conds:RS_120._col0=RS_121._col0(Inner),RS_120._col0=RS_122._col0(Inner),Output:["_col0","_col1","_col3","_col5"]
                     <-Reducer 16 [SIMPLE_EDGE]
                       SHUFFLE [RS_120]
@@ -102,27 +102,27 @@ Stage-0
                             PartitionCols:_col0
                             Group By Operator [GBY_76] (rows=174243235 width=135)
                               Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
-                              Merge Join Operator [MERGEJOIN_263] (rows=174243235 width=135)
+                              Merge Join Operator [MERGEJOIN_264] (rows=174243235 width=135)
                                 Conds:RS_72._col1=RS_73._col0(Inner),Output:["_col2","_col7"]
                               <-Map 24 [SIMPLE_EDGE]
                                 SHUFFLE [RS_73]
                                   PartitionCols:_col0
                                   Select Operator [SEL_68] (rows=40000000 width=1014)
                                     Output:["_col0","_col1"]
-                                    Filter Operator [FIL_249] (rows=40000000 width=1014)
+                                    Filter Operator [FIL_250] (rows=40000000 width=1014)
                                       predicate:(ca_address_sk is not null and ca_county is not null)
                                        Please refer to the previous TableScan [TS_6]
                               <-Reducer 14 [SIMPLE_EDGE]
                                 SHUFFLE [RS_72]
                                   PartitionCols:_col1
-                                  Merge Join Operator [MERGEJOIN_262] (rows=158402938 width=135)
+                                  Merge Join Operator [MERGEJOIN_263] (rows=158402938 width=135)
                                     Conds:RS_69._col0=RS_70._col0(Inner),Output:["_col1","_col2"]
                                   <-Map 13 [SIMPLE_EDGE]
                                     SHUFFLE [RS_70]
                                       PartitionCols:_col0
                                       Select Operator [SEL_65] (rows=18262 width=1119)
                                         Output:["_col0"]
-                                        Filter Operator [FIL_248] (rows=18262 width=1119)
+                                        Filter Operator [FIL_249] (rows=18262 width=1119)
                                           predicate:((d_qoy = 1) and (d_year = 1998) and d_date_sk is not null)
                                            Please refer to the previous TableScan [TS_3]
                                   <-Map 25 [SIMPLE_EDGE]
@@ -130,7 +130,7 @@ Stage-0
                                       PartitionCols:_col0
                                       Select Operator [SEL_62] (rows=144002668 width=135)
                                         Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_247] (rows=144002668 width=135)
+                                        Filter Operator [FIL_248] (rows=144002668 width=135)
                                           predicate:(ws_sold_date_sk is not null and ws_bill_addr_sk is not null)
                                           TableScan [TS_60] (rows=144002668 width=135)
                                             default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_bill_addr_sk","ws_ext_sales_price"]
@@ -144,27 +144,27 @@ Stage-0
                             PartitionCols:_col0
                             Group By Operator [GBY_96] (rows=174243235 width=135)
                               Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
-                              Merge Join Operator [MERGEJOIN_265] (rows=174243235 width=135)
+                              Merge Join Operator [MERGEJOIN_266] (rows=174243235 width=135)
                                 Conds:RS_92._col1=RS_93._col0(Inner),Output:["_col2","_col7"]
                               <-Map 24 [SIMPLE_EDGE]
                                 SHUFFLE [RS_93]
                                   PartitionCols:_col0
                                   Select Operator [SEL_88] (rows=40000000 width=1014)
                                     Output:["_col0","_col1"]
-                                    Filter Operator [FIL_252] (rows=40000000 width=1014)
+                                    Filter Operator [FIL_253] (rows=40000000 width=1014)
                                       predicate:(ca_address_sk is not null and ca_county is not null)
                                        Please refer to the previous TableScan [TS_6]
                               <-Reducer 18 [SIMPLE_EDGE]
                                 SHUFFLE [RS_92]
                                   PartitionCols:_col1
-                                  Merge Join Operator [MERGEJOIN_264] (rows=158402938 width=135)
+                                  Merge Join Operator [MERGEJOIN_265] (rows=158402938 width=135)
                                     Conds:RS_89._col0=RS_90._col0(Inner),Output:["_col1","_col2"]
                                   <-Map 13 [SIMPLE_EDGE]
                                     SHUFFLE [RS_90]
                                       PartitionCols:_col0
                                       Select Operator [SEL_85] (rows=18262 width=1119)
                                         Output:["_col0"]
-                                        Filter Operator [FIL_251] (rows=18262 width=1119)
+                                        Filter Operator [FIL_252] (rows=18262 width=1119)
                                           predicate:((d_qoy = 2) and (d_year = 1998) and d_date_sk is not null)
                                            Please refer to the previous TableScan [TS_3]
                                   <-Map 25 [SIMPLE_EDGE]
@@ -172,7 +172,7 @@ Stage-0
                                       PartitionCols:_col0
                                       Select Operator [SEL_82] (rows=144002668 width=135)
                                         Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_250] (rows=144002668 width=135)
+                                        Filter Operator [FIL_251] (rows=144002668 width=135)
                                           predicate:(ws_sold_date_sk is not null and ws_bill_addr_sk is not null)
                                            Please refer to the previous TableScan [TS_60]
                     <-Reducer 23 [SIMPLE_EDGE]
@@ -185,27 +185,27 @@ Stage-0
                             PartitionCols:_col0
                             Group By Operator [GBY_116] (rows=174243235 width=135)
                               Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
-                              Merge Join Operator [MERGEJOIN_267] (rows=174243235 width=135)
+                              Merge Join Operator [MERGEJOIN_268] (rows=174243235 width=135)
                                 Conds:RS_112._col1=RS_113._col0(Inner),Output:["_col2","_col7"]
                               <-Map 24 [SIMPLE_EDGE]
                                 SHUFFLE [RS_113]
                                   PartitionCols:_col0
                                   Select Operator [SEL_108] (rows=40000000 width=1014)
                                     Output:["_col0","_col1"]
-                                    Filter Operator [FIL_255] (rows=40000000 width=1014)
+                                    Filter Operator [FIL_256] (rows=40000000 width=1014)
                                       predicate:(ca_address_sk is not null and ca_county is not null)
                                        Please refer to the previous TableScan [TS_6]
                               <-Reducer 21 [SIMPLE_EDGE]
                                 SHUFFLE [RS_112]
                                   PartitionCols:_col1
-                                  Merge Join Operator [MERGEJOIN_266] (rows=158402938 width=135)
+                                  Merge Join Operator [MERGEJOIN_267] (rows=158402938 width=135)
                                     Conds:RS_109._col0=RS_110._col0(Inner),Output:["_col1","_col2"]
                                   <-Map 13 [SIMPLE_EDGE]
                                     SHUFFLE [RS_110]
                                       PartitionCols:_col0
                                       Select Operator [SEL_105] (rows=18262 width=1119)
                                         Output:["_col0"]
-                                        Filter Operator [FIL_254] (rows=18262 width=1119)
+                                        Filter Operator [FIL_255] (rows=18262 width=1119)
                                           predicate:((d_qoy = 3) and (d_year = 1998) and d_date_sk is not null)
                                            Please refer to the previous TableScan [TS_3]
                                   <-Map 25 [SIMPLE_EDGE]
@@ -213,7 +213,7 @@ Stage-0
                                       PartitionCols:_col0
                                       Select Operator [SEL_102] (rows=144002668 width=135)
                                         Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_253] (rows=144002668 width=135)
+                                        Filter Operator [FIL_254] (rows=144002668 width=135)
                                           predicate:(ws_sold_date_sk is not null and ws_bill_addr_sk is not null)
                                            Please refer to the previous TableScan [TS_60]
                 <-Reducer 4 [SIMPLE_EDGE]
@@ -226,27 +226,27 @@ Stage-0
                         PartitionCols:_col0
                         Group By Operator [GBY_16] (rows=696954748 width=88)
                           Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
-                          Merge Join Operator [MERGEJOIN_257] (rows=696954748 width=88)
+                          Merge Join Operator [MERGEJOIN_258] (rows=696954748 width=88)
                             Conds:RS_12._col1=RS_13._col0(Inner),Output:["_col2","_col7"]
                           <-Map 24 [SIMPLE_EDGE]
                             SHUFFLE [RS_13]
                               PartitionCols:_col0
                               Select Operator [SEL_8] (rows=40000000 width=1014)
                                 Output:["_col0","_col1"]
-                                Filter Operator [FIL_240] (rows=40000000 width=1014)
+                                Filter Operator [FIL_241] (rows=40000000 width=1014)
                                   predicate:(ca_address_sk is not null and ca_county is not null)
                                    Please refer to the previous TableScan [TS_6]
                           <-Reducer 2 [SIMPLE_EDGE]
                             SHUFFLE [RS_12]
                               PartitionCols:_col1
-                              Merge Join Operator [MERGEJOIN_256] (rows=633595212 width=88)
+                              Merge Join Operator [MERGEJOIN_257] (rows=633595212 width=88)
                                 Conds:RS_9._col0=RS_10._col0(Inner),Output:["_col1","_col2"]
                               <-Map 13 [SIMPLE_EDGE]
                                 SHUFFLE [RS_10]
                                   PartitionCols:_col0
                                   Select Operator [SEL_5] (rows=18262 width=1119)
                                     Output:["_col0"]
-                                    Filter Operator [FIL_239] (rows=18262 width=1119)
+                                    Filter Operator [FIL_240] (rows=18262 width=1119)
                                       predicate:((d_qoy = 2) and (d_year = 1998) and d_date_sk is not null)
                                        Please refer to the previous TableScan [TS_3]
                               <-Map 1 [SIMPLE_EDGE]
@@ -254,7 +254,7 @@ Stage-0
                                   PartitionCols:_col0
                                   Select Operator [SEL_2] (rows=575995635 width=88)
                                     Output:["_col0","_col1","_col2"]
-                                    Filter Operator [FIL_238] (rows=575995635 width=88)
+                                    Filter Operator [FIL_239] (rows=575995635 width=88)
                                       predicate:(ss_sold_date_sk is not null and ss_addr_sk is not null)
                                        Please refer to the previous TableScan [TS_0]
                 <-Reducer 9 [SIMPLE_EDGE]
@@ -267,27 +267,27 @@ Stage-0
                         PartitionCols:_col0
                         Group By Operator [GBY_36] (rows=696954748 width=88)
                           Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
-                          Merge Join Operator [MERGEJOIN_259] (rows=696954748 width=88)
+                          Merge Join Operator [MERGEJOIN_260] (rows=696954748 width=88)
                             Conds:RS_32._col1=RS_33._col0(Inner),Output:["_col2","_col7"]
                           <-Map 24 [SIMPLE_EDGE]
                             SHUFFLE [RS_33]
                               PartitionCols:_col0
                               Select Operator [SEL_28] (rows=40000000 width=1014)
                                 Output:["_col0","_col1"]
-                                Filter Operator [FIL_243] (rows=40000000 width=1014)
+                                Filter Operator [FIL_244] (rows=40000000 width=1014)
                                   predicate:(ca_address_sk is not null and ca_county is not null)
                                    Please refer to the previous TableScan [TS_6]
                           <-Reducer 7 [SIMPLE_EDGE]
                             SHUFFLE [RS_32]
                               PartitionCols:_col1
-                              Merge Join Operator [MERGEJOIN_258] (rows=633595212 width=88)
+                              Merge Join Operator [MERGEJOIN_259] (rows=633595212 width=88)
                                 Conds:RS_29._col0=RS_30._col0(Inner),Output:["_col1","_col2"]
                               <-Map 13 [SIMPLE_EDGE]
                                 SHUFFLE [RS_30]
                                   PartitionCols:_col0
                                   Select Operator [SEL_25] (rows=18262 width=1119)
                                     Output:["_col0"]
-                                    Filter Operator [FIL_242] (rows=18262 width=1119)
+                                    Filter Operator [FIL_243] (rows=18262 width=1119)
                                       predicate:((d_qoy = 1) and (d_year = 1998) and d_date_sk is not null)
                                        Please refer to the previous TableScan [TS_3]
                               <-Map 1 [SIMPLE_EDGE]
@@ -295,7 +295,7 @@ Stage-0
                                   PartitionCols:_col0
                                   Select Operator [SEL_22] (rows=575995635 width=88)
                                     Output:["_col0","_col1","_col2"]
-                                    Filter Operator [FIL_241] (rows=575995635 width=88)
+                                    Filter Operator [FIL_242] (rows=575995635 width=88)
                                       predicate:(ss_sold_date_sk is not null and ss_addr_sk is not null)
                                        Please refer to the previous TableScan [TS_0]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query36.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query36.q.out b/ql/src/test/results/clientpositive/perf/query36.q.out
index 57ab26a..b5110d9 100644
--- a/ql/src/test/results/clientpositive/perf/query36.q.out
+++ b/ql/src/test/results/clientpositive/perf/query36.q.out
@@ -68,10 +68,10 @@ Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 7
-      File Output Operator [FS_35]
+      File Output Operator [FS_36]
         Limit [LIM_34] (rows=100 width=88)
           Number of rows:100
           Select Operator [SEL_33] (rows=1149975358 width=88)
@@ -79,7 +79,7 @@ Stage-0
           <-Reducer 6 [SIMPLE_EDGE]
             SHUFFLE [RS_32]
               Select Operator [SEL_30] (rows=1149975358 width=88)
-                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                 PTF Operator [PTF_29] (rows=1149975358 width=88)
                   Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(_col4 / _col5) ASC NULLS FIRST","partition by:":"(grouping(_col6, 1) + grouping(_col6, 0)), CASE WHEN ((grouping(_col6, 0) = 0)) THEN (_col0) ELSE (null) END"}]
                   Select Operator [SEL_28] (rows=1149975358 width=88)
@@ -98,42 +98,42 @@ Stage-0
                               Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col2)","sum(_col3)"],keys:_col0, _col1, 0
                               Select Operator [SEL_21] (rows=766650239 width=88)
                                 Output:["_col0","_col1","_col2","_col3"]
-                                Merge Join Operator [MERGEJOIN_51] (rows=766650239 width=88)
+                                Merge Join Operator [MERGEJOIN_52] (rows=766650239 width=88)
                                   Conds:RS_18._col1=RS_19._col0(Inner),Output:["_col3","_col4","_col10","_col11"]
                                 <-Map 10 [SIMPLE_EDGE]
                                   SHUFFLE [RS_19]
                                     PartitionCols:_col0
                                     Select Operator [SEL_11] (rows=462000 width=1436)
                                       Output:["_col0","_col1","_col2"]
-                                      Filter Operator [FIL_48] (rows=462000 width=1436)
+                                      Filter Operator [FIL_49] (rows=462000 width=1436)
                                         predicate:i_item_sk is not null
                                         TableScan [TS_9] (rows=462000 width=1436)
                                           default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_class","i_category"]
                                 <-Reducer 3 [SIMPLE_EDGE]
                                   SHUFFLE [RS_18]
                                     PartitionCols:_col1
-                                    Merge Join Operator [MERGEJOIN_50] (rows=696954748 width=88)
+                                    Merge Join Operator [MERGEJOIN_51] (rows=696954748 width=88)
                                       Conds:RS_15._col2=RS_16._col0(Inner),Output:["_col1","_col3","_col4"]
                                     <-Map 9 [SIMPLE_EDGE]
                                       SHUFFLE [RS_16]
                                         PartitionCols:_col0
                                         Select Operator [SEL_8] (rows=852 width=1910)
                                           Output:["_col0"]
-                                          Filter Operator [FIL_47] (rows=852 width=1910)
+                                          Filter Operator [FIL_48] (rows=852 width=1910)
                                             predicate:((s_state) IN ('SD', 'FL', 'MI', 'LA', 'MO', 'SC', 'AL', 'GA') and s_store_sk is not null)
                                             TableScan [TS_6] (rows=1704 width=1910)
                                               default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_state"]
                                     <-Reducer 2 [SIMPLE_EDGE]
                                       SHUFFLE [RS_15]
                                         PartitionCols:_col2
-                                        Merge Join Operator [MERGEJOIN_49] (rows=633595212 width=88)
+                                        Merge Join Operator [MERGEJOIN_50] (rows=633595212 width=88)
                                           Conds:RS_12._col0=RS_13._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
                                         <-Map 1 [SIMPLE_EDGE]
                                           SHUFFLE [RS_12]
                                             PartitionCols:_col0
                                             Select Operator [SEL_2] (rows=575995635 width=88)
                                               Output:["_col0","_col1","_col2","_col3","_col4"]
-                                              Filter Operator [FIL_45] (rows=575995635 width=88)
+                                              Filter Operator [FIL_46] (rows=575995635 width=88)
                                                 predicate:(ss_sold_date_sk is not null and ss_item_sk is not null and ss_store_sk is not null)
                                                 TableScan [TS_0] (rows=575995635 width=88)
                                                   default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_ext_sales_price","ss_net_profit"]
@@ -142,7 +142,7 @@ Stage-0
                                             PartitionCols:_col0
                                             Select Operator [SEL_5] (rows=36524 width=1119)
                                               Output:["_col0"]
-                                              Filter Operator [FIL_46] (rows=36524 width=1119)
+                                              Filter Operator [FIL_47] (rows=36524 width=1119)
                                                 predicate:((d_year = 1999) and d_date_sk is not null)
                                                 TableScan [TS_3] (rows=73049 width=1119)
                                                   default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query39.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query39.q.out b/ql/src/test/results/clientpositive/perf/query39.q.out
index dcf3cb2..3e34c27 100644
--- a/ql/src/test/results/clientpositive/perf/query39.q.out
+++ b/ql/src/test/results/clientpositive/perf/query39.q.out
@@ -21,14 +21,14 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 7
-      File Output Operator [FS_62]
+      File Output Operator [FS_63]
         Select Operator [SEL_61] (rows=13756683 width=15)
           Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
         <-Reducer 6 [SIMPLE_EDGE]
           SHUFFLE [RS_60]
             Select Operator [SEL_59] (rows=13756683 width=15)
-              Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col8","_col9"]
-              Merge Join Operator [MERGEJOIN_103] (rows=13756683 width=15)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+              Merge Join Operator [MERGEJOIN_104] (rows=13756683 width=15)
                 Conds:RS_56._col1, _col2=RS_57._col1, _col2(Inner),Output:["_col1","_col2","_col3","_col4","_col6","_col7","_col8","_col9"]
               <-Reducer 11 [SIMPLE_EDGE]
                 SHUFFLE [RS_57]
@@ -46,42 +46,42 @@ Stage-0
                             PartitionCols:_col0, _col1, _col2
                             Group By Operator [GBY_50] (rows=50024305 width=15)
                               Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["stddev_samp(_col3)","avg(_col3)"],keys:_col8, _col7, _col9
-                              Merge Join Operator [MERGEJOIN_102] (rows=50024305 width=15)
+                              Merge Join Operator [MERGEJOIN_103] (rows=50024305 width=15)
                                 Conds:RS_46._col2=RS_47._col0(Inner),Output:["_col3","_col7","_col8","_col9"]
                               <-Map 14 [SIMPLE_EDGE]
                                 SHUFFLE [RS_47]
                                   PartitionCols:_col0
                                   Select Operator [SEL_39] (rows=27 width=1029)
                                     Output:["_col0","_col1"]
-                                    Filter Operator [FIL_96] (rows=27 width=1029)
+                                    Filter Operator [FIL_97] (rows=27 width=1029)
                                       predicate:w_warehouse_sk is not null
                                       TableScan [TS_9] (rows=27 width=1029)
                                         default@warehouse,warehouse,Tbl:COMPLETE,Col:NONE,Output:["w_warehouse_sk","w_warehouse_name"]
                               <-Reducer 9 [SIMPLE_EDGE]
                                 SHUFFLE [RS_46]
                                   PartitionCols:_col2
-                                  Merge Join Operator [MERGEJOIN_101] (rows=45476640 width=15)
+                                  Merge Join Operator [MERGEJOIN_102] (rows=45476640 width=15)
                                     Conds:RS_43._col1=RS_44._col0(Inner),Output:["_col2","_col3","_col7"]
                                   <-Map 13 [SIMPLE_EDGE]
                                     SHUFFLE [RS_44]
                                       PartitionCols:_col0
                                       Select Operator [SEL_36] (rows=462000 width=1436)
                                         Output:["_col0"]
-                                        Filter Operator [FIL_95] (rows=462000 width=1436)
+                                        Filter Operator [FIL_96] (rows=462000 width=1436)
                                           predicate:i_item_sk is not null
                                           TableScan [TS_6] (rows=462000 width=1436)
                                             default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk"]
                                   <-Reducer 8 [SIMPLE_EDGE]
                                     SHUFFLE [RS_43]
                                       PartitionCols:_col1
-                                      Merge Join Operator [MERGEJOIN_100] (rows=41342400 width=15)
+                                      Merge Join Operator [MERGEJOIN_101] (rows=41342400 width=15)
                                         Conds:RS_40._col0=RS_41._col0(Inner),Output:["_col1","_col2","_col3"]
                                       <-Map 1 [SIMPLE_EDGE]
                                         SHUFFLE [RS_40]
                                           PartitionCols:_col0
                                           Select Operator [SEL_30] (rows=37584000 width=15)
                                             Output:["_col0","_col1","_col2","_col3"]
-                                            Filter Operator [FIL_93] (rows=37584000 width=15)
+                                            Filter Operator [FIL_94] (rows=37584000 width=15)
                                               predicate:(inv_item_sk is not null and inv_warehouse_sk is not null and inv_date_sk is not null)
                                               TableScan [TS_0] (rows=37584000 width=15)
                                                 default@inventory,inventory,Tbl:COMPLETE,Col:NONE,Output:["inv_date_sk","inv_item_sk","inv_warehouse_sk","inv_quantity_on_hand"]
@@ -90,7 +90,7 @@ Stage-0
                                           PartitionCols:_col0
                                           Select Operator [SEL_33] (rows=18262 width=1119)
                                             Output:["_col0"]
-                                            Filter Operator [FIL_94] (rows=18262 width=1119)
+                                            Filter Operator [FIL_95] (rows=18262 width=1119)
                                               predicate:((d_year = 1999) and (d_moy = 4) and d_date_sk is not null)
                                               TableScan [TS_3] (rows=73049 width=1119)
                                                 default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
@@ -110,40 +110,40 @@ Stage-0
                             PartitionCols:_col0, _col1, _col2
                             Group By Operator [GBY_22] (rows=50024305 width=15)
                               Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["stddev_samp(_col3)","avg(_col3)"],keys:_col8, _col7, _col9
-                              Merge Join Operator [MERGEJOIN_99] (rows=50024305 width=15)
+                              Merge Join Operator [MERGEJOIN_100] (rows=50024305 width=15)
                                 Conds:RS_18._col2=RS_19._col0(Inner),Output:["_col3","_col7","_col8","_col9"]
                               <-Map 14 [SIMPLE_EDGE]
                                 SHUFFLE [RS_19]
                                   PartitionCols:_col0
                                   Select Operator [SEL_11] (rows=27 width=1029)
                                     Output:["_col0","_col1"]
-                                    Filter Operator [FIL_92] (rows=27 width=1029)
+                                    Filter Operator [FIL_93] (rows=27 width=1029)
                                       predicate:w_warehouse_sk is not null
                                        Please refer to the previous TableScan [TS_9]
                               <-Reducer 3 [SIMPLE_EDGE]
                                 SHUFFLE [RS_18]
                                   PartitionCols:_col2
-                                  Merge Join Operator [MERGEJOIN_98] (rows=45476640 width=15)
+                                  Merge Join Operator [MERGEJOIN_99] (rows=45476640 width=15)
                                     Conds:RS_15._col1=RS_16._col0(Inner),Output:["_col2","_col3","_col7"]
                                   <-Map 13 [SIMPLE_EDGE]
                                     SHUFFLE [RS_16]
                                       PartitionCols:_col0
                                       Select Operator [SEL_8] (rows=462000 width=1436)
                                         Output:["_col0"]
-                                        Filter Operator [FIL_91] (rows=462000 width=1436)
+                                        Filter Operator [FIL_92] (rows=462000 width=1436)
                                           predicate:i_item_sk is not null
                                            Please refer to the previous TableScan [TS_6]
                                   <-Reducer 2 [SIMPLE_EDGE]
                                     SHUFFLE [RS_15]
                                       PartitionCols:_col1
-                                      Merge Join Operator [MERGEJOIN_97] (rows=41342400 width=15)
+                                      Merge Join Operator [MERGEJOIN_98] (rows=41342400 width=15)
                                         Conds:RS_12._col0=RS_13._col0(Inner),Output:["_col1","_col2","_col3"]
                                       <-Map 1 [SIMPLE_EDGE]
                                         SHUFFLE [RS_12]
                                           PartitionCols:_col0
                                           Select Operator [SEL_2] (rows=37584000 width=15)
                                             Output:["_col0","_col1","_col2","_col3"]
-                                            Filter Operator [FIL_89] (rows=37584000 width=15)
+                                            Filter Operator [FIL_90] (rows=37584000 width=15)
                                               predicate:(inv_item_sk is not null and inv_warehouse_sk is not null and inv_date_sk is not null)
                                                Please refer to the previous TableScan [TS_0]
                                       <-Map 12 [SIMPLE_EDGE]
@@ -151,7 +151,7 @@ Stage-0
                                           PartitionCols:_col0
                                           Select Operator [SEL_5] (rows=18262 width=1119)
                                             Output:["_col0"]
-                                            Filter Operator [FIL_90] (rows=18262 width=1119)
+                                            Filter Operator [FIL_91] (rows=18262 width=1119)
                                               predicate:((d_year = 1999) and (d_moy = 3) and d_date_sk is not null)
                                                Please refer to the previous TableScan [TS_3]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query42.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query42.q.out b/ql/src/test/results/clientpositive/perf/query42.q.out
index 3bebac3..307ef98 100644
--- a/ql/src/test/results/clientpositive/perf/query42.q.out
+++ b/ql/src/test/results/clientpositive/perf/query42.q.out
@@ -12,18 +12,18 @@ Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 5
-      File Output Operator [FS_23]
-        Limit [LIM_22] (rows=100 width=88)
-          Number of rows:100
-          Select Operator [SEL_21] (rows=348477374 width=88)
-            Output:["_col0","_col1","_col2","_col3"]
-          <-Reducer 4 [SIMPLE_EDGE]
-            SHUFFLE [RS_20]
-              Select Operator [SEL_19] (rows=348477374 width=88)
-                Output:["_col1","_col2","_col3"]
+      File Output Operator [FS_24]
+        Select Operator [SEL_23] (rows=100 width=88)
+          Output:["_col0","_col1","_col2","_col3"]
+          Limit [LIM_22] (rows=100 width=88)
+            Number of rows:100
+            Select Operator [SEL_21] (rows=348477374 width=88)
+              Output:["_col0","_col1","_col2"]
+            <-Reducer 4 [SIMPLE_EDGE]
+              SHUFFLE [RS_20]
                 Group By Operator [GBY_18] (rows=348477374 width=88)
                   Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
                 <-Reducer 3 [SIMPLE_EDGE]
@@ -31,28 +31,28 @@ Stage-0
                     PartitionCols:_col0, _col1
                     Group By Operator [GBY_16] (rows=696954748 width=88)
                       Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col7, _col8
-                      Merge Join Operator [MERGEJOIN_33] (rows=696954748 width=88)
+                      Merge Join Operator [MERGEJOIN_34] (rows=696954748 width=88)
                         Conds:RS_12._col1=RS_13._col0(Inner),Output:["_col2","_col7","_col8"]
                       <-Map 7 [SIMPLE_EDGE]
                         SHUFFLE [RS_13]
                           PartitionCols:_col0
                           Select Operator [SEL_8] (rows=231000 width=1436)
                             Output:["_col0","_col1","_col2"]
-                            Filter Operator [FIL_31] (rows=231000 width=1436)
+                            Filter Operator [FIL_32] (rows=231000 width=1436)
                               predicate:((i_manager_id = 1) and i_item_sk is not null)
                               TableScan [TS_6] (rows=462000 width=1436)
                                 default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_category_id","i_category","i_manager_id"]
                       <-Reducer 2 [SIMPLE_EDGE]
                         SHUFFLE [RS_12]
                           PartitionCols:_col1
-                          Merge Join Operator [MERGEJOIN_32] (rows=633595212 width=88)
+                          Merge Join Operator [MERGEJOIN_33] (rows=633595212 width=88)
                             Conds:RS_9._col0=RS_10._col0(Inner),Output:["_col1","_col2"]
                           <-Map 1 [SIMPLE_EDGE]
                             SHUFFLE [RS_9]
                               PartitionCols:_col0
                               Select Operator [SEL_2] (rows=575995635 width=88)
                                 Output:["_col0","_col1","_col2"]
-                                Filter Operator [FIL_29] (rows=575995635 width=88)
+                                Filter Operator [FIL_30] (rows=575995635 width=88)
                                   predicate:(ss_sold_date_sk is not null and ss_item_sk is not null)
                                   TableScan [TS_0] (rows=575995635 width=88)
                                     default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_ext_sales_price"]
@@ -61,7 +61,7 @@ Stage-0
                               PartitionCols:_col0
                               Select Operator [SEL_5] (rows=18262 width=1119)
                                 Output:["_col0"]
-                                Filter Operator [FIL_30] (rows=18262 width=1119)
+                                Filter Operator [FIL_31] (rows=18262 width=1119)
                                   predicate:((d_moy = 12) and (d_year = 1998) and d_date_sk is not null)
                                   TableScan [TS_3] (rows=73049 width=1119)
                                     default@date_dim,dt,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query52.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query52.q.out b/ql/src/test/results/clientpositive/perf/query52.q.out
index 74ecaf2..3d4b9e5 100644
--- a/ql/src/test/results/clientpositive/perf/query52.q.out
+++ b/ql/src/test/results/clientpositive/perf/query52.q.out
@@ -12,18 +12,18 @@ Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 5
-      File Output Operator [FS_24]
-        Limit [LIM_23] (rows=100 width=88)
-          Number of rows:100
-          Select Operator [SEL_22] (rows=348477374 width=88)
-            Output:["_col0","_col1","_col2","_col3"]
-          <-Reducer 4 [SIMPLE_EDGE]
-            SHUFFLE [RS_21]
-              Select Operator [SEL_19] (rows=348477374 width=88)
-                Output:["_col1","_col2","_col3"]
+      File Output Operator [FS_25]
+        Select Operator [SEL_24] (rows=100 width=88)
+          Output:["_col0","_col1","_col2","_col3"]
+          Limit [LIM_23] (rows=100 width=88)
+            Number of rows:100
+            Select Operator [SEL_22] (rows=348477374 width=88)
+              Output:["_col0","_col1","_col2"]
+            <-Reducer 4 [SIMPLE_EDGE]
+              SHUFFLE [RS_21]
                 Group By Operator [GBY_18] (rows=348477374 width=88)
                   Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
                 <-Reducer 3 [SIMPLE_EDGE]
@@ -31,28 +31,28 @@ Stage-0
                     PartitionCols:_col0, _col1
                     Group By Operator [GBY_16] (rows=696954748 width=88)
                       Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col7, _col8
-                      Merge Join Operator [MERGEJOIN_34] (rows=696954748 width=88)
+                      Merge Join Operator [MERGEJOIN_35] (rows=696954748 width=88)
                         Conds:RS_12._col1=RS_13._col0(Inner),Output:["_col2","_col7","_col8"]
                       <-Map 7 [SIMPLE_EDGE]
                         SHUFFLE [RS_13]
                           PartitionCols:_col0
                           Select Operator [SEL_8] (rows=231000 width=1436)
                             Output:["_col0","_col1","_col2"]
-                            Filter Operator [FIL_32] (rows=231000 width=1436)
+                            Filter Operator [FIL_33] (rows=231000 width=1436)
                               predicate:((i_manager_id = 1) and i_item_sk is not null)
                               TableScan [TS_6] (rows=462000 width=1436)
                                 default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_brand_id","i_brand","i_manager_id"]
                       <-Reducer 2 [SIMPLE_EDGE]
                         SHUFFLE [RS_12]
                           PartitionCols:_col1
-                          Merge Join Operator [MERGEJOIN_33] (rows=633595212 width=88)
+                          Merge Join Operator [MERGEJOIN_34] (rows=633595212 width=88)
                             Conds:RS_9._col0=RS_10._col0(Inner),Output:["_col1","_col2"]
                           <-Map 1 [SIMPLE_EDGE]
                             SHUFFLE [RS_9]
                               PartitionCols:_col0
                               Select Operator [SEL_2] (rows=575995635 width=88)
                                 Output:["_col0","_col1","_col2"]
-                                Filter Operator [FIL_30] (rows=575995635 width=88)
+                                Filter Operator [FIL_31] (rows=575995635 width=88)
                                   predicate:(ss_sold_date_sk is not null and ss_item_sk is not null)
                                   TableScan [TS_0] (rows=575995635 width=88)
                                     default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_ext_sales_price"]
@@ -61,7 +61,7 @@ Stage-0
                               PartitionCols:_col0
                               Select Operator [SEL_5] (rows=18262 width=1119)
                                 Output:["_col0"]
-                                Filter Operator [FIL_31] (rows=18262 width=1119)
+                                Filter Operator [FIL_32] (rows=18262 width=1119)
                                   predicate:((d_moy = 12) and (d_year = 1998) and d_date_sk is not null)
                                   TableScan [TS_3] (rows=73049 width=1119)
                                     default@date_dim,dt,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]


[3/7] hive git commit: HIVE-15160: Can't order by an unselected column (Pengcheng Xiong, reviewed by Ashutosh Chauhan)

Posted by px...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query70.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query70.q.out b/ql/src/test/results/clientpositive/perf/query70.q.out
index 55c1461..d4b7731 100644
--- a/ql/src/test/results/clientpositive/perf/query70.q.out
+++ b/ql/src/test/results/clientpositive/perf/query70.q.out
@@ -88,10 +88,10 @@ Reducer 9 <- Map 14 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 7
-      File Output Operator [FS_60]
+      File Output Operator [FS_61]
         Limit [LIM_59] (rows=100 width=88)
           Number of rows:100
           Select Operator [SEL_58] (rows=1149975358 width=88)
@@ -99,7 +99,7 @@ Stage-0
           <-Reducer 6 [SIMPLE_EDGE]
             SHUFFLE [RS_57]
               Select Operator [SEL_55] (rows=1149975358 width=88)
-                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                 PTF Operator [PTF_54] (rows=1149975358 width=88)
                   Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col4 DESC NULLS LAST","partition by:":"(grouping(_col5, 1) + grouping(_col5, 0)), CASE WHEN ((grouping(_col5, 0) = 0)) THEN (_col0) ELSE (null) END"}]
                   Select Operator [SEL_53] (rows=1149975358 width=88)
@@ -118,14 +118,14 @@ Stage-0
                               Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col2)"],keys:_col0, _col1, 0
                               Select Operator [SEL_46] (rows=766650239 width=88)
                                 Output:["_col0","_col1","_col2"]
-                                Merge Join Operator [MERGEJOIN_88] (rows=766650239 width=88)
+                                Merge Join Operator [MERGEJOIN_89] (rows=766650239 width=88)
                                   Conds:RS_43._col7=RS_44._col0(Inner),Output:["_col2","_col6","_col7"]
                                 <-Reducer 11 [SIMPLE_EDGE]
                                   SHUFFLE [RS_44]
                                     PartitionCols:_col0
                                     Select Operator [SEL_32] (rows=116159124 width=88)
                                       Output:["_col0"]
-                                      Filter Operator [FIL_80] (rows=116159124 width=88)
+                                      Filter Operator [FIL_81] (rows=116159124 width=88)
                                         predicate:(rank_window_0 <= 5)
                                         PTF Operator [PTF_31] (rows=348477374 width=88)
                                           Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 DESC NULLS LAST","partition by:":"_col0"}]
@@ -141,28 +141,28 @@ Stage-0
                                                   PartitionCols:_col0
                                                   Group By Operator [GBY_25] (rows=696954748 width=88)
                                                     Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col6
-                                                    Merge Join Operator [MERGEJOIN_87] (rows=696954748 width=88)
+                                                    Merge Join Operator [MERGEJOIN_88] (rows=696954748 width=88)
                                                       Conds:RS_21._col1=RS_22._col0(Inner),Output:["_col2","_col6"]
                                                     <-Map 14 [SIMPLE_EDGE]
                                                       SHUFFLE [RS_22]
                                                         PartitionCols:_col0
                                                         Select Operator [SEL_17] (rows=1704 width=1910)
                                                           Output:["_col0","_col1"]
-                                                          Filter Operator [FIL_83] (rows=1704 width=1910)
+                                                          Filter Operator [FIL_84] (rows=1704 width=1910)
                                                             predicate:(s_store_sk is not null and s_state is not null)
                                                             TableScan [TS_15] (rows=1704 width=1910)
                                                               default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_state"]
                                                     <-Reducer 8 [SIMPLE_EDGE]
                                                       SHUFFLE [RS_21]
                                                         PartitionCols:_col1
-                                                        Merge Join Operator [MERGEJOIN_86] (rows=633595212 width=88)
+                                                        Merge Join Operator [MERGEJOIN_87] (rows=633595212 width=88)
                                                           Conds:RS_18._col0=RS_19._col0(Inner),Output:["_col1","_col2"]
                                                         <-Map 1 [SIMPLE_EDGE]
                                                           SHUFFLE [RS_18]
                                                             PartitionCols:_col0
                                                             Select Operator [SEL_11] (rows=575995635 width=88)
                                                               Output:["_col0","_col1","_col2"]
-                                                              Filter Operator [FIL_81] (rows=575995635 width=88)
+                                                              Filter Operator [FIL_82] (rows=575995635 width=88)
                                                                 predicate:(ss_store_sk is not null and ss_sold_date_sk is not null)
                                                                 TableScan [TS_0] (rows=575995635 width=88)
                                                                   default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_store_sk","ss_net_profit"]
@@ -171,35 +171,35 @@ Stage-0
                                                             PartitionCols:_col0
                                                             Select Operator [SEL_14] (rows=8116 width=1119)
                                                               Output:["_col0"]
-                                                              Filter Operator [FIL_82] (rows=8116 width=1119)
+                                                              Filter Operator [FIL_83] (rows=8116 width=1119)
                                                                 predicate:(d_month_seq BETWEEN 1212 AND 1223 and d_date_sk is not null)
                                                                 TableScan [TS_3] (rows=73049 width=1119)
                                                                   default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_month_seq"]
                                 <-Reducer 3 [SIMPLE_EDGE]
                                   SHUFFLE [RS_43]
                                     PartitionCols:_col7
-                                    Merge Join Operator [MERGEJOIN_85] (rows=696954748 width=88)
+                                    Merge Join Operator [MERGEJOIN_86] (rows=696954748 width=88)
                                       Conds:RS_40._col1=RS_41._col0(Inner),Output:["_col2","_col6","_col7"]
                                     <-Map 13 [SIMPLE_EDGE]
                                       SHUFFLE [RS_41]
                                         PartitionCols:_col0
                                         Select Operator [SEL_8] (rows=1704 width=1910)
                                           Output:["_col0","_col1","_col2"]
-                                          Filter Operator [FIL_79] (rows=1704 width=1910)
+                                          Filter Operator [FIL_80] (rows=1704 width=1910)
                                             predicate:(s_state is not null and s_store_sk is not null)
                                             TableScan [TS_6] (rows=1704 width=1910)
                                               default@store,s,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_county","s_state"]
                                     <-Reducer 2 [SIMPLE_EDGE]
                                       SHUFFLE [RS_40]
                                         PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_84] (rows=633595212 width=88)
+                                        Merge Join Operator [MERGEJOIN_85] (rows=633595212 width=88)
                                           Conds:RS_37._col0=RS_38._col0(Inner),Output:["_col1","_col2"]
                                         <-Map 1 [SIMPLE_EDGE]
                                           SHUFFLE [RS_37]
                                             PartitionCols:_col0
                                             Select Operator [SEL_2] (rows=575995635 width=88)
                                               Output:["_col0","_col1","_col2"]
-                                              Filter Operator [FIL_77] (rows=575995635 width=88)
+                                              Filter Operator [FIL_78] (rows=575995635 width=88)
                                                 predicate:(ss_sold_date_sk is not null and ss_store_sk is not null)
                                                  Please refer to the previous TableScan [TS_0]
                                         <-Map 12 [SIMPLE_EDGE]
@@ -207,7 +207,7 @@ Stage-0
                                             PartitionCols:_col0
                                             Select Operator [SEL_5] (rows=8116 width=1119)
                                               Output:["_col0"]
-                                              Filter Operator [FIL_78] (rows=8116 width=1119)
+                                              Filter Operator [FIL_79] (rows=8116 width=1119)
                                                 predicate:(d_month_seq BETWEEN 1212 AND 1223 and d_date_sk is not null)
                                                  Please refer to the previous TableScan [TS_3]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a74c1e7c/ql/src/test/results/clientpositive/perf/query75.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query75.q.out b/ql/src/test/results/clientpositive/perf/query75.q.out
index 0ecc985..55da3a2 100644
--- a/ql/src/test/results/clientpositive/perf/query75.q.out
+++ b/ql/src/test/results/clientpositive/perf/query75.q.out
@@ -30,346 +30,348 @@ Reducer 9 <- Map 1 (SIMPLE_EDGE), Map 14 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:100
+    limit:-1
     Stage-1
       Reducer 8
-      File Output Operator [FS_156]
-        Limit [LIM_155] (rows=100 width=108)
-          Number of rows:100
-          Select Operator [SEL_154] (rows=245965926 width=108)
-            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
-          <-Reducer 7 [SIMPLE_EDGE]
-            SHUFFLE [RS_153]
-              Select Operator [SEL_152] (rows=245965926 width=108)
-                Output:["_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
-                Filter Operator [FIL_151] (rows=245965926 width=108)
-                  predicate:((CAST( _col10 AS decimal(17,2)) / CAST( _col4 AS decimal(17,2))) < 0.9)
-                  Merge Join Operator [MERGEJOIN_259] (rows=737897778 width=108)
-                    Conds:RS_148._col0, _col1, _col2, _col3=RS_149._col0, _col1, _col2, _col3(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col10","_col11"]
-                  <-Reducer 13 [SIMPLE_EDGE]
-                    SHUFFLE [RS_149]
-                      PartitionCols:_col0, _col1, _col2, _col3
-                      Group By Operator [GBY_146] (rows=670816148 width=108)
-                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
-                      <-Union 12 [SIMPLE_EDGE]
-                        <-Reducer 11 [CONTAINS]
-                          Reduce Output Operator [RS_145]
-                            PartitionCols:_col0, _col1, _col2, _col3
-                            Group By Operator [GBY_144] (rows=1341632296 width=108)
-                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
-                              Select Operator [SEL_95] (rows=383314495 width=135)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                Merge Join Operator [MERGEJOIN_252] (rows=383314495 width=135)
-                                  Conds:RS_92._col1, _col2=RS_93._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
-                                <-Map 28 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_93]
-                                    PartitionCols:_col0, _col1
-                                    Select Operator [SEL_85] (rows=28798881 width=106)
-                                      Output:["_col0","_col1","_col2","_col3"]
-                                      Filter Operator [FIL_232] (rows=28798881 width=106)
-                                        predicate:cr_item_sk is not null
-                                        TableScan [TS_9] (rows=28798881 width=106)
-                                          default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_item_sk","cr_order_number","cr_return_quantity","cr_return_amount"]
-                                <-Reducer 10 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_92]
-                                    PartitionCols:_col1, _col2
-                                    Merge Join Operator [MERGEJOIN_251] (rows=348467716 width=135)
-                                      Conds:RS_89._col1=RS_90._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
-                                    <-Map 27 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_90]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_82] (rows=231000 width=1436)
-                                          Output:["_col0","_col1","_col2","_col3","_col5"]
-                                          Filter Operator [FIL_231] (rows=231000 width=1436)
-                                            predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
-                                            TableScan [TS_6] (rows=462000 width=1436)
-                                              default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_brand_id","i_class_id","i_category_id","i_category","i_manufact_id"]
-                                    <-Reducer 9 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_89]
-                                        PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_250] (rows=316788826 width=135)
-                                          Conds:RS_86._col0=RS_87._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
-                                        <-Map 14 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_87]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_79] (rows=36524 width=1119)
-                                              Output:["_col0"]
-                                              Filter Operator [FIL_230] (rows=36524 width=1119)
-                                                predicate:((d_year = 2002) and d_date_sk is not null)
-                                                TableScan [TS_3] (rows=73049 width=1119)
-                                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
-                                        <-Map 1 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_86]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_76] (rows=287989836 width=135)
-                                              Output:["_col0","_col1","_col2","_col3","_col4"]
-                                              Filter Operator [FIL_229] (rows=287989836 width=135)
-                                                predicate:(cs_item_sk is not null and cs_sold_date_sk is not null)
-                                                TableScan [TS_0] (rows=287989836 width=135)
-                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_item_sk","cs_order_number","cs_quantity","cs_ext_sales_price"]
-                        <-Reducer 23 [CONTAINS]
-                          Reduce Output Operator [RS_145]
-                            PartitionCols:_col0, _col1, _col2, _col3
-                            Group By Operator [GBY_144] (rows=1341632296 width=108)
-                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
-                              Select Operator [SEL_117] (rows=766650239 width=88)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                Merge Join Operator [MERGEJOIN_255] (rows=766650239 width=88)
-                                  Conds:RS_114._col1, _col2=RS_115._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
-                                <-Map 30 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_115]
-                                    PartitionCols:_col0, _col1
-                                    Select Operator [SEL_107] (rows=57591150 width=77)
-                                      Output:["_col0","_col1","_col2","_col3"]
-                                      Filter Operator [FIL_236] (rows=57591150 width=77)
-                                        predicate:sr_item_sk is not null
-                                        TableScan [TS_31] (rows=57591150 width=77)
-                                          default@store_returns,store_returns,Tbl:COMPLETE,Col:NONE,Output:["sr_item_sk","sr_ticket_number","sr_return_quantity","sr_return_amt"]
-                                <-Reducer 22 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_114]
-                                    PartitionCols:_col1, _col2
-                                    Merge Join Operator [MERGEJOIN_254] (rows=696954748 width=88)
-                                      Conds:RS_111._col1=RS_112._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
-                                    <-Map 27 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_112]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_104] (rows=231000 width=1436)
-                                          Output:["_col0","_col1","_col2","_col3","_col5"]
-                                          Filter Operator [FIL_235] (rows=231000 width=1436)
-                                            predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
-                                             Please refer to the previous TableScan [TS_6]
-                                    <-Reducer 21 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_111]
-                                        PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_253] (rows=633595212 width=88)
-                                          Conds:RS_108._col0=RS_109._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
-                                        <-Map 14 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_109]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_101] (rows=36524 width=1119)
-                                              Output:["_col0"]
-                                              Filter Operator [FIL_234] (rows=36524 width=1119)
-                                                predicate:((d_year = 2002) and d_date_sk is not null)
-                                                 Please refer to the previous TableScan [TS_3]
-                                        <-Map 29 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_108]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_98] (rows=575995635 width=88)
-                                              Output:["_col0","_col1","_col2","_col3","_col4"]
-                                              Filter Operator [FIL_233] (rows=575995635 width=88)
-                                                predicate:(ss_item_sk is not null and ss_sold_date_sk is not null)
-                                                TableScan [TS_22] (rows=575995635 width=88)
-                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_ticket_number","ss_quantity","ss_ext_sales_price"]
-                        <-Reducer 26 [CONTAINS]
-                          Reduce Output Operator [RS_145]
-                            PartitionCols:_col0, _col1, _col2, _col3
-                            Group By Operator [GBY_144] (rows=1341632296 width=108)
-                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
-                              Select Operator [SEL_141] (rows=191667562 width=135)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                Merge Join Operator [MERGEJOIN_258] (rows=191667562 width=135)
-                                  Conds:RS_138._col1, _col2=RS_139._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
-                                <-Map 32 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_139]
-                                    PartitionCols:_col0, _col1
-                                    Select Operator [SEL_131] (rows=14398467 width=92)
-                                      Output:["_col0","_col1","_col2","_col3"]
-                                      Filter Operator [FIL_240] (rows=14398467 width=92)
-                                        predicate:wr_item_sk is not null
-                                        TableScan [TS_55] (rows=14398467 width=92)
-                                          default@web_returns,web_returns,Tbl:COMPLETE,Col:NONE,Output:["wr_item_sk","wr_order_number","wr_return_quantity","wr_return_amt"]
-                                <-Reducer 25 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_138]
-                                    PartitionCols:_col1, _col2
-                                    Merge Join Operator [MERGEJOIN_257] (rows=174243235 width=135)
-                                      Conds:RS_135._col1=RS_136._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
-                                    <-Map 27 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_136]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_128] (rows=231000 width=1436)
-                                          Output:["_col0","_col1","_col2","_col3","_col5"]
-                                          Filter Operator [FIL_239] (rows=231000 width=1436)
-                                            predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
-                                             Please refer to the previous TableScan [TS_6]
-                                    <-Reducer 24 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_135]
-                                        PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_256] (rows=158402938 width=135)
-                                          Conds:RS_132._col0=RS_133._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
-                                        <-Map 14 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_133]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_125] (rows=36524 width=1119)
-                                              Output:["_col0"]
-                                              Filter Operator [FIL_238] (rows=36524 width=1119)
-                                                predicate:((d_year = 2002) and d_date_sk is not null)
-                                                 Please refer to the previous TableScan [TS_3]
-                                        <-Map 31 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_132]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_122] (rows=144002668 width=135)
-                                              Output:["_col0","_col1","_col2","_col3","_col4"]
-                                              Filter Operator [FIL_237] (rows=144002668 width=135)
-                                                predicate:(ws_item_sk is not null and ws_sold_date_sk is not null)
-                                                TableScan [TS_46] (rows=144002668 width=135)
-                                                  default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_item_sk","ws_order_number","ws_quantity","ws_ext_sales_price"]
-                  <-Reducer 6 [SIMPLE_EDGE]
-                    SHUFFLE [RS_148]
-                      PartitionCols:_col0, _col1, _col2, _col3
-                      Group By Operator [GBY_72] (rows=670816148 width=108)
-                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
-                      <-Union 5 [SIMPLE_EDGE]
-                        <-Reducer 17 [CONTAINS]
-                          Reduce Output Operator [RS_71]
-                            PartitionCols:_col0, _col1, _col2, _col3
-                            Group By Operator [GBY_70] (rows=1341632296 width=108)
-                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
-                              Select Operator [SEL_43] (rows=766650239 width=88)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                Merge Join Operator [MERGEJOIN_246] (rows=766650239 width=88)
-                                  Conds:RS_40._col1, _col2=RS_41._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
-                                <-Map 30 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_41]
-                                    PartitionCols:_col0, _col1
-                                    Select Operator [SEL_33] (rows=57591150 width=77)
-                                      Output:["_col0","_col1","_col2","_col3"]
-                                      Filter Operator [FIL_224] (rows=57591150 width=77)
-                                        predicate:sr_item_sk is not null
-                                         Please refer to the previous TableScan [TS_31]
-                                <-Reducer 16 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_40]
-                                    PartitionCols:_col1, _col2
-                                    Merge Join Operator [MERGEJOIN_245] (rows=696954748 width=88)
-                                      Conds:RS_37._col1=RS_38._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
-                                    <-Map 27 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_38]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_30] (rows=231000 width=1436)
-                                          Output:["_col0","_col1","_col2","_col3","_col5"]
-                                          Filter Operator [FIL_223] (rows=231000 width=1436)
-                                            predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
-                                             Please refer to the previous TableScan [TS_6]
-                                    <-Reducer 15 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_37]
-                                        PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_244] (rows=633595212 width=88)
-                                          Conds:RS_34._col0=RS_35._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
-                                        <-Map 14 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_35]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_27] (rows=36524 width=1119)
-                                              Output:["_col0"]
-                                              Filter Operator [FIL_222] (rows=36524 width=1119)
-                                                predicate:((d_year = 2001) and d_date_sk is not null)
-                                                 Please refer to the previous TableScan [TS_3]
-                                        <-Map 29 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_34]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_24] (rows=575995635 width=88)
-                                              Output:["_col0","_col1","_col2","_col3","_col4"]
-                                              Filter Operator [FIL_221] (rows=575995635 width=88)
-                                                predicate:(ss_item_sk is not null and ss_sold_date_sk is not null)
-                                                 Please refer to the previous TableScan [TS_22]
-                        <-Reducer 20 [CONTAINS]
-                          Reduce Output Operator [RS_71]
-                            PartitionCols:_col0, _col1, _col2, _col3
-                            Group By Operator [GBY_70] (rows=1341632296 width=108)
-                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
-                              Select Operator [SEL_67] (rows=191667562 width=135)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                Merge Join Operator [MERGEJOIN_249] (rows=191667562 width=135)
-                                  Conds:RS_64._col1, _col2=RS_65._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
-                                <-Map 32 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_65]
-                                    PartitionCols:_col0, _col1
-                                    Select Operator [SEL_57] (rows=14398467 width=92)
-                                      Output:["_col0","_col1","_col2","_col3"]
-                                      Filter Operator [FIL_228] (rows=14398467 width=92)
-                                        predicate:wr_item_sk is not null
-                                         Please refer to the previous TableScan [TS_55]
-                                <-Reducer 19 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_64]
-                                    PartitionCols:_col1, _col2
-                                    Merge Join Operator [MERGEJOIN_248] (rows=174243235 width=135)
-                                      Conds:RS_61._col1=RS_62._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
-                                    <-Map 27 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_62]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_54] (rows=231000 width=1436)
-                                          Output:["_col0","_col1","_col2","_col3","_col5"]
-                                          Filter Operator [FIL_227] (rows=231000 width=1436)
-                                            predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
-                                             Please refer to the previous TableScan [TS_6]
-                                    <-Reducer 18 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_61]
-                                        PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_247] (rows=158402938 width=135)
-                                          Conds:RS_58._col0=RS_59._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
-                                        <-Map 14 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_59]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_51] (rows=36524 width=1119)
-                                              Output:["_col0"]
-                                              Filter Operator [FIL_226] (rows=36524 width=1119)
-                                                predicate:((d_year = 2001) and d_date_sk is not null)
-                                                 Please refer to the previous TableScan [TS_3]
-                                        <-Map 31 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_58]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_48] (rows=144002668 width=135)
-                                              Output:["_col0","_col1","_col2","_col3","_col4"]
-                                              Filter Operator [FIL_225] (rows=144002668 width=135)
-                                                predicate:(ws_item_sk is not null and ws_sold_date_sk is not null)
-                                                 Please refer to the previous TableScan [TS_46]
-                        <-Reducer 4 [CONTAINS]
-                          Reduce Output Operator [RS_71]
-                            PartitionCols:_col0, _col1, _col2, _col3
-                            Group By Operator [GBY_70] (rows=1341632296 width=108)
-                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
-                              Select Operator [SEL_21] (rows=383314495 width=135)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                Merge Join Operator [MERGEJOIN_243] (rows=383314495 width=135)
-                                  Conds:RS_18._col1, _col2=RS_19._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
-                                <-Map 28 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_19]
-                                    PartitionCols:_col0, _col1
-                                    Select Operator [SEL_11] (rows=28798881 width=106)
-                                      Output:["_col0","_col1","_col2","_col3"]
-                                      Filter Operator [FIL_220] (rows=28798881 width=106)
-                                        predicate:cr_item_sk is not null
-                                         Please refer to the previous TableScan [TS_9]
-                                <-Reducer 3 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_18]
-                                    PartitionCols:_col1, _col2
-                                    Merge Join Operator [MERGEJOIN_242] (rows=348467716 width=135)
-                                      Conds:RS_15._col1=RS_16._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
-                                    <-Map 27 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_16]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_8] (rows=231000 width=1436)
-                                          Output:["_col0","_col1","_col2","_col3","_col5"]
-                                          Filter Operator [FIL_219] (rows=231000 width=1436)
-                                            predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
-                                             Please refer to the previous TableScan [TS_6]
-                                    <-Reducer 2 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_15]
-                                        PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_241] (rows=316788826 width=135)
-                                          Conds:RS_12._col0=RS_13._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
-                                        <-Map 14 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_13]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_5] (rows=36524 width=1119)
-                                              Output:["_col0"]
-                                              Filter Operator [FIL_218] (rows=36524 width=1119)
-                                                predicate:((d_year = 2001) and d_date_sk is not null)
-                                                 Please refer to the previous TableScan [TS_3]
-                                        <-Map 1 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_12]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_2] (rows=287989836 width=135)
-                                              Output:["_col0","_col1","_col2","_col3","_col4"]
-                                              Filter Operator [FIL_217] (rows=287989836 width=135)
-                                                predicate:(cs_item_sk is not null and cs_sold_date_sk is not null)
-                                                 Please refer to the previous TableScan [TS_0]
+      File Output Operator [FS_157]
+        Select Operator [SEL_156] (rows=100 width=108)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+          Limit [LIM_155] (rows=100 width=108)
+            Number of rows:100
+            Select Operator [SEL_154] (rows=245965926 width=108)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+            <-Reducer 7 [SIMPLE_EDGE]
+              SHUFFLE [RS_153]
+                Select Operator [SEL_152] (rows=245965926 width=108)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                  Filter Operator [FIL_151] (rows=245965926 width=108)
+                    predicate:((CAST( _col10 AS decimal(17,2)) / CAST( _col4 AS decimal(17,2))) < 0.9)
+                    Merge Join Operator [MERGEJOIN_260] (rows=737897778 width=108)
+                      Conds:RS_148._col0, _col1, _col2, _col3=RS_149._col0, _col1, _col2, _col3(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col10","_col11"]
+                    <-Reducer 13 [SIMPLE_EDGE]
+                      SHUFFLE [RS_149]
+                        PartitionCols:_col0, _col1, _col2, _col3
+                        Group By Operator [GBY_146] (rows=670816148 width=108)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
+                        <-Union 12 [SIMPLE_EDGE]
+                          <-Reducer 11 [CONTAINS]
+                            Reduce Output Operator [RS_145]
+                              PartitionCols:_col0, _col1, _col2, _col3
+                              Group By Operator [GBY_144] (rows=1341632296 width=108)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
+                                Select Operator [SEL_95] (rows=383314495 width=135)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                  Merge Join Operator [MERGEJOIN_253] (rows=383314495 width=135)
+                                    Conds:RS_92._col1, _col2=RS_93._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
+                                  <-Map 28 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_93]
+                                      PartitionCols:_col0, _col1
+                                      Select Operator [SEL_85] (rows=28798881 width=106)
+                                        Output:["_col0","_col1","_col2","_col3"]
+                                        Filter Operator [FIL_233] (rows=28798881 width=106)
+                                          predicate:cr_item_sk is not null
+                                          TableScan [TS_9] (rows=28798881 width=106)
+                                            default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_item_sk","cr_order_number","cr_return_quantity","cr_return_amount"]
+                                  <-Reducer 10 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_92]
+                                      PartitionCols:_col1, _col2
+                                      Merge Join Operator [MERGEJOIN_252] (rows=348467716 width=135)
+                                        Conds:RS_89._col1=RS_90._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
+                                      <-Map 27 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_90]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_82] (rows=231000 width=1436)
+                                            Output:["_col0","_col1","_col2","_col3","_col5"]
+                                            Filter Operator [FIL_232] (rows=231000 width=1436)
+                                              predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
+                                              TableScan [TS_6] (rows=462000 width=1436)
+                                                default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_brand_id","i_class_id","i_category_id","i_category","i_manufact_id"]
+                                      <-Reducer 9 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_89]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_251] (rows=316788826 width=135)
+                                            Conds:RS_86._col0=RS_87._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                          <-Map 14 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_87]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_79] (rows=36524 width=1119)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_231] (rows=36524 width=1119)
+                                                  predicate:((d_year = 2002) and d_date_sk is not null)
+                                                  TableScan [TS_3] (rows=73049 width=1119)
+                                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
+                                          <-Map 1 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_86]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_76] (rows=287989836 width=135)
+                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                Filter Operator [FIL_230] (rows=287989836 width=135)
+                                                  predicate:(cs_item_sk is not null and cs_sold_date_sk is not null)
+                                                  TableScan [TS_0] (rows=287989836 width=135)
+                                                    default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_item_sk","cs_order_number","cs_quantity","cs_ext_sales_price"]
+                          <-Reducer 23 [CONTAINS]
+                            Reduce Output Operator [RS_145]
+                              PartitionCols:_col0, _col1, _col2, _col3
+                              Group By Operator [GBY_144] (rows=1341632296 width=108)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
+                                Select Operator [SEL_117] (rows=766650239 width=88)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                  Merge Join Operator [MERGEJOIN_256] (rows=766650239 width=88)
+                                    Conds:RS_114._col1, _col2=RS_115._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
+                                  <-Map 30 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_115]
+                                      PartitionCols:_col0, _col1
+                                      Select Operator [SEL_107] (rows=57591150 width=77)
+                                        Output:["_col0","_col1","_col2","_col3"]
+                                        Filter Operator [FIL_237] (rows=57591150 width=77)
+                                          predicate:sr_item_sk is not null
+                                          TableScan [TS_31] (rows=57591150 width=77)
+                                            default@store_returns,store_returns,Tbl:COMPLETE,Col:NONE,Output:["sr_item_sk","sr_ticket_number","sr_return_quantity","sr_return_amt"]
+                                  <-Reducer 22 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_114]
+                                      PartitionCols:_col1, _col2
+                                      Merge Join Operator [MERGEJOIN_255] (rows=696954748 width=88)
+                                        Conds:RS_111._col1=RS_112._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
+                                      <-Map 27 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_112]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_104] (rows=231000 width=1436)
+                                            Output:["_col0","_col1","_col2","_col3","_col5"]
+                                            Filter Operator [FIL_236] (rows=231000 width=1436)
+                                              predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
+                                               Please refer to the previous TableScan [TS_6]
+                                      <-Reducer 21 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_111]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_254] (rows=633595212 width=88)
+                                            Conds:RS_108._col0=RS_109._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                          <-Map 14 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_109]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_101] (rows=36524 width=1119)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_235] (rows=36524 width=1119)
+                                                  predicate:((d_year = 2002) and d_date_sk is not null)
+                                                   Please refer to the previous TableScan [TS_3]
+                                          <-Map 29 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_108]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_98] (rows=575995635 width=88)
+                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                Filter Operator [FIL_234] (rows=575995635 width=88)
+                                                  predicate:(ss_item_sk is not null and ss_sold_date_sk is not null)
+                                                  TableScan [TS_22] (rows=575995635 width=88)
+                                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_ticket_number","ss_quantity","ss_ext_sales_price"]
+                          <-Reducer 26 [CONTAINS]
+                            Reduce Output Operator [RS_145]
+                              PartitionCols:_col0, _col1, _col2, _col3
+                              Group By Operator [GBY_144] (rows=1341632296 width=108)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
+                                Select Operator [SEL_141] (rows=191667562 width=135)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                  Merge Join Operator [MERGEJOIN_259] (rows=191667562 width=135)
+                                    Conds:RS_138._col1, _col2=RS_139._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
+                                  <-Map 32 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_139]
+                                      PartitionCols:_col0, _col1
+                                      Select Operator [SEL_131] (rows=14398467 width=92)
+                                        Output:["_col0","_col1","_col2","_col3"]
+                                        Filter Operator [FIL_241] (rows=14398467 width=92)
+                                          predicate:wr_item_sk is not null
+                                          TableScan [TS_55] (rows=14398467 width=92)
+                                            default@web_returns,web_returns,Tbl:COMPLETE,Col:NONE,Output:["wr_item_sk","wr_order_number","wr_return_quantity","wr_return_amt"]
+                                  <-Reducer 25 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_138]
+                                      PartitionCols:_col1, _col2
+                                      Merge Join Operator [MERGEJOIN_258] (rows=174243235 width=135)
+                                        Conds:RS_135._col1=RS_136._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
+                                      <-Map 27 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_136]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_128] (rows=231000 width=1436)
+                                            Output:["_col0","_col1","_col2","_col3","_col5"]
+                                            Filter Operator [FIL_240] (rows=231000 width=1436)
+                                              predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
+                                               Please refer to the previous TableScan [TS_6]
+                                      <-Reducer 24 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_135]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_257] (rows=158402938 width=135)
+                                            Conds:RS_132._col0=RS_133._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                          <-Map 14 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_133]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_125] (rows=36524 width=1119)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_239] (rows=36524 width=1119)
+                                                  predicate:((d_year = 2002) and d_date_sk is not null)
+                                                   Please refer to the previous TableScan [TS_3]
+                                          <-Map 31 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_132]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_122] (rows=144002668 width=135)
+                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                Filter Operator [FIL_238] (rows=144002668 width=135)
+                                                  predicate:(ws_item_sk is not null and ws_sold_date_sk is not null)
+                                                  TableScan [TS_46] (rows=144002668 width=135)
+                                                    default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_item_sk","ws_order_number","ws_quantity","ws_ext_sales_price"]
+                    <-Reducer 6 [SIMPLE_EDGE]
+                      SHUFFLE [RS_148]
+                        PartitionCols:_col0, _col1, _col2, _col3
+                        Group By Operator [GBY_72] (rows=670816148 width=108)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
+                        <-Union 5 [SIMPLE_EDGE]
+                          <-Reducer 17 [CONTAINS]
+                            Reduce Output Operator [RS_71]
+                              PartitionCols:_col0, _col1, _col2, _col3
+                              Group By Operator [GBY_70] (rows=1341632296 width=108)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
+                                Select Operator [SEL_43] (rows=766650239 width=88)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                  Merge Join Operator [MERGEJOIN_247] (rows=766650239 width=88)
+                                    Conds:RS_40._col1, _col2=RS_41._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
+                                  <-Map 30 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_41]
+                                      PartitionCols:_col0, _col1
+                                      Select Operator [SEL_33] (rows=57591150 width=77)
+                                        Output:["_col0","_col1","_col2","_col3"]
+                                        Filter Operator [FIL_225] (rows=57591150 width=77)
+                                          predicate:sr_item_sk is not null
+                                           Please refer to the previous TableScan [TS_31]
+                                  <-Reducer 16 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_40]
+                                      PartitionCols:_col1, _col2
+                                      Merge Join Operator [MERGEJOIN_246] (rows=696954748 width=88)
+                                        Conds:RS_37._col1=RS_38._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
+                                      <-Map 27 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_38]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_30] (rows=231000 width=1436)
+                                            Output:["_col0","_col1","_col2","_col3","_col5"]
+                                            Filter Operator [FIL_224] (rows=231000 width=1436)
+                                              predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
+                                               Please refer to the previous TableScan [TS_6]
+                                      <-Reducer 15 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_37]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_245] (rows=633595212 width=88)
+                                            Conds:RS_34._col0=RS_35._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                          <-Map 14 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_35]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_27] (rows=36524 width=1119)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_223] (rows=36524 width=1119)
+                                                  predicate:((d_year = 2001) and d_date_sk is not null)
+                                                   Please refer to the previous TableScan [TS_3]
+                                          <-Map 29 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_34]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_24] (rows=575995635 width=88)
+                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                Filter Operator [FIL_222] (rows=575995635 width=88)
+                                                  predicate:(ss_item_sk is not null and ss_sold_date_sk is not null)
+                                                   Please refer to the previous TableScan [TS_22]
+                          <-Reducer 20 [CONTAINS]
+                            Reduce Output Operator [RS_71]
+                              PartitionCols:_col0, _col1, _col2, _col3
+                              Group By Operator [GBY_70] (rows=1341632296 width=108)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
+                                Select Operator [SEL_67] (rows=191667562 width=135)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                  Merge Join Operator [MERGEJOIN_250] (rows=191667562 width=135)
+                                    Conds:RS_64._col1, _col2=RS_65._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
+                                  <-Map 32 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_65]
+                                      PartitionCols:_col0, _col1
+                                      Select Operator [SEL_57] (rows=14398467 width=92)
+                                        Output:["_col0","_col1","_col2","_col3"]
+                                        Filter Operator [FIL_229] (rows=14398467 width=92)
+                                          predicate:wr_item_sk is not null
+                                           Please refer to the previous TableScan [TS_55]
+                                  <-Reducer 19 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_64]
+                                      PartitionCols:_col1, _col2
+                                      Merge Join Operator [MERGEJOIN_249] (rows=174243235 width=135)
+                                        Conds:RS_61._col1=RS_62._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
+                                      <-Map 27 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_62]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_54] (rows=231000 width=1436)
+                                            Output:["_col0","_col1","_col2","_col3","_col5"]
+                                            Filter Operator [FIL_228] (rows=231000 width=1436)
+                                              predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
+                                               Please refer to the previous TableScan [TS_6]
+                                      <-Reducer 18 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_61]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_248] (rows=158402938 width=135)
+                                            Conds:RS_58._col0=RS_59._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                          <-Map 14 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_59]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_51] (rows=36524 width=1119)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_227] (rows=36524 width=1119)
+                                                  predicate:((d_year = 2001) and d_date_sk is not null)
+                                                   Please refer to the previous TableScan [TS_3]
+                                          <-Map 31 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_58]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_48] (rows=144002668 width=135)
+                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                Filter Operator [FIL_226] (rows=144002668 width=135)
+                                                  predicate:(ws_item_sk is not null and ws_sold_date_sk is not null)
+                                                   Please refer to the previous TableScan [TS_46]
+                          <-Reducer 4 [CONTAINS]
+                            Reduce Output Operator [RS_71]
+                              PartitionCols:_col0, _col1, _col2, _col3
+                              Group By Operator [GBY_70] (rows=1341632296 width=108)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
+                                Select Operator [SEL_21] (rows=383314495 width=135)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                  Merge Join Operator [MERGEJOIN_244] (rows=383314495 width=135)
+                                    Conds:RS_18._col1, _col2=RS_19._col0, _col1(Left Outer),Output:["_col3","_col4","_col8","_col9","_col10","_col12","_col15","_col16"]
+                                  <-Map 28 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_19]
+                                      PartitionCols:_col0, _col1
+                                      Select Operator [SEL_11] (rows=28798881 width=106)
+                                        Output:["_col0","_col1","_col2","_col3"]
+                                        Filter Operator [FIL_221] (rows=28798881 width=106)
+                                          predicate:cr_item_sk is not null
+                                           Please refer to the previous TableScan [TS_9]
+                                  <-Reducer 3 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_18]
+                                      PartitionCols:_col1, _col2
+                                      Merge Join Operator [MERGEJOIN_243] (rows=348467716 width=135)
+                                        Conds:RS_15._col1=RS_16._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col8","_col9","_col10","_col12"]
+                                      <-Map 27 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_16]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_8] (rows=231000 width=1436)
+                                            Output:["_col0","_col1","_col2","_col3","_col5"]
+                                            Filter Operator [FIL_220] (rows=231000 width=1436)
+                                              predicate:((i_category = 'Sports') and i_item_sk is not null and i_brand_id is not null and i_class_id is not null and i_category_id is not null and i_manufact_id is not null)
+                                               Please refer to the previous TableScan [TS_6]
+                                      <-Reducer 2 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_15]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_242] (rows=316788826 width=135)
+                                            Conds:RS_12._col0=RS_13._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                          <-Map 14 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_13]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_5] (rows=36524 width=1119)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_219] (rows=36524 width=1119)
+                                                  predicate:((d_year = 2001) and d_date_sk is not null)
+                                                   Please refer to the previous TableScan [TS_3]
+                                          <-Map 1 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_12]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_2] (rows=287989836 width=135)
+                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                Filter Operator [FIL_218] (rows=287989836 width=135)
+                                                  predicate:(cs_item_sk is not null and cs_sold_date_sk is not null)
+                                                   Please refer to the previous TableScan [TS_0]