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

前端 未结 18 1716
独厮守ぢ
独厮守ぢ 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条回答
  •  萌比男神i
    2020-11-27 11:08

    You can use INSERTDIRECTORY …, as in this example:

    INSERT OVERWRITE LOCAL DIRECTORY '/tmp/ca_employees'
    SELECT name, salary, address
    FROM employees
    WHERE se.state = 'CA';
    

    OVERWRITE and LOCAL have the same interpretations as before and paths are interpreted following the usual rules. One or more files will be written to /tmp/ca_employees, depending on the number of reducers invoked.

提交回复
热议问题