You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2019/10/28 16:04:18 UTC

[hive] branch master updated: HIVE-22321: Setting default nulls last does not take effect when order direction is specified (Krisztian Kasa reviewed by Jesus Camacho Rodriguez)

This is an automated email from the ASF dual-hosted git repository.

jcamacho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new aceb8b6  HIVE-22321: Setting default nulls last does not take effect when order direction is specified (Krisztian Kasa reviewed by Jesus Camacho Rodriguez)
aceb8b6 is described below

commit aceb8b6002728d2c2b52dda4ecf8cf701a095e70
Author: Krisztian Kasa <kk...@cloudera.com>
AuthorDate: Mon Oct 28 09:03:49 2019 -0700

    HIVE-22321: Setting default nulls last does not take effect when order direction is specified (Krisztian Kasa reviewed by Jesus Camacho Rodriguez)
---
 .../org/apache/hadoop/hive/ql/parse/HiveParser.g   | 29 ++++++++++++++-------
 .../results/clientpositive/llap/order_null.q.out   | 10 ++++----
 .../results/clientpositive/llap/sample10.q.out     |  2 +-
 .../clientpositive/llap/vector_char_2.q.out        |  2 +-
 .../clientpositive/llap/vector_order_null.q.out    | 30 +++++++++++-----------
 .../llap/vector_windowing_gby2.q.out               |  6 ++---
 .../clientpositive/perf/spark/query36.q.out        |  2 +-
 .../clientpositive/perf/spark/query44.q.out        |  2 +-
 .../clientpositive/perf/tez/cbo_query36.q.out      |  2 +-
 .../perf/tez/constraints/cbo_query36.q.out         |  2 +-
 .../perf/tez/constraints/mv_query44.q.out          |  2 +-
 .../perf/tez/constraints/query36.q.out             |  2 +-
 .../perf/tez/constraints/query44.q.out             |  2 +-
 .../results/clientpositive/perf/tez/query36.q.out  |  2 +-
 .../results/clientpositive/perf/tez/query44.q.out  |  2 +-
 .../results/clientpositive/spark/sample10.q.out    |  2 +-
 .../results/clientpositive/vector_char_2.q.out     |  2 +-
 .../results/clientpositive/windowing_gby2.q.out    |  4 +--
 18 files changed, 58 insertions(+), 47 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
index bb23a4e..6ce5f8e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
@@ -2496,23 +2496,34 @@ columnNameComment
     -> ^(TOK_TABCOL $colName TOK_NULL $comment?)
     ;
 
+orderSpecificationRewrite
+@init { pushMsg("order specification", state); }
+@after { popMsg(state); }
+    : KW_ASC -> ^(TOK_TABSORTCOLNAMEASC)
+    | KW_DESC -> ^(TOK_TABSORTCOLNAMEDESC)
+    ;
+
 columnRefOrder
 @init { pushMsg("column order", state); }
 @after { popMsg(state); }
-    : expression orderSpec=orderSpecification? nullSpec=nullOrdering?
+    : expression orderSpec=orderSpecificationRewrite? nullSpec=nullOrdering?
+    // ORDER not present, NULLS ORDER not present and default is NULLS LAST ex.: ORDER BY col0
     -> {$orderSpec.tree == null && $nullSpec.tree == null && nullsLast()}?
             ^(TOK_TABSORTCOLNAMEASC ^(TOK_NULLS_LAST expression))
-    -> {$orderSpec.tree == null && $nullSpec.tree == null && !nullsLast()}?
+    // ORDER not present, NULLS ORDER not present and default is NULLS FIRST ex.: ORDER BY col0
+    -> {$orderSpec.tree == null && $nullSpec.tree == null}?
             ^(TOK_TABSORTCOLNAMEASC ^(TOK_NULLS_FIRST expression))
+    // ORDER not present but NULLS ORDER present ex.: ORDER BY col0 NULLS FIRST
     -> {$orderSpec.tree == null}?
             ^(TOK_TABSORTCOLNAMEASC ^($nullSpec expression))
