Write Drill query output to csv (or some other format)

Kevin picture Kevin · Jun 24, 2015 · Viewed 9.7k times · Source

I'm using drill in embedded mode, and I can't figure out how to save query output other than copy and pasting it.

Answer

Vince Gonzalez picture Vince Gonzalez · Jun 29, 2015

If you're using sqlline, you can create a new table as CSV as follows:

use dfs.tmp; 
alter session set `store.format`='csv';
create table dfs.tmp.my_output as select * from cp.`employee.json`;

Your CSV file(s) will appear in /tmp/my_output.