Thanks Paul, Confirmed that it does indeed work like that.
On Tue, Nov 9, 2010 at 12:13 AM, Paul Yang <py...@facebook.com> wrote: > In your original query, I think if you put parenthesis around p,k it should > have worked: > > select taxonDensityUDTF(kingdom_concept_id, phylum_concept_id) as (p,k) ... > > -----Original Message----- > From: Tim Robertson [mailto:timrobertson...@gmail.com] > Sent: Monday, November 08, 2010 5:53 AM > To: user@hive.apache.org > Subject: Re: Only a single expression in the SELECT clause is supported with > UDTF's > > Thank you once again Sonal. > > The following worked just nicely: > select k,p from temp_kingdom_phylum lateral view > taxonDensityUDTF(kingdom_concept_id, phylum_concept_id) e as k,p; > > [For anyone stumbling across this thread: I also had to change the > close() and issue the forward() in the process andnot in the close() > which is against the example shipped with hive, but in accord with the > docs which say one must not do this] > > Cheers, > Tim > > > > On Mon, Nov 8, 2010 at 2:18 PM, Sonal Goyal <sonalgoy...@gmail.com> wrote: >> Hi Tim, >> >> I guess you are running into limitations while using UDTFs. Check >> http://wiki.apache.org/hadoop/Hive/LanguageManual/UDF#UDTF. I think you >> should be able to use lateral view in your query. >> >> Thanks and Regards, >> Sonal >> >> Sonal Goyal | Founder and CEO | Nube Technologies LLP >> http://www.nubetech.co >> http://code.google.com/p/hiho/ >> >> >> >> >> >> >> On Mon, Nov 8, 2010 at 2:11 PM, Tim Robertson <timrobertson...@gmail.com> >> wrote: >>> >>> Hi all, >>> >>> I am trying my first UDTF, but can't seem to get it to run. Can >>> anyone spot anything wrong with this please: >>> >>> hive> select taxonDensityUDTF(kingdom_concept_id, phylum_concept_id) >>> as p,k from temp_kingdom_phylum; >>> FAILED: Error in semantic analysis: Only a single expression in the >>> SELECT clause is supported with UDTF's >>> hive> >>> >>> Below is my code. Thanks for any pointers, >>> >>> Tim >>> >>> >>> >>> @description( >>> name = "taxonDensityUDTF", >>> value = "_FUNC_(kingdom_concept_id, phylum_concept_id)" >>> ) >>> public class TaxonDensityUDTF extends GenericUDTF { >>> Integer kingdom_concept_id = Integer.valueOf(0); >>> Integer phylum_concept_id = Integer.valueOf(0); >>> >>> /** >>> * @see org.apache.hadoop.hive.ql.udf.generic.GenericUDTF#close() >>> */ >>> �...@override >>> public void close() throws HiveException { >>> Object[] forwardObj = new Object[2]; >>> forwardObj[0] = kingdom_concept_id; >>> forwardObj[1] = phylum_concept_id; >>> forward(forwardObj); >>> // TEST STUFF FOR NOW >>> forwardObj = new Object[2]; >>> forwardObj[0] = kingdom_concept_id+1; >>> forwardObj[1] = phylum_concept_id+1; >>> forward(forwardObj); >>> } >>> >>> /** >>> * @see >>> org.apache.hadoop.hive.ql.udf.generic.GenericUDTF#initialize(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector[]) >>> */ >>> �...@override >>> public StructObjectInspector initialize(ObjectInspector[] arg0) >>> throws UDFArgumentException { >>> ArrayList<String> fieldNames = new ArrayList<String>(); >>> ArrayList<ObjectInspector> fieldOIs = new >>> ArrayList<ObjectInspector>(); >>> fieldNames.add("kingdom_concept_id"); >>> fieldNames.add("phylum_concept_id"); >>> >>> fieldOIs.add(PrimitiveObjectInspectorFactory.javaIntObjectInspector); >>> >>> fieldOIs.add(PrimitiveObjectInspectorFactory.javaIntObjectInspector); >>> return >>> ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames,fieldOIs); >>> } >>> >>> /** >>> * @see >>> org.apache.hadoop.hive.ql.udf.generic.GenericUDTF#process(java.lang.Object[]) >>> */ >>> �...@override >>> public void process(Object[] args) throws HiveException { >>> kingdom_concept_id = (Integer) args[0]; >>> phylum_concept_id = (Integer) args[1]; >>> } >>> } >> >> >