Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

presto-cli: csv output without quotes #8845

Closed
shigemk2 opened this issue Aug 26, 2017 · 6 comments
Closed

presto-cli: csv output without quotes #8845

shigemk2 opened this issue Aug 26, 2017 · 6 comments
Labels

Comments

@shigemk2
Copy link

When using presto-cli with csv output option, it results data with double quotes.

$ presto --server example:8889 --catalog hive --schema default --file sample.sql --output-format CSV
"1000","mix","test"
"1","mix2","fs"
"2","mix3","test"
"33","fromscratch","mi"
"333","bdash","aaa"

But I need csv results without double quotes.

$ presto --server example:8889 --catalog hive --schema default --file sample.sql --output-format CSV
1000,mix,test
1,mix2,fs
2,mix3,test
33,fromscratch,mi
333,bdash,aaa

According to RFC 4180, field data may or may not be enclosed in double quotes. https://tools.ietf.org/html/rfc4180

So, I need to create new output-format options.

  • CSV(default output-format option)
  • CSV_HEADER
  • CSV_WITHOUT_QUOTES
  • CSV_HEADER_WITHOUT_QUOTES
@amarcum
Copy link

amarcum commented Nov 14, 2017

+1
I am also looking for this functionality in a file export that I am doing.

@zsaltys
Copy link

zsaltys commented Dec 28, 2017

+1

@leoChaoGlut
Copy link

leoChaoGlut commented Jan 31, 2018

The solution is as follows:

  1. com.facebook.presto.cli.Query.createOutputPrinter(OutputFormat format, Writer writer, List<String>
  2. au.com.bytecode.opencsv.CSVWriter.CSVWriter(Writer writer, char separator)
  3. au.com.bytecode.opencsv.CSVWriter.writeNext(String[] nextLine)

@ebyhr
Copy link
Contributor

ebyhr commented Mar 5, 2018

Implemented as an experiment. I will send PR later.

ebyhr$ presto-cli/target/presto-cli-0.197-SNAPSHOT-executable.jar -f select.txt --output-format CSV_WITHOUT_QUOTES
1,1,1
ebyhr$ 
ebyhr$ presto-cli/target/presto-cli-0.197-SNAPSHOT-executable.jar -f select.txt --output-format CSV_HEADER_WITHOUT_QUOTES
c1,c2,c3
1,1,1

@ebyhr
Copy link
Contributor

ebyhr commented Mar 5, 2019

The PR was merged into trinodb/trino#319
The new option names are CSV_UNQUOTED and CSV_HEADER_UNQUOTED. It will be release on version 305.

@stale
Copy link

stale bot commented Jun 23, 2021

This issue has been automatically marked as stale because it has not had any activity in the last 2 years. If you feel that this issue is important, just comment and the stale tag will be removed; otherwise it will be closed in 7 days. This is an attempt to ensure that our open issues remain valuable and relevant so that we can keep track of what needs to be done and prioritize the right things.

@stale stale bot added the stale label Jun 23, 2021
@stale stale bot closed this as completed Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants