Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1A532200C55 for ; Wed, 29 Mar 2017 18:42:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 18AE6160B8A; Wed, 29 Mar 2017 16:42:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 69141160B9D for ; Wed, 29 Mar 2017 18:42:46 +0200 (CEST) Received: (qmail 97368 invoked by uid 500); 29 Mar 2017 16:42:45 -0000 Mailing-List: contact issues-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hive.apache.org Delivered-To: mailing list issues@hive.apache.org Received: (qmail 97355 invoked by uid 99); 29 Mar 2017 16:42:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Mar 2017 16:42:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 28ED6C0D33 for ; Wed, 29 Mar 2017 16:42:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id DXpaMdvsKr3T for ; Wed, 29 Mar 2017 16:42:44 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 9B9855FE4D for ; Wed, 29 Mar 2017 16:42:43 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 9D904E08BB for ; Wed, 29 Mar 2017 16:42:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id DC23424174 for ; Wed, 29 Mar 2017 16:42:41 +0000 (UTC) Date: Wed, 29 Mar 2017 16:42:41 +0000 (UTC) From: "Ashutosh Chauhan (JIRA)" To: issues@hive.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HIVE-15434) Add UDF to allow interrogation of uniontype values MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 29 Mar 2017 16:42:47 -0000 [ https://issues.apache.org/jira/browse/HIVE-15434?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Ashutosh Chauhan updated HIVE-15434: ------------------------------------ Fix Version/s: 3.0.0 2.3.0 > Add UDF to allow interrogation of uniontype values > -------------------------------------------------- > > Key: HIVE-15434 > URL: https://issues.apache.org/jira/browse/HIVE-15434 > Project: Hive > Issue Type: New Feature > Components: UDF > Affects Versions: 2.1.1 > Reporter: David Maughan > Assignee: David Maughan > Fix For: 2.3.0, 3.0.0 > > Attachments: HIVE-15434.01.patch, HIVE-15434.02.patch > > > h2. Overview > As stated in the documention: > {quote} > 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 look-at-only. > {quote} > It is essential to have a usable uniontype. Until full support is added to Hive users should at least have the ability to inspect and extract values for further comparison or transformation. > h2. Proposal > I propose to add a GenericUDF that has 2 modes of operation. Consider the following schema and data that contains a union: > Schema: > {code} > struct> > {code} > Query: > {code} > hive> select field1 from thing; > {0:0} > {1:"one"} > {code} > 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 to: > {code} > struct > {code} > {code} > hive> select extract_union(field1) from thing; > {"tag_0":0,"tag_1":null} > {"tag_0":null,"tag_1":one} > {code} > {code} > hive> select extract_union(field1).tag_0 from thing; > 0 > null > {code} > 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. > {code} > hive> select extract_union(field1, 0) from thing; > 0 > null > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)