hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arvind Prabhakar (JIRA)" <>
Subject [jira] Updated: (HIVE-1179) Add UDF array_contains
Date Wed, 03 Mar 2010 20:28:35 GMT


Arvind Prabhakar updated HIVE-1179:

    Attachment: HIVE-1179.patch

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 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

*Implementation Details:*
	- 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 {{}} method to test if the
given value matches any of the elements of the given array.
	- 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.

	- Registered the {{GenericUDFArrayContains}} as array_contains
	- Some whitespace formatting changes and removal of redundant casts
	- 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:
>             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.

View raw message