hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Maughan (JIRA)" <>
Subject [jira] [Created] (HIVE-15434) Hive GenericUDF to make uniontype more usable
Date Thu, 15 Dec 2016 11:45:58 GMT
David Maughan created HIVE-15434:

             Summary: Hive GenericUDF to make uniontype more usable
                 Key: HIVE-15434
             Project: Hive
          Issue Type: New Feature
          Components: UDF
    Affects Versions: 2.1.1
            Reporter: David Maughan
            Priority: Minor

h2. Overview

As stated in the documention:

UNIONTYPE support is incomplete The UNIONTYPE datatype was introduced in Hive 0.7.0 (HIVE-537),
but full support for this type in Hive remains incomplete. Queries that reference UNIONTYPE
fields in JOIN (HIVE-2508), WHERE, and GROUP BY clauses will fail, and Hive does not define
syntax to extract the tag or value fields of a UNIONTYPE. This means that UNIONTYPEs are effectively

It would be useful to have a UDF that allows extraction of values for further comparison or

h2. Proposal

I propose to add a GenericUDF that has 2 modes of operation. Consider the following schema
and data that contains a union:




hive> select field1 from thing;

h4. Explode to Struct

This method will recursively convert all unions within the type to structs with fields named
{{tag_n}}, {{n}} being the tag number. Only the {{tag_*}} field that matches the tag of the
union will be populated with the value. In the case above the schema of field1 will be converted


hive> select extract_union(field1) from thing;

hive> select extract_union(field1).tag_0 from thing;

h4. Extract the specified tag

This method will simply extract the value of the specified tag. If the tag number matches
then the value is returned, if it does not, then null is returned.

hive> select extract_union(field1, 0) from thing;

This message was sent by Atlassian JIRA

View raw message