Grokbase Groups Hive user June 2010
FAQ
Hi,

I am trying to explode or lateral view on a list that is returned by
get_jsonb_object, something along these lines:

select explode(get_json_object(jsonblob, '$.output_dict.articles.url'))
as url from sometable;

I get:
FAILED: Error in semantic analysis: explode() takes an array as a
parameter

The trick is that what get_json_object returns is an array (or is it a
string representation of an array?)


a) how to do it?

b) any chance for explode to produce enumeration too (so I'd get two
variables out of each entry - url and position)


--
Andraz Tori, CTO
Zemanta Ltd, New York, London, Ljubljana
www.zemanta.com
mail: andraz@zemanta.com
tel: +1 415 937 1 936 +386 41 515 767
twitter: andraz, skype: minmax_test

Search Discussions

  • Andraz Tori at Jun 30, 2010 at 4:03 pm
    Hi,

    I am trying to explode or lateral view on a list that is returned by
    get_jsonb_object, something along these lines:

    select explode(get_json_object(jsonblob, '$.output_dict.articles.url'))
    as url from sometable;

    I get:
    FAILED: Error in semantic analysis: explode() takes an array as a
    parameter

    The trick is that what get_json_object returns is an array (or is it a
    string representation of an array?)


    a) how to do it?

    b) any chance for explode to produce enumeration too (so I'd get two
    variables out of each entry - url and position)


    [I hope this is not a duplicate message, mail program trouble]

    --
    Andraz Tori, CTO
    Zemanta Ltd, New York, London, Ljubljana
    www.zemanta.com
    mail: andraz@zemanta.com
    tel: +1 415 937 1 936 +386 41 515 767
    twitter: andraz, skype: minmax_test
  • Paul Yang at Jun 30, 2010 at 6:17 pm
    Hi Andraz,

    get_json_object() will return the string representation of a array. One way to converting this to a list is use regexp_replace() to get rid of '[' and ']' and then call split() using ',' to get an array.

    Enumeration is a little bit tricky. One way is to use field() on the array to get the position of each exploded string. But field() may be broken at the moment. Viraj on the mailing list was looking to do the same thing as well.

    Cheers,
    Paul
    -----Original Message-----
    From: Andraz Tori
    Sent: Wednesday, June 30, 2010 9:02 AM
    To: hive-user@hadoop.apache.org
    Subject: using get_json_object with explode/lateral view

    Hi,

    I am trying to explode or lateral view on a list that is returned by
    get_jsonb_object, something along these lines:

    select explode(get_json_object(jsonblob, '$.output_dict.articles.url'))
    as url from sometable;

    I get:
    FAILED: Error in semantic analysis: explode() takes an array as a
    parameter

    The trick is that what get_json_object returns is an array (or is it a
    string representation of an array?)


    a) how to do it?

    b) any chance for explode to produce enumeration too (so I'd get two
    variables out of each entry - url and position)


    [I hope this is not a duplicate message, mail program trouble]

    --
    Andraz Tori, CTO
    Zemanta Ltd, New York, London, Ljubljana
    www.zemanta.com
    mail: andraz@zemanta.com
    tel: +1 415 937 1 936 +386 41 515 767
    twitter: andraz, skype: minmax_test

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categorieshive, hadoop
postedJun 30, '10 at 3:57p
activeJun 30, '10 at 6:17p
posts3
users2
websitehive.apache.org

2 users in discussion

Andraz Tori: 2 posts Paul Yang: 1 post

People

Translate

site design / logo © 2021 Grokbase