Skip to main content
snm1523
Gold ⭐️⭐️
Jun 8, 2023 6:29 AM UTC
Solved

Change input and output format of existing hive table

Hi,

 

How do we change the InputFormat and OutputFormat of an existing Hive table?

 

I tried below, but got an error:

alter table <table name> SET InputFormat "org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat";

 

Error:

Cannot recognize input near 'SET' 'InputFormat' 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'

 

Kindly suggest

smruti
smrutiAnswer
Gold ⭐️⭐️⭐️
Jun 9, 2023 12:36 PM UTC

@snm1523 It should be SET FILEFORMAT INPUTFORMAT... Please try it as follows.

ALTER TABLE alter_file_format_test SET FILEFORMAT INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe';

2 replies

smruti
Gold ⭐️⭐️⭐️
smrutiAnswer
Gold ⭐️⭐️⭐️
Jun 9, 2023 12:36 PM UTC

@snm1523 It should be SET FILEFORMAT INPUTFORMAT... Please try it as follows.

ALTER TABLE alter_file_format_test SET FILEFORMAT INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe';
Translate
snm1523
snm1523Author
Gold ⭐️⭐️
Jun 9, 2023 12:53 PM UTC

@smruti - thank you for the response

Translate