-    -> {$nullSpec.tree == null && $orderSpec.tree.getType()==HiveParser.KW_ASC}?
-            ^(TOK_TABSORTCOLNAMEASC ^(TOK_NULLS_FIRST expression))
-    -> {$nullSpec.tree == null && $orderSpec.tree.getType()==HiveParser.KW_DESC}?
-            ^(TOK_TABSORTCOLNAMEDESC ^(TOK_NULLS_LAST expression))
-    -> {$orderSpec.tree.getType()==HiveParser.KW_ASC}?
-            ^(TOK_TABSORTCOLNAMEASC ^($nullSpec expression))
-    -> ^(TOK_TABSORTCOLNAMEDESC ^($nullSpec expression))
+    // ORDER present but NULLS ORDER not present and default is NULLS LAST ex.: ORDER BY col0 ASC
+    -> {$nullSpec.tree == null && nullsLast()}?
+            ^($orderSpec ^(TOK_NULLS_LAST expression))
+    // ORDER present, NULLS ORDER not present and default is NULLS FIRST ex.: ORDER BY col0 ASC
+    -> {$nullSpec.tree == null}?
+            ^($orderSpec ^(TOK_NULLS_FIRST expression))
+    // both ORDER and NULLS ORDER present ex.: ORDER BY col0 ASC NULLS LAST
+    -> ^($orderSpec ^($nullSpec expression))
     ;
 
 columnNameType
diff --git a/ql/src/test/results/clientpositive/llap/order_null.q.out b/ql/src/test/results/clientpositive/llap/order_null.q.out
index c380844..1dac6e4 100644
--- a/ql/src/test/results/clientpositive/llap/order_null.q.out
+++ b/ql/src/test/results/clientpositive/llap/order_null.q.out
@@ -74,12 +74,12 @@ POSTHOOK: query: SELECT x.* FROM src_null_n1 x ORDER BY a asc
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src_null_n1
 #### A masked pattern was here ####
-NULL	NULL
 1	A
 2	NULL
 2	A
 2	B
 3	NULL
+NULL	NULL
 PREHOOK: query: SELECT x.* FROM src_null_n1 x ORDER BY a desc
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src_null_n1
@@ -102,12 +102,12 @@ POSTHOOK: query: SELECT x.* FROM src_null_n1 x ORDER BY b asc, a asc nulls last
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src_null_n1
 #### A masked pattern was here ####
-2	NULL
-3	NULL
-NULL	NULL
 1	A
 2	A
 2	B
+2	NULL
+3	NULL
+NULL	NULL
 PREHOOK: query: SELECT x.* FROM src_null_n1 x ORDER BY b desc, a asc
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src_null_n1
@@ -119,9 +119,9 @@ POSTHOOK: Input: default@src_null_n1
 2	B
 1	A
 2	A
-NULL	NULL
 2	NULL
 3	NULL
+NULL	NULL
 PREHOOK: query: SELECT x.* FROM src_null_n1 x ORDER BY a asc nulls first
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src_null_n1
diff --git a/ql/src/test/results/clientpositive/llap/sample10.q.out b/ql/src/test/results/clientpositive/llap/sample10.q.out
index 20c38ac..240b42b 100644
--- a/ql/src/test/results/clientpositive/llap/sample10.q.out
+++ b/ql/src/test/results/clientpositive/llap/sample10.q.out
@@ -322,7 +322,7 @@ STAGE PLANS:
                 Statistics: Num rows: 2 Data size: 384 Basic stats: COMPLETE Column stats: COMPLETE
                 Reduce Output Operator
                   key expressions: _col0 (type: string)
-                  null sort order: a
+                  null sort order: z
                   sort order: +
                   Statistics: Num rows: 2 Data size: 384 Basic stats: COMPLETE Column stats: COMPLETE
                   tag: -1
diff --git a/ql/src/test/results/clientpositive/llap/vector_char_2.q.out b/ql/src/test/results/clientpositive/llap/vector_char_2.q.out
index 80ba95d..6228aac 100644
--- a/ql/src/test/results/clientpositive/llap/vector_char_2.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_char_2.q.out
@@ -241,11 +241,11 @@ limit 5
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@char_2_n0
 #### A masked pattern was here ####
-NULL	NULL	1
 val_0               	0	3
 val_10              	10	1
 val_100             	200	2
 val_103             	206	2
+val_104             	208	2
 PREHOOK: query: select value, sum(cast(key as int)), count(*) numrows
 from src
 group by value
