I'm using drill in embedded mode, and I can't figure out how to save query output other than copy and pasting it.
标签:
apache-drill
相关问题
- Apache Drill connection through Java
- Is it possible to read and write Parquet using Jav
- Apache Drill using Google Cloud Storage
- How to create connection in storage plugin of Apac
- Creating Storage Plugin throught through C# code i
相关文章
- Is it possible to read and write Parquet using Jav
- Apache Drill using Google Cloud Storage
- How to create connection in storage plugin of Apac
- Creating Storage Plugin throught through C# code i
- Can't create Drill storage plugin for oracle
- Making storage plugin on Apache Drill to HDFS
- How to use apache drill do page search
- In Apache drill, query to find the Nth occurrence
If you're using sqlline, you can create a new table as CSV as follows:
Your CSV file(s) will appear in /tmp/my_output.
UPDATE: REDIRECTING APACHE DRILL SHELL OUTPUT TO A CSV FILE
It's now early 2018, and for some of you (particularly Apache Drill in MAPR), the above commands DON'T work. If that's the case, try the following. As of 2018 03 02 this DOES work on MapR 5.2 and Mapr 6 :-)
NOTE: I'm using "//" to denote comments alongside actual commands...
NOTE: I'm using "=>" to denote the RESPONSE of the shell to the command...
//FROM INSIDE A DRILL SHELL (ie "SQLLINE")...
//first set the "outputformat" session (shell) variables...
=> you see some output from the shell echoing back the new value...
//next begin "recording" any output to a file...
=> again you see some output from the shell echoing that "recording" is ON...
//next actually submit (say) a SELECT query, whose output will now be CSV (even to the screen), as opposed to "TABLE" format...
=> output (formatted as CSV) will begin streaming to both the screen and the file you specified...
//finally you turn OFF the "recording", so the csv file closes...
THAT'S IT - you're DONE ! :-) Now you can either process that CSV where it lies in the CLUSTER storage, or - if you have a need - TRANSFER that file OUT of the cluster and into (say) some other server that has Tableau, Kabana, PowerBI Desktop or some other visualization tools for further analysis.
If you are using SQLLINE use !record .
If you are using a set of queries, you need to specify the exact schema to use. This can be done using th Use schema command. Unfortunately, you must also not use your root schema. Ensure that you have created the correct directory on your file system and use the proper storage configuration as well. An example configuration is below. After this, you can create a csv via java using the SQL driver, or in a tool such as Pentaho to generate a CSV. With the proper specification, it is possible to use the REST query tool at localhost:8047/query as well. The query to produce a csv at /out/data/csv is below after the configuration example.
Storage Configuration
Query
This will produce at least one CSV and possibly many with different header specifications at /out/data/csv/mycsv_out.
Each file should follow the following format:
Note: While the query result can be read as a single CSV the resulting CSVs (if there are more than one) cannot as the number of headers will vary. Drop the file as a Json file and read with code or later with Drill or another tool if this is the case.
You can specify
!record <file_path>
to save all output to particular file. Drill docs