You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2015/08/25 23:29:09 UTC

[39/50] [abbrv] hive git commit: HIVE-11596: nvl(x, y) throws NPE if type x and type y doesn't match, rather than throwing the meaningful error (Aihua Xu, reviewed by Chao Sun)

HIVE-11596: nvl(x, y) throws NPE if type x and type y doesn't match, rather than throwing the meaningful error (Aihua Xu, reviewed by Chao Sun)


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

Branch: refs/heads/llap
Commit: 3c1eae0c44450ebbf26c88066de871ea7f479981
Parents: 1030ae7
Author: Aihua Xu <ai...@gmail.com>
Authored: Fri Aug 21 15:23:53 2015 -0700
Committer: Chao Sun <su...@apache.org>
Committed: Fri Aug 21 15:23:53 2015 -0700

----------------------------------------------------------------------
 .../hive/ql/udf/generic/GenericUDFBasePad.java  |  8 ++--
 .../hive/ql/udf/generic/GenericUDFNvl.java      |  2 +-
 .../queries/clientnegative/nvl_mismatch_type.q  | 20 +++++++++
 .../clientnegative/char_pad_convert_fail0.q.out |  2 +-
 .../clientnegative/char_pad_convert_fail1.q.out |  2 +-
 .../clientnegative/char_pad_convert_fail3.q.out |  2 +-
 .../clientnegative/nvl_mismatch_type.q.out      | 43 ++++++++++++++++++++
 7 files changed, 71 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/3c1eae0c/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBasePad.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBasePad.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBasePad.java
