3
votes

Can you export a hive query result into parquet file formats? I can export results as a tsv like this:

INSERT OVERWRITE DIRECTORY '/home/user/events'
row format delimited 
fields terminated by '\t'

but how do I tell it to do it in parquet format?

3

3 Answers

8
votes

insert overwrite directory 'EXTERNAL_DIRECTORY' STORED AS PARQUET select * from SOURCE_TABLE_NAME;

1
votes

Use the below approach

create table parque_table (

) ROW FORMAT SERDE 'parquet.hive.serde.ParquetHiveSerDe' STORED AS INPUTFORMAT "parquet.hive.DeprecatedParquetInputFormat" OUTPUTFORMAT "parquet.hive.DeprecatedParquetOutputFormat" LOCATION '${hiveconf:hive_location}';

INSERT OVERWRITE TABLE parque_table select from othertable

0
votes

First you need to create one table with the schema of your results in hive stored as parquet. After getting the results you can export them into the parquet file format table like this

insert into table parquet_file_table_name select * from table_name_containing_results

For more information you can refer to the below link

https://acadgild.com/blog/parquet-file-format-hadoop/