How do I output the results of a HiveQL query to CSV?

前端 未结 18 1690
独厮守ぢ
独厮守ぢ 2020-11-27 10:11

we would like to put the results of a Hive query to a CSV file. I thought the command should look like this:

insert overwrite directory \'/home/output.csv\'          


        
18条回答
  •  眼角桃花
    2020-11-27 10:55

    hive  --outputformat=csv2 -e "select * from yourtable" > my_file.csv
    

    or

    hive  --outputformat=csv2 -e "select * from yourtable" > [your_path]/file_name.csv
    

    For tsv, just change csv to tsv in the above queries and run your queries

提交回复
热议问题