Hello all - I understand that support for union datatypes isn't complete, so I am attempting to write a generic UDF to extract type-specific information. For the example in the wiki (https://cwiki.apache.org/Hive/languagemanual-types.html#LanguageManualTypes-Uniontypes):
CREATE TABLE union_test(foo UNIONTYPE<int, double, array<string>, struct<a:int,b:string>>); SELECT foo FROM union_test; {0:1} {1:2.0} {2:["three","four"]} {3:{"a":5,"b":"five"}} {2:["six","seven"]} {3:{"a":8,"b":"eight"}} {0:9} {1:10.0} the udf would function as SELECT union_extract(foo, 2) FROM union_test; null null ["three","four"] null ["six","seven"] null null where the return value is of the type matching the union definition (in this case, array<string>) >From my understanding, the initialize function of a GenericUDF public ObjectInspector initialize(ObjectInspector[] arguments) returns an ObjectInspector appropriate for the return value. Is it possible to deduce from the arguments what type of ObjectInspector should be returned? Apologies if this is a basic question - I've written simple UDFs before, butI didn't find any similar examples in the Hive codebase. cheers, -James