Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4D37410F27 for ; Thu, 18 Jul 2013 04:28:05 +0000 (UTC) Received: (qmail 75477 invoked by uid 500); 18 Jul 2013 04:28:04 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 75444 invoked by uid 500); 18 Jul 2013 04:27:55 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 75431 invoked by uid 99); 18 Jul 2013 04:27:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jul 2013 04:27:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jul 2013 04:27:48 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 25F942388980; Thu, 18 Jul 2013 04:27:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1504361 - in /hive/trunk/ql/src: java/org/apache/hadoop/hive/ql/exec/ test/results/clientnegative/ test/results/compiler/errors/ Date: Thu, 18 Jul 2013 04:27:26 -0000 To: commits@hive.apache.org From: ecapriolo@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130718042727.25F942388980@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ecapriolo Date: Thu Jul 18 04:27:26 2013 New Revision: 1504361 URL: http://svn.apache.org/r1504361 Log: HIVE-4873 Sort candidate functions in case of UDFArgumentException (Xuefu Zhang via egc) Submitted by: Xuefu Zhang Reviewed by: Edward Capriolo Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/UDFArgumentException.java hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_1.q.out hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_2.q.out hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_3.q.out hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_4.q.out hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_5.q.out hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_6.q.out hive/trunk/ql/src/test/results/clientnegative/wrong_column_type.q.out hive/trunk/ql/src/test/results/compiler/errors/invalid_function_param2.q.out Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/UDFArgumentException.java URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/UDFArgumentException.java?rev=1504361&r1=1504360&r2=1504361&view=diff ============================================================================== --- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/UDFArgumentException.java (original) +++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/UDFArgumentException.java Thu Jul 18 04:27:26 2013 @@ -21,6 +21,8 @@ package org.apache.hadoop.hive.ql.exec; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import org.apache.hadoop.hive.ql.parse.SemanticException; @@ -72,6 +74,8 @@ public class UDFArgumentException extend StringBuilder sb = new StringBuilder(); sb.append(message); if (methods != null) { + // Sort the methods before omitting them. + sortMethods(methods); sb.append(". Possible choices: "); for (Method m: methods) { Type[] types = m.getGenericParameterTypes(); @@ -89,6 +93,28 @@ public class UDFArgumentException extend return sb.toString(); } + private static void sortMethods(List methods) { + Collections.sort( methods, new Comparator(){ + + @Override + public int compare(Method m1, Method m2) { + int result = m1.getName().compareTo(m2.getName()); + if (result != 0) + return result; + Type[] types1 = m1.getGenericParameterTypes(); + Type[] types2 = m2.getGenericParameterTypes(); + for (int i = 0; i < types1.length && i < types2.length; i++) { + String type1 = ObjectInspectorUtils.getTypeNameFromJavaClass(types1[i]); + String type2 = ObjectInspectorUtils.getTypeNameFromJavaClass(types2[i]); + if ((result = type1.compareTo(type2)) != 0) + return result; + } + return types1.length - types2.length; + } + + }); + } + /** * The UDF or UDAF class that has the ambiguity. */ Modified: hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_1.q.out URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_1.q.out?rev=1504361&r1=1504360&r2=1504361&view=diff ============================================================================== --- hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_1.q.out (original) +++ hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_1.q.out Thu Jul 18 04:27:26 2013 @@ -3,4 +3,4 @@ PREHOOK: type: CREATETABLE POSTHOOK: query: create table tbl (a binary) POSTHOOK: type: CREATETABLE POSTHOOK: Output: default@tbl -FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToInteger with (binary). Possible choices: _FUNC_(void) _FUNC_(boolean) _FUNC_(tinyint) _FUNC_(smallint) _FUNC_(bigint) _FUNC_(float) _FUNC_(double) _FUNC_(string) _FUNC_(timestamp) _FUNC_(decimal) +FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToInteger with (binary). Possible choices: _FUNC_(bigint) _FUNC_(boolean) _FUNC_(decimal) _FUNC_(double) _FUNC_(float) _FUNC_(smallint) _FUNC_(string) _FUNC_(timestamp) _FUNC_(tinyint) _FUNC_(void) Modified: hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_2.q.out URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_2.q.out?rev=1504361&r1=1504360&r2=1504361&view=diff ============================================================================== --- hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_2.q.out (original) +++ hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_2.q.out Thu Jul 18 04:27:26 2013 @@ -3,4 +3,4 @@ PREHOOK: type: CREATETABLE POSTHOOK: query: create table tbl (a binary) POSTHOOK: type: CREATETABLE POSTHOOK: Output: default@tbl -FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToByte with (binary). Possible choices: _FUNC_(void) _FUNC_(boolean) _FUNC_(smallint) _FUNC_(int) _FUNC_(bigint) _FUNC_(float) _FUNC_(double) _FUNC_(string) _FUNC_(timestamp) _FUNC_(decimal) +FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToByte with (binary). Possible choices: _FUNC_(bigint) _FUNC_(boolean) _FUNC_(decimal) _FUNC_(double) _FUNC_(float) _FUNC_(int) _FUNC_(smallint) _FUNC_(string) _FUNC_(timestamp) _FUNC_(void) Modified: hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_3.q.out URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_3.q.out?rev=1504361&r1=1504360&r2=1504361&view=diff ============================================================================== --- hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_3.q.out (original) +++ hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_3.q.out Thu Jul 18 04:27:26 2013 @@ -3,4 +3,4 @@ PREHOOK: type: CREATETABLE POSTHOOK: query: create table tbl (a binary) POSTHOOK: type: CREATETABLE POSTHOOK: Output: default@tbl -FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToShort with (binary). Possible choices: _FUNC_(void) _FUNC_(boolean) _FUNC_(tinyint) _FUNC_(int) _FUNC_(bigint) _FUNC_(float) _FUNC_(double) _FUNC_(string) _FUNC_(timestamp) _FUNC_(decimal) +FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToShort with (binary). Possible choices: _FUNC_(bigint) _FUNC_(boolean) _FUNC_(decimal) _FUNC_(double) _FUNC_(float) _FUNC_(int) _FUNC_(string) _FUNC_(timestamp) _FUNC_(tinyint) _FUNC_(void) Modified: hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_4.q.out URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_4.q.out?rev=1504361&r1=1504360&r2=1504361&view=diff ============================================================================== --- hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_4.q.out (original) +++ hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_4.q.out Thu Jul 18 04:27:26 2013 @@ -3,4 +3,4 @@ PREHOOK: type: CREATETABLE POSTHOOK: query: create table tbl (a binary) POSTHOOK: type: CREATETABLE POSTHOOK: Output: default@tbl -FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToLong with (binary). Possible choices: _FUNC_(void) _FUNC_(boolean) _FUNC_(tinyint) _FUNC_(smallint) _FUNC_(int) _FUNC_(bigint) _FUNC_(float) _FUNC_(double) _FUNC_(string) _FUNC_(timestamp) _FUNC_(decimal) +FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToLong with (binary). Possible choices: _FUNC_(bigint) _FUNC_(boolean) _FUNC_(decimal) _FUNC_(double) _FUNC_(float) _FUNC_(int) _FUNC_(smallint) _FUNC_(string) _FUNC_(timestamp) _FUNC_(tinyint) _FUNC_(void) Modified: hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_5.q.out URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_5.q.out?rev=1504361&r1=1504360&r2=1504361&view=diff ============================================================================== --- hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_5.q.out (original) +++ hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_5.q.out Thu Jul 18 04:27:26 2013 @@ -3,4 +3,4 @@ PREHOOK: type: CREATETABLE POSTHOOK: query: create table tbl (a binary) POSTHOOK: type: CREATETABLE POSTHOOK: Output: default@tbl -FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToFloat with (binary). Possible choices: _FUNC_(void) _FUNC_(boolean) _FUNC_(tinyint) _FUNC_(smallint) _FUNC_(int) _FUNC_(bigint) _FUNC_(double) _FUNC_(string) _FUNC_(timestamp) _FUNC_(decimal) +FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToFloat with (binary). Possible choices: _FUNC_(bigint) _FUNC_(boolean) _FUNC_(decimal) _FUNC_(double) _FUNC_(int) _FUNC_(smallint) _FUNC_(string) _FUNC_(timestamp) _FUNC_(tinyint) _FUNC_(void) Modified: hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_6.q.out URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_6.q.out?rev=1504361&r1=1504360&r2=1504361&view=diff ============================================================================== --- hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_6.q.out (original) +++ hive/trunk/ql/src/test/results/clientnegative/invalid_cast_from_binary_6.q.out Thu Jul 18 04:27:26 2013 @@ -3,4 +3,4 @@ PREHOOK: type: CREATETABLE POSTHOOK: query: create table tbl (a binary) POSTHOOK: type: CREATETABLE POSTHOOK: Output: default@tbl -FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToDouble with (binary). Possible choices: _FUNC_(void) _FUNC_(boolean) _FUNC_(tinyint) _FUNC_(smallint) _FUNC_(int) _FUNC_(bigint) _FUNC_(float) _FUNC_(string) _FUNC_(timestamp) _FUNC_(decimal) +FAILED: SemanticException Line 0:-1 Wrong arguments 'a': No matching method for class org.apache.hadoop.hive.ql.udf.UDFToDouble with (binary). Possible choices: _FUNC_(bigint) _FUNC_(boolean) _FUNC_(decimal) _FUNC_(float) _FUNC_(int) _FUNC_(smallint) _FUNC_(string) _FUNC_(timestamp) _FUNC_(tinyint) _FUNC_(void) Modified: hive/trunk/ql/src/test/results/clientnegative/wrong_column_type.q.out URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/wrong_column_type.q.out?rev=1504361&r1=1504360&r2=1504361&view=diff ============================================================================== --- hive/trunk/ql/src/test/results/clientnegative/wrong_column_type.q.out (original) +++ hive/trunk/ql/src/test/results/clientnegative/wrong_column_type.q.out Thu Jul 18 04:27:26 2013 @@ -3,4 +3,4 @@ PREHOOK: type: CREATETABLE POSTHOOK: query: CREATE TABLE dest1(a float) POSTHOOK: type: CREATETABLE POSTHOOK: Output: default@dest1 -FAILED: NoMatchingMethodException No matching method for class org.apache.hadoop.hive.ql.udf.UDFToFloat with (array). Possible choices: _FUNC_(void) _FUNC_(boolean) _FUNC_(tinyint) _FUNC_(smallint) _FUNC_(int) _FUNC_(bigint) _FUNC_(double) _FUNC_(string) _FUNC_(timestamp) _FUNC_(decimal) +FAILED: NoMatchingMethodException No matching method for class org.apache.hadoop.hive.ql.udf.UDFToFloat with (array). Possible choices: _FUNC_(bigint) _FUNC_(boolean) _FUNC_(decimal) _FUNC_(double) _FUNC_(int) _FUNC_(smallint) _FUNC_(string) _FUNC_(timestamp) _FUNC_(tinyint) _FUNC_(void) Modified: hive/trunk/ql/src/test/results/compiler/errors/invalid_function_param2.q.out URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/compiler/errors/invalid_function_param2.q.out?rev=1504361&r1=1504360&r2=1504361&view=diff ============================================================================== --- hive/trunk/ql/src/test/results/compiler/errors/invalid_function_param2.q.out (original) +++ hive/trunk/ql/src/test/results/compiler/errors/invalid_function_param2.q.out Thu Jul 18 04:27:26 2013 @@ -1,2 +1,2 @@ Semantic Exception: -Line 2:36 Wrong arguments ''abc'': No matching method for class org.apache.hadoop.hive.ql.udf.UDFSubstr with (string, string). Possible choices: _FUNC_(string, int, int) _FUNC_(string, int) _FUNC_(binary, int, int) _FUNC_(binary, int) \ No newline at end of file +Line 2:36 Wrong arguments ''abc'': No matching method for class org.apache.hadoop.hive.ql.udf.UDFSubstr with (string, string). Possible choices: _FUNC_(binary, int) _FUNC_(binary, int, int) _FUNC_(string, int) _FUNC_(string, int, int) \ No newline at end of file