diff --git a/ql/src/test/results/clientpositive/llap/vector_order_null.q.out b/ql/src/test/results/clientpositive/llap/vector_order_null.q.out
index 1379c39..8c9c210 100644
--- a/ql/src/test/results/clientpositive/llap/vector_order_null.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_order_null.q.out
@@ -146,7 +146,7 @@ STAGE PLANS:
             Reduce Vectorization:
                 enabled: true
                 enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                reduceColumnNullOrder: aa
+                reduceColumnNullOrder: zz
                 reduceColumnSortOrder: ++
                 allNative: false
                 usesVectorUDFAdaptor: false
@@ -191,12 +191,12 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src_null_n3
 #### A masked pattern was here ####
 x.a	x.b
-NULL	NULL
 1	A
-2	NULL
 2	A
 2	B
+2	NULL
 3	NULL
+NULL	NULL
 PREHOOK: query: EXPLAIN VECTORIZATION DETAIL
 SELECT x.* FROM src_null_n3 x ORDER BY a desc, b asc
 PREHOOK: type: QUERY
@@ -271,7 +271,7 @@ STAGE PLANS:
             Reduce Vectorization:
                 enabled: true
                 enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                reduceColumnNullOrder: za
+                reduceColumnNullOrder: zz
                 reduceColumnSortOrder: -+
                 allNative: false
                 usesVectorUDFAdaptor: false
@@ -317,9 +317,9 @@ POSTHOOK: Input: default@src_null_n3
 #### A masked pattern was here ####
 x.a	x.b
 3	NULL
-2	NULL
 2	A
 2	B
+2	NULL
 1	A
 NULL	NULL
 PREHOOK: query: EXPLAIN VECTORIZATION DETAIL
@@ -396,7 +396,7 @@ STAGE PLANS:
             Reduce Vectorization:
                 enabled: true
                 enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                reduceColumnNullOrder: az
+                reduceColumnNullOrder: zz
                 reduceColumnSortOrder: ++
                 allNative: false
                 usesVectorUDFAdaptor: false
@@ -441,12 +441,12 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src_null_n3
 #### A masked pattern was here ####
 x.a	x.b
-2	NULL
-3	NULL
-NULL	NULL
 1	A
 2	A
 2	B
+2	NULL
+3	NULL
+NULL	NULL
 PREHOOK: query: EXPLAIN VECTORIZATION DETAIL
 SELECT x.* FROM src_null_n3 x ORDER BY b desc, a asc
 PREHOOK: type: QUERY
@@ -521,7 +521,7 @@ STAGE PLANS:
             Reduce Vectorization:
                 enabled: true
                 enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                reduceColumnNullOrder: za
+                reduceColumnNullOrder: zz
                 reduceColumnSortOrder: -+
                 allNative: false
                 usesVectorUDFAdaptor: false
@@ -569,9 +569,9 @@ x.a	x.b
 2	B
 1	A
 2	A
-NULL	NULL
 2	NULL
 3	NULL
+NULL	NULL
 PREHOOK: query: EXPLAIN VECTORIZATION DETAIL
 SELECT x.* FROM src_null_n3 x ORDER BY a asc nulls first, b asc
 PREHOOK: type: QUERY
@@ -646,7 +646,7 @@ STAGE PLANS:
             Reduce Vectorization:
                 enabled: true
                 enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                reduceColumnNullOrder: aa
+                reduceColumnNullOrder: az
                 reduceColumnSortOrder: ++
                 allNative: false
                 usesVectorUDFAdaptor: false
@@ -693,9 +693,9 @@ POSTHOOK: Input: default@src_null_n3
 x.a	x.b
 NULL	NULL
 1	A
-2	NULL
 2	A
 2	B
+2	NULL
 3	NULL
 PREHOOK: query: EXPLAIN VECTORIZATION DETAIL
 SELECT x.* FROM src_null_n3 x ORDER BY a desc nulls first, b asc
@@ -771,7 +771,7 @@ STAGE PLANS:
             Reduce Vectorization:
                 enabled: true
                 enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                reduceColumnNullOrder: aa
+                reduceColumnNullOrder: az
                 reduceColumnSortOrder: -+
                 allNative: false
                 usesVectorUDFAdaptor: false
@@ -818,9 +818,9 @@ POSTHOOK: Input: default@src_null_n3
 x.a	x.b
 NULL	NULL
 3	NULL
