You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Ron Bodkin (JIRA)" <ji...@apache.org> on 2013/01/07 01:22:12 UTC

[jira] [Commented] (HIVE-3865) Allow collect_set to work on non-primitive types

    [ https://issues.apache.org/jira/browse/HIVE-3865?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13545534#comment-13545534 ] 

Ron Bodkin commented on HIVE-3865:
----------------------------------

It's nice if you can use collect_set for structs too, to collect related information from a set of rows into an array. It turns out it's pretty easy to implement. I have run sample queries using a slightly modified version and it works just fine.

The general approach is just to drop the needless assumption of a primitive object inspector and check for comparable objects rather than primitives, like so:
<     ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[0]);
<     if (!ObjectInspectorUtils.compareSupported(oi)) {
<       throw new UDFArgumentTypeException(parameters.length - 1,
<           "Cannot support comparison of map<> type or complex type containing map<>.");
---
>     if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
>       throw new UDFArgumentTypeException(0,
>           "Only primitive type arguments are accepted but "
>           + parameters[0].getTypeName() + " was passed as parameter 1.");

<     private ObjectInspector inputOI;
---
>     private PrimitiveObjectInspector inputOI;

<         inputOI = parameters[0];
---
>         inputOI = (PrimitiveObjectInspector) parameters[0];

<             .getStandardListObjectInspector(ObjectInspectorUtils
---
>             .getStandardListObjectInspector((PrimitiveObjectInspector) ObjectInspectorUtils

<           inputOI = internalMergeOI.getListElementObjectInspector();
---
>           inputOI = (PrimitiveObjectInspector) internalMergeOI.getListElementObjectInspector();

Is there some reason this won't work? I can turn this into a formal patch and test it but would welcome any feedback.

                
> Allow collect_set to work on non-primitive types
> ------------------------------------------------
>
>                 Key: HIVE-3865
>                 URL: https://issues.apache.org/jira/browse/HIVE-3865
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Ron Bodkin
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira