Return-Path: X-Original-To: apmail-hive-user-archive@www.apache.org Delivered-To: apmail-hive-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7270110983 for ; Wed, 29 Jan 2014 15:29:46 +0000 (UTC) Received: (qmail 45613 invoked by uid 500); 29 Jan 2014 15:29:41 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 45557 invoked by uid 500); 29 Jan 2014 15:29:41 -0000 Mailing-List: contact user-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hive.apache.org Delivered-To: mailing list user@hive.apache.org Received: (qmail 45547 invoked by uid 99); 29 Jan 2014 15:29:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jan 2014 15:29:40 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of edlinuxguru@gmail.com designates 74.125.82.54 as permitted sender) Received: from [74.125.82.54] (HELO mail-wg0-f54.google.com) (74.125.82.54) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jan 2014 15:29:35 +0000 Received: by mail-wg0-f54.google.com with SMTP id x13so3901602wgg.9 for ; Wed, 29 Jan 2014 07:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=WjBAsmc122i2pXh5A9PjfTeumleq9nxanVQpIBh1acA=; b=cwSJR0K/l5ccNBiliZaYiPsux33GvdHe9M56lzwcaxq9Uv+CWhjzRfKnXc7BMQ/8NR nT289RBONMURud7ty2UOu7uMkuFPAkk98SfhmXjKneX+mm98oYQLx5PhqADCL062onyS oNBikywDX9y3L+fJisZtQJR0Gss386zCiO7Jbwlg3b7UqJjfC0dYWqBkaPV+MxHOExea yMNkeT9P6u2UGT8WudWSYcfEyC5DyCkR8/2XkMOjgOVOl94mr+VaTKS+lj1BSy0TFGjG p0S7zqqmv94wsZkN29Kth5kOQOJpCS5/9JtS+IUgP9y9ng03alnl3nK/5ObbIwEukzKc AD7A== MIME-Version: 1.0 X-Received: by 10.194.119.168 with SMTP id kv8mr2211726wjb.41.1391009354286; Wed, 29 Jan 2014 07:29:14 -0800 (PST) Received: by 10.194.220.105 with HTTP; Wed, 29 Jan 2014 07:29:14 -0800 (PST) In-Reply-To: <1391008899.42220.YahooMailNeo@web160106.mail.bf1.yahoo.com> References: <1391008899.42220.YahooMailNeo@web160106.mail.bf1.yahoo.com> Date: Wed, 29 Jan 2014 10:29:14 -0500 Message-ID: Subject: Re: Returning variable number of fields from Hive UDTF From: Edward Capriolo To: "user@hive.apache.org" , Kumar V Content-Type: multipart/alternative; boundary=089e01176b1d710bd104f11d9a6a X-Virus-Checked: Checked by ClamAV on apache.org --089e01176b1d710bd104f11d9a6a Content-Type: text/plain; charset=ISO-8859-1 if and only if the number is truely a constant, you can use the constant Object Inspector in initialize. The value but be a constant at query compile time. So this should work: myudtf(5,xpathsfile); THhis can not work myudtf(colx,xpathsfile); On Wed, Jan 29, 2014 at 10:21 AM, Kumar V wrote: > Hi all, > I have a UDTF that returns fields from an XML/SerDe based table. So I > have to return varying number of fields from the UDTF based on the number > of xpath's in the query file. I am not sure how to access the values of > the parameters in the initialize() method of the UDTF. It only has the > ObjectInspector array. The UDTF itself works fine if I always return a > fixed number of fields. > > Something like > > select * from myudtf(xpathsfile); > > Should return as many fields as there are xpaths in the file. Or I can > also modify the UDTF to take in a parameter for the number of fields, like > > select * from myudtf(5,xpathsfile); > > I am kind of against a wall here. Any help is appreciated. > > Regards, > Murali. > --089e01176b1d710bd104f11d9a6a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
if and only if the number is truely a constant, you can us= e the constant Object Inspector in initialize. The value but be a constant = at query compile time.
So this should work:
myudtf(5,xpathsfile);
THhis can not work
myudtf(colx,xpathsfile);


On Wed, Jan 29, 2014 at 10:21 AM= , Kumar V <kumarbuyonline@yahoo.com> wrote:
Hi all,
=A0=A0=A0 I have a=A0UDTF that returns fields from an XML= /SerDe based table.=A0 So I have to return varying number of fields from th= e UDTF based on the number of xpath's in the query file.=A0 I am not su= re how to access the values of the parameters in the initialize() method of= the UDTF.=A0 It only has the ObjectInspector array. The UDTF itself works = fine if I always return a fixed number of fields.

Something like

select * from = myudtf(xpathsfile);

Should return as many fields a= s there are xpaths in the file.=A0 Or I can also modify the UDTF to take in= a parameter for the number of fields, like

select * from myudtf(5,xpathsfile);

I am kind of against a wall= here. Any help is appreciated.

Regards,
Murali.

--089e01176b1d710bd104f11d9a6a--