-2	NULL
 2	A
 2	B
+2	NULL
 1	A
 PREHOOK: query: EXPLAIN VECTORIZATION DETAIL
 SELECT x.* FROM src_null_n3 x ORDER BY b asc nulls last, a
diff --git a/ql/src/test/results/clientpositive/llap/vector_windowing_gby2.q.out b/ql/src/test/results/clientpositive/llap/vector_windowing_gby2.q.out
index 769e8ab..7c30f4f 100644
--- a/ql/src/test/results/clientpositive/llap/vector_windowing_gby2.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_windowing_gby2.q.out
@@ -705,7 +705,7 @@ STAGE PLANS:
             Reduce Vectorization:
                 enabled: true
                 enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
-                reduceColumnNullOrder: aa
+                reduceColumnNullOrder: az
                 reduceColumnSortOrder: ++
                 allNative: true
                 usesVectorUDFAdaptor: false
@@ -733,7 +733,7 @@ STAGE PLANS:
                       Windowing table definition
                         input alias: ptf_1
                         name: windowingtablefunction
-                        order by: _col4 ASC NULLS FIRST
+                        order by: _col4 ASC NULLS LAST
                         partition by: lower(_col2)
                         raw input shape:
                         window functions:
@@ -800,7 +800,7 @@ STAGE PLANS:
                       Windowing table definition
                         input alias: ptf_1
                         name: windowingtablefunction
-                        order by: _col7 ASC NULLS FIRST
+                        order by: _col7 ASC NULLS LAST
                         partition by: _col6
                         raw input shape:
                         window functions:
diff --git a/ql/src/test/results/clientpositive/perf/spark/query36.q.out b/ql/src/test/results/clientpositive/perf/spark/query36.q.out
index cde0e93..1e65e79 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query36.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query36.q.out
@@ -256,7 +256,7 @@ STAGE PLANS:
                       Windowing table definition
                         input alias: ptf_1
                         name: windowingtablefunction
-                        order by: (_col2 / _col3) ASC NULLS FIRST
+                        order by: (_col2 / _col3) ASC NULLS LAST
                         partition by: (grouping(_col4, 1L) + grouping(_col4, 0L)), CASE WHEN ((grouping(_col4, 0L) = UDFToLong(0))) THEN (_col0) ELSE (CAST( null AS STRING)) END
                         raw input shape:
                         window functions:
diff --git a/ql/src/test/results/clientpositive/perf/spark/query44.q.out b/ql/src/test/results/clientpositive/perf/spark/query44.q.out
index c7c7965..38d9f77 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query44.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query44.q.out
@@ -440,7 +440,7 @@ STAGE PLANS:
                       Windowing table definition
                         input alias: ptf_1
                         name: windowingtablefunction
-                        order by: _col1 ASC NULLS FIRST
+                        order by: _col1 ASC NULLS LAST
                         partition by: 0
                         raw input shape:
                         window functions:
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out
index f0204dd..c2a11d5 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out
@@ -69,7 +69,7 @@ POSTHOOK: Output: hdfs://### HDFS PATH ###
 CBO PLAN:
 HiveProject(gross_margin=[$0], i_category=[$1], i_class=[$2], lochierarchy=[$3], rank_within_parent=[$4])
   HiveSortLimit(sort0=[$3], sort1=[$5], sort2=[$4], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], fetch=[100])
-    HiveProject(gross_margin=[/($2, $3)], i_category=[$0], i_class=[$1], lochierarchy=[+(grouping($4, 1:BIGINT), grouping($4, 0:BIGINT))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($4, 1:BIGINT), grouping($4, 0:BIGINT)), CASE(=(grouping($4, 0:BIGINT), CAST(0):BIGINT), $0, null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE") ORDER BY /($2, $3) NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (to [...]
+    HiveProject(gross_margin=[/($2, $3)], i_category=[$0], i_class=[$1], lochierarchy=[+(grouping($4, 1:BIGINT), grouping($4, 0:BIGINT))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($4, 1:BIGINT), grouping($4, 0:BIGINT)), CASE(=(grouping($4, 0:BIGINT), CAST(0):BIGINT), $0, null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE") ORDER BY /($2, $3) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (tok [...]
       HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], GROUPING__ID=[$4])
         HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], GROUPING__ID=[GROUPING__ID()])
           HiveProject($f0=[$9], $f1=[$8], $f2=[$4], $f3=[$3])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query36.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query36.q.out
