Return-Path: Delivered-To: apmail-hadoop-hive-dev-archive@minotaur.apache.org Received: (qmail 62788 invoked from network); 3 Mar 2010 20:29:04 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Mar 2010 20:29:04 -0000 Received: (qmail 62135 invoked by uid 500); 3 Mar 2010 20:28:55 -0000 Delivered-To: apmail-hadoop-hive-dev-archive@hadoop.apache.org Received: (qmail 62033 invoked by uid 500); 3 Mar 2010 20:28:55 -0000 Mailing-List: contact hive-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hadoop.apache.org Delivered-To: mailing list hive-dev@hadoop.apache.org Received: (qmail 62015 invoked by uid 99); 3 Mar 2010 20:28:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Mar 2010 20:28:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Mar 2010 20:28:55 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 38F3B234C4C4 for ; Wed, 3 Mar 2010 20:28:35 +0000 (UTC) Message-ID: <1251587114.46081267648115232.JavaMail.jira@brutus.apache.org> Date: Wed, 3 Mar 2010 20:28:35 +0000 (UTC) From: "Arvind Prabhakar (JIRA)" To: hive-dev@hadoop.apache.org Subject: [jira] Updated: (HIVE-1179) Add UDF array_contains In-Reply-To: <686712914.366301266520827953.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HIVE-1179?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Arvind Prabhakar updated HIVE-1179: ----------------------------------- Attachment: HIVE-1179.patch *Summary:* This patch implements the array_contains UDF. The signature of this UDF is array_contains(array, value). It returns true if value exists within the array. The comparison of value with array elements is done using the ObjectInspectorUtils' compare method. *Special Case:* The implementation of ObjectInspectorUtils.compare() method currently does not handle map comparisons and raises a runtime exception when it encounters a map type. To avoid this exception, a call to compareSupported() method is made by the UDF during initialization. If this method returns false, a UDFArgumentException is raised stating that the argument type does not support comparison. *Implementation Details:* _GenericUDFArrayContains.java_ - added to {{org.apache.hadoop.hive.ql.udf.generic}} package - its initialize method does the following (a) checks to see if there are exactly two arguments specified, (b) if the first argument is of a LIST type, (c) if the type of list element and the type of value argument is identical, and (d) if comparison for such types is supported. - its evaluate method calls into {{ObjectInspectorUtils.compare()}} method to test if the given value matches any of the elements of the given array. _ObjectInspectorUtils:_ - added a new method called {{compareTypes(ObjectInspector, ObjectInspector)}} which returns true if the two types represented are identical. This comparison is done via recursive call to elements of the type until all elements are deemed identical down to their primitive constituents. _FunctionRegistry:_ - Registered the {{GenericUDFArrayContains}} as array_contains - Some whitespace formatting changes and removal of redundant casts _package-info.java_ - added the missing file to hive.ql.generic package. _Test cases:_ - client positive test: {{udf_array_contains.q}} - client negative tests: {{udf_array_contains_wrong1.q}}, {{udf_array_contains_wrong2.q}} > Add UDF array_contains > ---------------------- > > Key: HIVE-1179 > URL: https://issues.apache.org/jira/browse/HIVE-1179 > Project: Hadoop Hive > Issue Type: New Feature > Reporter: Zheng Shao > Attachments: HIVE-1179.patch > > > Returns true or false, depending on whether an element is in an array. > {{array_contains(T element, array theArray)}} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.