You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Michael Haeusler (JIRA)" <ji...@apache.org> on 2015/06/12 14:02:01 UTC

[jira] [Commented] (HIVE-3866) Allow sort_array to work on non-primitive types.

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

Michael Haeusler commented on HIVE-3866:
----------------------------------------

Is this issue duplicated by Hive-10788?

> Allow sort_array to work on non-primitive types.
> ------------------------------------------------
>
>                 Key: HIVE-3866
>                 URL: https://issues.apache.org/jira/browse/HIVE-3866
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Ron Bodkin
>
> It's also nice to be able to sort an array of structs, as a kind of generalization of HIVE-1128, so you can have not only the maximum value from a list but a sorted list of value and source keys. As with HIVE-3865 it's fairly easy to relax the assumption that sort_array works only on primitives:
> @@ -35,6 +35,7 @@ import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters;
>  import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter;
>  import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
>  import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
> +import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
>  
>  /**
>   * Generic UDF for array sort
> @@ -66,10 +67,12 @@ public class GenericUDFSortArray extends GenericUDF {
>  
>      switch(arguments[0].getCategory()) {
>        case LIST:
> -        if(((ListObjectInspector)(arguments[0])).getListElementObjectInspector()
> -          .getCategory().equals(Category.PRIMITIVE)) {
> -          break;
> -        }
> +            ObjectInspector loi = ((ListObjectInspector)(arguments[0])).getListElementObjectInspector();
> +           if (!ObjectInspectorUtils.compareSupported(loi)) {
> +             throw new UDFArgumentTypeException(0,
> +                 "Cannot support comparison of map<> type or complex type containing map<>.");
> +           }
> +            break;
>        default:
>          throw new UDFArgumentTypeException(0, "Argument 1"
>            + " of function SORT_ARRAY must be array "



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)