Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
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();
{ + throw new UDFArgumentTypeException(0, + "Cannot support comparison of map<> type or complex type containing map<>."); + }
+ if (!ObjectInspectorUtils.compareSupported(loi))+ break;
default:
throw new UDFArgumentTypeException(0, "Argument 1"
+ " of function SORT_ARRAY must be array "
Attachments
Issue Links
- is duplicated by
-
HIVE-10788 Change sort_array to support non-primitive types
- Closed