-Re: Hive struct
Stephen Sprague 2013-05-03, 18:21
ok. i'll bite.
when you say "struct" do you mean that literally? if so then you know the
first and last elements _by definition_. so that's easy and i presume you
can solve that.
other than that if you mean "map" or "array" i think you're not going to do
it in native hive. For this I'd personally recommend looking at the
transform() function. Its your back-door to do all sorts of wild and crazy
things that you can dream up.
That said there's not whole lot of collection functions i see listed in the
hive udf page. maybe some day those'll get a refresh.
keep in mind this is all my 2 cents only. ymmv.
On Thu, May 2, 2013 at 9:28 PM, abhishek <[EMAIL PROTECTED]> wrote:
> hi all,
> Please share your view on how can I do this
> i have query in hive where one column is struct(1 to n strings),second
> column is string
> i want to compare struct of first and last element with second column
> string, if first element matches i should get output first or last element
> matches with the second column then I should get last anything else should
> be null or 0
> column 1 | column 2
> <a,b,c,d> | a
> <w,x,y,z> | z
> <p,w,r,s> | w
> I want to print this table as
> column 1 | column 2 | column 3
> <a,b,c,d> | a | first
> <w,x,y,z> | z | second
> <p,w,r,s> | w | null or 0