hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xu...@apache.org
Subject svn commit: r1604277 - in /hive/trunk/ql/src: java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java test/queries/clientpositive/udf_translate.q test/results/clientpositive/udf_translate.q.out
Date Fri, 20 Jun 2014 21:13:28 GMT
Author: xuefu
Date: Fri Jun 20 21:13:28 2014
New Revision: 1604277

URL: http://svn.apache.org/r1604277
Log:
HIVE-6622: UDF translate doesn't take either CHAR or VARCHAR as any of its arguments (Wilbur
via Xuefu)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java
    hive/trunk/ql/src/test/queries/clientpositive/udf_translate.q
    hive/trunk/ql/src/test/results/clientpositive/udf_translate.q.out

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java?rev=1604277&r1=1604276&r2=1604277&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java
(original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java
Fri Jun 20 21:13:28 2014
@@ -148,10 +148,12 @@ public class GenericUDFTranslate extends
           .getPrimitiveCategory();
 
       if (primitiveCategory != PrimitiveCategory.STRING
+          && primitiveCategory != PrimitiveCategory.CHAR
+          && primitiveCategory != PrimitiveCategory.VARCHAR
           && primitiveCategory != PrimitiveCategory.VOID) {
         throw new UDFArgumentTypeException(i,
-            "A string argument was expected but an argument of type " + arguments[i].getTypeName()
-                + " was given.");
+            "A string, char, or varchar argument was expected but an argument of type "
+                + arguments[i].getTypeName() + " was given.");
 
       }
     }

Modified: hive/trunk/ql/src/test/queries/clientpositive/udf_translate.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/udf_translate.q?rev=1604277&r1=1604276&r2=1604277&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/udf_translate.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/udf_translate.q Fri Jun 20 21:13:28 2014
@@ -37,3 +37,7 @@ SELECT translate('abcd', 'abc', '1234') 
 -- Test proper function over UTF-8 characters
 SELECT translate('Àbcd', 'À', 'Ã') FROM src tablesample (1 rows);
 
+-- Run some queries where the arguments are not strings but chars and varchars
+SELECT translate(CAST('abcd' AS CHAR(5)), CAST('aba' AS VARCHAR(5)), CAST('123' AS CHAR(5))),
+       translate(CAST('abcd' AS VARCHAR(9)), CAST('aba' AS CHAR(9)), CAST('12' AS VARCHAR(9)))
+       FROM src tablesample (1 rows);

Modified: hive/trunk/ql/src/test/results/clientpositive/udf_translate.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_translate.q.out?rev=1604277&r1=1604276&r2=1604277&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_translate.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_translate.q.out Fri Jun 20 21:13:28
2014
@@ -145,3 +145,18 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
 Ãbcd
+PREHOOK: query: -- Run some queries where the arguments are not strings but chars and varchars
+SELECT translate(CAST('abcd' AS CHAR(5)), CAST('aba' AS VARCHAR(5)), CAST('123' AS CHAR(5))),
+       translate(CAST('abcd' AS VARCHAR(9)), CAST('aba' AS CHAR(9)), CAST('12' AS VARCHAR(9)))
+       FROM src tablesample (1 rows)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: -- Run some queries where the arguments are not strings but chars and varchars
+SELECT translate(CAST('abcd' AS CHAR(5)), CAST('aba' AS VARCHAR(5)), CAST('123' AS CHAR(5))),
+       translate(CAST('abcd' AS VARCHAR(9)), CAST('aba' AS CHAR(9)), CAST('12' AS VARCHAR(9)))
+       FROM src tablesample (1 rows)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+12cd	12cd



Mime
View raw message