Repository: hive Updated Branches: refs/heads/master 12b27a355 -> a6366fc07
HIVE-16050: Regression: Union of null with non-null (Gopal V, reviewed by Sergey Shelukhin) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/a6366fc0 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a6366fc0 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a6366fc0 Branch: refs/heads/master Commit: a6366fc07931f374af77d0ab208404027bf165a3 Parents: 12b27a3 Author: Gopal V <[email protected]> Authored: Wed Mar 1 17:57:54 2017 +0530 Committer: Gopal V <[email protected]> Committed: Wed Mar 1 17:58:06 2017 +0530 ---------------------------------------------------------------------- .../org/apache/hadoop/hive/ql/exec/FunctionRegistry.java | 9 +++++++++ ql/src/test/queries/clientpositive/union_null.q | 3 +++ ql/src/test/results/clientpositive/spark/union_null.q.out | 10 ++++++++++ ql/src/test/results/clientpositive/union_null.q.out | 10 ++++++++++ 4 files changed, 32 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/a6366fc0/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java index 0f05160..aaf2399 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java @@ -728,6 +728,15 @@ public final class FunctionRegistry { PrimitiveGrouping pgA = PrimitiveObjectInspectorUtils.getPrimitiveGrouping(pcA); PrimitiveGrouping pgB = PrimitiveObjectInspectorUtils.getPrimitiveGrouping(pcB); + + // untyped nulls + if (pgA == PrimitiveGrouping.VOID_GROUP) { + return b; + } + if (pgB == PrimitiveGrouping.VOID_GROUP) { + return a; + } + if (pgA != pgB) { return null; } http://git-wip-us.apache.org/repos/asf/hive/blob/a6366fc0/ql/src/test/queries/clientpositive/union_null.q ---------------------------------------------------------------------- diff --git a/ql/src/test/queries/clientpositive/union_null.q b/ql/src/test/queries/clientpositive/union_null.q index 45448b4..aacf310 100644 --- a/ql/src/test/queries/clientpositive/union_null.q +++ b/ql/src/test/queries/clientpositive/union_null.q @@ -8,3 +8,6 @@ select x from (select * from (select value as x from src order by x limit 5)a un set hive.cbo.returnpath.hiveop=false; -- HIVE-4837 select * from (select * from (select cast(null as string) as N from src1 group by key)a UNION ALL select * from (select cast(null as string) as N from src1 group by key)b ) a; + +-- HIVE-16050 +select null as c1 UNION ALL select 1 as c1; http://git-wip-us.apache.org/repos/asf/hive/blob/a6366fc0/ql/src/test/results/clientpositive/spark/union_null.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/spark/union_null.q.out b/ql/src/test/results/clientpositive/spark/union_null.q.out index e196ff3..00bd9d9 100644 --- a/ql/src/test/results/clientpositive/spark/union_null.q.out +++ b/ql/src/test/results/clientpositive/spark/union_null.q.out @@ -74,3 +74,13 @@ NULL NULL NULL NULL +PREHOOK: query: select null as c1 UNION ALL select 1 as c1 +PREHOOK: type: QUERY +PREHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POSTHOOK: query: select null as c1 UNION ALL select 1 as c1 +POSTHOOK: type: QUERY +POSTHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +NULL +1 http://git-wip-us.apache.org/repos/asf/hive/blob/a6366fc0/ql/src/test/results/clientpositive/union_null.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/union_null.q.out b/ql/src/test/results/clientpositive/union_null.q.out index e196ff3..00bd9d9 100644 --- a/ql/src/test/results/clientpositive/union_null.q.out +++ b/ql/src/test/results/clientpositive/union_null.q.out @@ -74,3 +74,13 @@ NULL NULL NULL NULL +PREHOOK: query: select null as c1 UNION ALL select 1 as c1 +PREHOOK: type: QUERY +PREHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POSTHOOK: query: select null as c1 UNION ALL select 1 as c1 +POSTHOOK: type: QUERY +POSTHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +NULL +1
