[ 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<T> theArray)}} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.