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

前端 未结 18 1679
独厮守ぢ
独厮守ぢ 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 11:01

    If you want a CSV file then you can modify Lukas' solutions as follows (assuming you are on a linux box):

    hive -e 'select books from table' | sed 's/[[:space:]]\+/,/g' > /home/lvermeer/temp.csv
    

提交回复
热议问题