You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Software Dev <st...@gmail.com> on 2014/02/20 20:09:49 UTC

Output Avro result as JSON

When I run a query in the hive shell for an Avro field it displays it as
json. How can I accomplish then when saving to a file?

Re: Output Avro result as JSON

Posted by Andrew Mains <an...@kontagent.com>.
One method could be to either create a custom table off of a query with 
a JSON serde (for instance, I've used 
https://github.com/rcongiu/Hive-JSON-Serde).

Something like:

CREATE EXTERNAL TABLE my_tmp_table
ROW  FORMAT  SERDE  'org.openx.data.jsonserde.JsonSerDe'
STORED  AS  TEXTFILE
LOCATION '/path/to/file'
AS
<query>


In versions of hive later than 0.10 (which is what we're using), I 
believe that you may be able to do a similar thing with INSERT 
OVERWRITE, but I'm not
sure whether it works with custom serdes (as opposed to custom 
delimiters). See https://issues.apache.org/jira/browse/HIVE-3682.

Hope this helps!

Andrew

On 2/20/14, 11:09 AM, Software Dev wrote:
> When I run a query in the hive shell for an Avro field it displays it 
> as json. How can I accomplish then when saving to a file?