index 3904ca4..33839f7 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBasePad.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBasePad.java
@@ -94,8 +94,8 @@ public abstract class GenericUDFBasePad extends GenericUDF {
   private Converter checkTextArguments(ObjectInspector[] arguments, int i)
     throws UDFArgumentException {
     if (arguments[i].getCategory() != ObjectInspector.Category.PRIMITIVE) {
-      throw new UDFArgumentTypeException(i + 1, "Only primitive type arguments are accepted but "
-      + arguments[i].getTypeName() + " is passed. as  arguments");
+      throw new UDFArgumentTypeException(i, "Only primitive type arguments are accepted but "
+      + arguments[i].getTypeName() + " is passed.");
     }
 
     Converter converter = ObjectInspectorConverters.getConverter((PrimitiveObjectInspector) arguments[i],
@@ -107,8 +107,8 @@ public abstract class GenericUDFBasePad extends GenericUDF {
   private Converter checkIntArguments(ObjectInspector[] arguments, int i)
     throws UDFArgumentException {
     if (arguments[i].getCategory() != ObjectInspector.Category.PRIMITIVE) {
-      throw new UDFArgumentTypeException(i + 1, "Only primitive type arguments are accepted but "
-      + arguments[i].getTypeName() + " is passed. as  arguments");
+      throw new UDFArgumentTypeException(i, "Only primitive type arguments are accepted but "
+      + arguments[i].getTypeName() + " is passed.");
     }
     PrimitiveCategory inputType = ((PrimitiveObjectInspector) arguments[i]).getPrimitiveCategory();
     Converter converter;

http://git-wip-us.apache.org/repos/asf/hive/blob/3c1eae0c/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFNvl.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFNvl.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFNvl.java
index 625b466..0a16da8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFNvl.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFNvl.java
@@ -42,7 +42,7 @@ public class GenericUDFNvl extends GenericUDF{
     returnOIResolver = new GenericUDFUtils.ReturnObjectInspectorResolver(true);
     if (!(returnOIResolver.update(arguments[0]) && returnOIResolver
         .update(arguments[1]))) {
-      throw new UDFArgumentTypeException(2,
+      throw new UDFArgumentTypeException(1,
           "The first and seconds arguments of function NLV should have the same type, "
           + "but they are different: \"" + arguments[0].getTypeName()
           + "\" and \"" + arguments[1].getTypeName() + "\"");

http://git-wip-us.apache.org/repos/asf/hive/blob/3c1eae0c/ql/src/test/queries/clientnegative/nvl_mismatch_type.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/nvl_mismatch_type.q b/ql/src/test/queries/clientnegative/nvl_mismatch_type.q
new file mode 100644
index 0000000..ace180c
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/nvl_mismatch_type.q
@@ -0,0 +1,20 @@
+
+create table over1k(
+           t tinyint,
+           si smallint,
+           i int,
+           b bigint,
+           f float,
+           d double,
+           bo boolean,
+           s string,
+           ts timestamp,
+           dec decimal(4,2),
+           bin binary)
+       row format delimited
+       fields terminated by '|';
+
+load data local inpath '../../data/files/over1k' into table over1k;
+
+-- Integers
+select nvl(t, true) from over1k limit 5;

http://git-wip-us.apache.org/repos/asf/hive/blob/3c1eae0c/ql/src/test/results/clientnegative/char_pad_convert_fail0.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/char_pad_convert_fail0.q.out b/ql/src/test/results/clientnegative/char_pad_convert_fail0.q.out
index d6f5502..ed2f516 100644
--- a/ql/src/test/results/clientnegative/char_pad_convert_fail0.q.out
+++ b/ql/src/test/results/clientnegative/char_pad_convert_fail0.q.out
@@ -40,4 +40,4 @@ POSTHOOK: query: load data local inpath '../../data/files/over1k' into table ove
 POSTHOOK: type: LOAD
 #### A masked pattern was here ####
 POSTHOOK: Output: default@over1k
-FAILED: SemanticException [Error 10016]: Line 7:29 Argument type mismatch '' '': Only primitive type arguments are accepted but array<int> is passed. as  arguments
+FAILED: SemanticException [Error 10016]: Line 7:15 Argument type mismatch '3': Only primitive type arguments are accepted but array<int> is passed.

http://git-wip-us.apache.org/repos/asf/hive/blob/3c1eae0c/ql/src/test/results/clientnegative/char_pad_convert_fail1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/char_pad_convert_fail1.q.out b/ql/src/test/results/clientnegative/char_pad_convert_fail1.q.out
index 81ceeec..5f17cfb 100644
--- a/ql/src/test/results/clientnegative/char_pad_convert_fail1.q.out
+++ b/ql/src/test/results/clientnegative/char_pad_convert_fail1.q.out
@@ -40,4 +40,4 @@ POSTHOOK: query: load data local inpath '../../data/files/over1k' into table ove
 POSTHOOK: type: LOAD
 #### A masked pattern was here ####
 POSTHOOK: Output: default@over1k
-FAILED: SemanticException [Error 10016]: Line 7:26 Argument type mismatch '4': Only primitive type arguments are accepted but array<int> is passed. as  arguments
+FAILED: SemanticException [Error 10016]: Line 7:12 Argument type mismatch '3': Only primitive type arguments are accepted but array<int> is passed.

http://git-wip-us.apache.org/repos/asf/hive/blob/3c1eae0c/ql/src/test/results/clientnegative/char_pad_convert_fail3.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/char_pad_convert_fail3.q.out b/ql/src/test/results/clientnegative/char_pad_convert_fail3.q.out
index 9896eae..a25ea15 100644
--- a/ql/src/test/results/clientnegative/char_pad_convert_fail3.q.out
+++ b/ql/src/test/results/clientnegative/char_pad_convert_fail3.q.out
@@ -40,4 +40,4 @@ POSTHOOK: query: load data local inpath '../../data/files/over1k' into table ove
 POSTHOOK: type: LOAD
 #### A masked pattern was here ####
 POSTHOOK: Output: default@over1k
-FAILED: SemanticException [Error 10016]: Line 7:38 Argument type mismatch '4': Only primitive type arguments are accepted but uniontype<string> is passed. as  arguments
+FAILED: SemanticException [Error 10016]: Line 7:12 Argument type mismatch ''Union'': Only primitive type arguments are accepted but uniontype<string> is passed.

http://git-wip-us.apache.org/repos/asf/hive/blob/3c1eae0c/ql/src/test/results/clientnegative/nvl_mismatch_type.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/nvl_mismatch_type.q.out b/ql/src/test/results/clientnegative/nvl_mismatch_type.q.out
new file mode 100644
index 0000000..6e88385
--- /dev/null
+++ b/ql/src/test/results/clientnegative/nvl_mismatch_type.q.out
@@ -0,0 +1,43 @@
+PREHOOK: query: create table over1k(
+           t tinyint,
+           si smallint,
+           i int,
+           b bigint,
+           f float,
+           d double,
+           bo boolean,
+           s string,
+           ts timestamp,
+           dec decimal(4,2),
+           bin binary)
+       row format delimited
+       fields terminated by '|'
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@over1k
+POSTHOOK: query: create table over1k(
+           t tinyint,
+           si smallint,
+           i int,
+           b bigint,
+           f float,
+           d double,
+           bo boolean,
+           s string,
+           ts timestamp,
+           dec decimal(4,2),
+           bin binary)
+       row format delimited
+       fields terminated by '|'
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@over1k
+PREHOOK: query: load data local inpath '../../data/files/over1k' into table over1k
+PREHOOK: type: LOAD
+#### A masked pattern was here ####
+PREHOOK: Output: default@over1k
+POSTHOOK: query: load data local inpath '../../data/files/over1k' into table over1k
+POSTHOOK: type: LOAD
+#### A masked pattern was here ####
+POSTHOOK: Output: default@over1k
+FAILED: SemanticException [Error 10016]: Line 4:14 Argument type mismatch 'true': The first and seconds arguments of function NLV should have the same type, but they are different: "tinyint" and "boolean"