Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Hive >> mail # dev >> querying against union datatypes

Copy link to this message
querying against union datatypes
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

CREATE TABLE union_test(foo UNIONTYPE<int, double, array<string>,
SELECT foo FROM union_test;


the udf  would function as

SELECT union_extract(foo, 2) FROM union_test;


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.