Ron Bodkin created HIVE-3866:
--------------------------------
Summary: 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 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