hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pxi...@apache.org
Subject hive git commit: HIVE-13372: Hive Macro overwritten when multiple macros are used in one column (Pengcheng Xiong, reviewed by Ashutosh Chauhan)
Date Thu, 31 Mar 2016 04:34:22 GMT
Repository: hive
Updated Branches:
  refs/heads/master 255069e4f -> 40088453b


HIVE-13372: Hive Macro overwritten when multiple macros are used in one 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/40088453
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/40088453
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/40088453

Branch: refs/heads/master
Commit: 40088453b57a9bc6abfa7d0a23c1a78d39390212
Parents: 255069e
Author: Pengcheng Xiong <pxiong@apache.org>
Authored: Wed Mar 30 21:34:01 2016 -0700
Committer: Pengcheng Xiong <pxiong@apache.org>
Committed: Wed Mar 30 21:34:01 2016 -0700

----------------------------------------------------------------------
 .../hive/ql/plan/ExprNodeGenericFuncDesc.java   |  5 +-
 ql/src/test/queries/clientpositive/macro_1.q    | 29 +++++++
 .../test/results/clientpositive/macro_1.q.out   | 84 ++++++++++++++++++++
 3 files changed, 117 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/40088453/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
index b7c1445..9e0159c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
@@ -284,7 +284,10 @@ public class ExprNodeGenericFuncDesc extends ExprNodeDesc implements
     }
 
     if (genericUDF instanceof GenericUDFMacro) {
-      if (funcText != null && !funcText.equals(dest.funcText)) {
+      // if getMacroName is null, we always treat it different from others.
+      if (((GenericUDFMacro) genericUDF).getMacroName() == null
+          || !(((GenericUDFMacro) genericUDF).getMacroName()
+              .equals(((GenericUDFMacro) dest.genericUDF).getMacroName()))) {
         return false;
       }
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/40088453/ql/src/test/queries/clientpositive/macro_1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/macro_1.q b/ql/src/test/queries/clientpositive/macro_1.q
new file mode 100644
index 0000000..dddc8e2
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/macro_1.q
@@ -0,0 +1,29 @@
+set hive.mapred.mode=nonstrict;
+
+CREATE TEMPORARY MACRO STRING_LEN(x string) length(x);
+CREATE TEMPORARY MACRO STRING_LEN_PLUS_ONE(x string) length(x)+1;
+CREATE TEMPORARY MACRO STRING_LEN_PLUS_TWO(x string) length(x)+2;
+
+create table macro_test (x string);
+
+insert into table macro_test values ("bb"), ("a"), ("ccc");
+
+SELECT
+    CONCAT(STRING_LEN(x), ":", STRING_LEN_PLUS_ONE(x), ":", STRING_LEN_PLUS_TWO(x)) a
+FROM macro_test;
+
+SELECT
+    CONCAT(STRING_LEN(x), ":", STRING_LEN_PLUS_ONE(x), ":", STRING_LEN_PLUS_TWO(x)) a
+FROM macro_test
+sort by a;
+
+
+SELECT
+    CONCAT(STRING_LEN(x), ":", STRING_LEN_PLUS_ONE(x), ":", STRING_LEN_PLUS_TWO(x)) a
+FROM macro_test
+sort by a desc;
+
+
+
+
+

http://git-wip-us.apache.org/repos/asf/hive/blob/40088453/ql/src/test/results/clientpositive/macro_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/macro_1.q.out b/ql/src/test/results/clientpositive/macro_1.q.out
new file mode 100644
index 0000000..82b4ad9
--- /dev/null
+++ b/ql/src/test/results/clientpositive/macro_1.q.out
@@ -0,0 +1,84 @@
+PREHOOK: query: CREATE TEMPORARY MACRO STRING_LEN(x string) length(x)
+PREHOOK: type: CREATEMACRO
+PREHOOK: Output: database:default
+POSTHOOK: query: CREATE TEMPORARY MACRO STRING_LEN(x string) length(x)
+POSTHOOK: type: CREATEMACRO
+POSTHOOK: Output: database:default
+PREHOOK: query: CREATE TEMPORARY MACRO STRING_LEN_PLUS_ONE(x string) length(x)+1
+PREHOOK: type: CREATEMACRO
+PREHOOK: Output: database:default
+POSTHOOK: query: CREATE TEMPORARY MACRO STRING_LEN_PLUS_ONE(x string) length(x)+1
+POSTHOOK: type: CREATEMACRO
+POSTHOOK: Output: database:default
+PREHOOK: query: CREATE TEMPORARY MACRO STRING_LEN_PLUS_TWO(x string) length(x)+2
+PREHOOK: type: CREATEMACRO
+PREHOOK: Output: database:default
+POSTHOOK: query: CREATE TEMPORARY MACRO STRING_LEN_PLUS_TWO(x string) length(x)+2
+POSTHOOK: type: CREATEMACRO
+POSTHOOK: Output: database:default
+PREHOOK: query: create table macro_test (x string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@macro_test
+POSTHOOK: query: create table macro_test (x string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@macro_test
+PREHOOK: query: insert into table macro_test values ("bb"), ("a"), ("ccc")
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@macro_test
+POSTHOOK: query: insert into table macro_test values ("bb"), ("a"), ("ccc")
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@macro_test
+POSTHOOK: Lineage: macro_test.x SIMPLE [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1,
type:string, comment:), ]
+PREHOOK: query: SELECT
+    CONCAT(STRING_LEN(x), ":", STRING_LEN_PLUS_ONE(x), ":", STRING_LEN_PLUS_TWO(x)) a
+FROM macro_test
+PREHOOK: type: QUERY
+PREHOOK: Input: default@macro_test
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT
+    CONCAT(STRING_LEN(x), ":", STRING_LEN_PLUS_ONE(x), ":", STRING_LEN_PLUS_TWO(x)) a
+FROM macro_test
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@macro_test
+#### A masked pattern was here ####
+2:3:4
+1:2:3
+3:4:5
+PREHOOK: query: SELECT
+    CONCAT(STRING_LEN(x), ":", STRING_LEN_PLUS_ONE(x), ":", STRING_LEN_PLUS_TWO(x)) a
+FROM macro_test
+sort by a
+PREHOOK: type: QUERY
+PREHOOK: Input: default@macro_test
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT
+    CONCAT(STRING_LEN(x), ":", STRING_LEN_PLUS_ONE(x), ":", STRING_LEN_PLUS_TWO(x)) a
+FROM macro_test
+sort by a
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@macro_test
+#### A masked pattern was here ####
+1:2:3
+2:3:4
+3:4:5
+PREHOOK: query: SELECT
+    CONCAT(STRING_LEN(x), ":", STRING_LEN_PLUS_ONE(x), ":", STRING_LEN_PLUS_TWO(x)) a
+FROM macro_test
+sort by a desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@macro_test
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT
+    CONCAT(STRING_LEN(x), ":", STRING_LEN_PLUS_ONE(x), ":", STRING_LEN_PLUS_TWO(x)) a
+FROM macro_test
+sort by a desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@macro_test
+#### A masked pattern was here ####
+3:4:5
+2:3:4
+1:2:3


Mime
View raw message