index 7832458..9c70e60 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query36.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query36.q.out
@@ -69,7 +69,7 @@ POSTHOOK: Output: hdfs://### HDFS PATH ###
 CBO PLAN:
 HiveProject(gross_margin=[$0], i_category=[$1], i_class=[$2], lochierarchy=[$3], rank_within_parent=[$4])
   HiveSortLimit(sort0=[$3], sort1=[$5], sort2=[$4], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], fetch=[100])
-    HiveProject(gross_margin=[/($2, $3)], i_category=[$0], i_class=[$1], lochierarchy=[+(grouping($4, 1:BIGINT), grouping($4, 0:BIGINT))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($4, 1:BIGINT), grouping($4, 0:BIGINT)), CASE(=(grouping($4, 0:BIGINT), CAST(0):BIGINT), $0, null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE") ORDER BY /($2, $3) NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (to [...]
+    HiveProject(gross_margin=[/($2, $3)], i_category=[$0], i_class=[$1], lochierarchy=[+(grouping($4, 1:BIGINT), grouping($4, 0:BIGINT))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($4, 1:BIGINT), grouping($4, 0:BIGINT)), CASE(=(grouping($4, 0:BIGINT), CAST(0):BIGINT), $0, null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE") ORDER BY /($2, $3) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (tok [...]
       HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], GROUPING__ID=[$4])
         HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], GROUPING__ID=[GROUPING__ID()])
           HiveProject($f0=[$9], $f1=[$8], $f2=[$4], $f3=[$3])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/mv_query44.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/mv_query44.q.out
index f56f988..61c01c5 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/mv_query44.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/mv_query44.q.out
@@ -242,7 +242,7 @@ Stage-0
                               Filter Operator [FIL_191] (rows=6951 width=116)
                                 predicate:(rank_window_0 < 11)
                                 PTF Operator [PTF_190] (rows=20854 width=116)
-                                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS FIRST","partition by:":"0"}]
+                                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS LAST","partition by:":"0"}]
                                   Select Operator [SEL_189] (rows=20854 width=116)
                                     Output:["_col2","_col3"]
                                   <-Reducer 5 [SIMPLE_EDGE]
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query36.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query36.q.out
index 40b2716..bf2b52f 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query36.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query36.q.out
@@ -93,7 +93,7 @@ Stage-0
               Select Operator [SEL_103] (rows=3060 width=490)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                 PTF Operator [PTF_102] (rows=3060 width=414)
-                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(_col2 / _col3) ASC NULLS FIRST","partition by:":"(grouping(_col4, 1L) + grouping(_col4, 0L)), CASE WHEN ((grouping(_col4, 0L) = UDFToLong(0))) THEN (_col0) ELSE (CAST( null AS STRING)) END"}]
+                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(_col2 / _col3) ASC NULLS LAST","partition by:":"(grouping(_col4, 1L) + grouping(_col4, 0L)), CASE WHEN ((grouping(_col4, 0L) = UDFToLong(0))) THEN (_col0) ELSE (CAST( null AS STRING)) END"}]
                   Select Operator [SEL_101] (rows=3060 width=414)
                     Output:["_col0","_col1","_col2","_col3","_col4"]
                   <-Reducer 5 [SIMPLE_EDGE] vectorized
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query44.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query44.q.out
index 80a9cdc..a243417 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query44.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query44.q.out
@@ -221,7 +221,7 @@ Stage-0
                               Filter Operator [FIL_191] (rows=6951 width=116)
                                 predicate:(rank_window_0 < 11)
                                 PTF Operator [PTF_190] (rows=20854 width=116)
-                                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS FIRST","partition by:":"0"}]
+                                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS LAST","partition by:":"0"}]
                                   Select Operator [SEL_189] (rows=20854 width=116)
                                     Output:["_col2","_col3"]
                                   <-Reducer 5 [SIMPLE_EDGE]
diff --git a/ql/src/test/results/clientpositive/perf/tez/query36.q.out b/ql/src/test/results/clientpositive/perf/tez/query36.q.out
index 7e1b4d0..8131c0b 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query36.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query36.q.out
@@ -93,7 +93,7 @@ Stage-0
               Select Operator [SEL_105] (rows=3060 width=490)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                 PTF Operator [PTF_104] (rows=3060 width=414)
-                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(_col2 / _col3) ASC NULLS FIRST","partition by:":"(grouping(_col4, 1L) + grouping(_col4, 0L)), CASE WHEN ((grouping(_col4, 0L) = UDFToLong(0))) THEN (_col0) ELSE (CAST( null AS STRING)) END"}]
+                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(_col2 / _col3) ASC NULLS LAST","partition by:":"(grouping(_col4, 1L) + grouping(_col4, 0L)), CASE WHEN ((grouping(_col4, 0L) = UDFToLong(0))) THEN (_col0) ELSE (CAST( null AS STRING)) END"}]
                   Select Operator [SEL_103] (rows=3060 width=414)
                     Output:["_col0","_col1","_col2","_col3","_col4"]
                   <-Reducer 5 [SIMPLE_EDGE] vectorized
diff --git a/ql/src/test/results/clientpositive/perf/tez/query44.q.out b/ql/src/test/results/clientpositive/perf/tez/query44.q.out
index 0017e66..38a281c 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query44.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query44.q.out
@@ -128,7 +128,7 @@ Stage-0
                           Filter Operator [FIL_193] (rows=6951 width=116)
                             predicate:((rank_window_0 < 11) and _col2 is not null)
                             PTF Operator [PTF_192] (rows=20854 width=116)
-                              Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS FIRST","partition by:":"0"}]
+                              Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS LAST","partition by:":"0"}]
                               Select Operator [SEL_191] (rows=20854 width=116)
                                 Output:["_col2","_col3"]
                               <-Reducer 10 [SIMPLE_EDGE]
diff --git a/ql/src/test/results/clientpositive/spark/sample10.q.out b/ql/src/test/results/clientpositive/spark/sample10.q.out
index d408b5d..51e8115 100644
--- a/ql/src/test/results/clientpositive/spark/sample10.q.out
+++ b/ql/src/test/results/clientpositive/spark/sample10.q.out
@@ -320,7 +320,7 @@ STAGE PLANS:
                 Statistics: Num rows: 10 Data size: 60 Basic stats: COMPLETE Column stats: NONE
                 Reduce Output Operator
                   key expressions: _col0 (type: string)
-                  null sort order: a
+                  null sort order: z
                   sort order: +
                   Statistics: Num rows: 10 Data size: 60 Basic stats: COMPLETE Column stats: NONE
                   tag: -1
diff --git a/ql/src/test/results/clientpositive/vector_char_2.q.out b/ql/src/test/results/clientpositive/vector_char_2.q.out
index aa627a8..8d98e98 100644
--- a/ql/src/test/results/clientpositive/vector_char_2.q.out
+++ b/ql/src/test/results/clientpositive/vector_char_2.q.out
@@ -224,11 +224,11 @@ limit 5
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@char_2_n0
 #### A masked pattern was here ####
-NULL	NULL	1
 val_0               	0	3
 val_10              	10	1
 val_100             	200	2
 val_103             	206	2
+val_104             	208	2
 PREHOOK: query: select value, sum(cast(key as int)), count(*) numrows
 from src
 group by value
diff --git a/ql/src/test/results/clientpositive/windowing_gby2.q.out b/ql/src/test/results/clientpositive/windowing_gby2.q.out
index d8de2fb..4ac79ee 100644
--- a/ql/src/test/results/clientpositive/windowing_gby2.q.out
+++ b/ql/src/test/results/clientpositive/windowing_gby2.q.out
@@ -398,7 +398,7 @@ STAGE PLANS:
                 Windowing table definition
                   input alias: ptf_1
                   name: windowingtablefunction
-                  order by: _col4 ASC NULLS FIRST
+                  order by: _col4 ASC NULLS LAST
                   partition by: lower(_col2)
                   raw input shape:
                   window functions:
@@ -446,7 +446,7 @@ STAGE PLANS:
                 Windowing table definition
                   input alias: ptf_1
                   name: windowingtablefunction
-                  order by: _col7 ASC NULLS FIRST
+                  order by: _col7 ASC NULLS LAST
                   partition by: _col6
                   raw input shape:
                   window functions: