I want to export the output of an SQL query into a csv file.
HADOOP_CLIENT_OPTS="-Ddisable.quoting.for.sv=false -Dfile.encoding=UTF-8" beeline -u $JDBC_URL --silent=true --outputformat=dsv --delimiterForDSV=';' --verbose=false --hiveconf hive.query.tag=${tag} -f query.sql > output.csv
The query might output string values with new line characters '\n' (i.e. multiple lines values), but all these new line characters are missing in the output .csv file.
When I set disable.quoting.for.sv=true, it keeps the new line characters, but the output file has a bad .csv format as the csv delimiters are not escaped.
It seems like enabling quoting for separated values removes all new line characters '\n'.
Is there a way to output a valid .csv file and still get all the new line characters in it ?
What my .csv output looks like :
| col1 | col2 | col3 |
|---|---|---|
| val1 | "This is; a line.Another line" | val2 |
| val3 | "Hi" | val4 |
What I want :
| col1 | col2 | col3 |
|---|---|---|
| val1 | "This is; a line. Another line" |
val2 |
| val3 | "Hi" | val4 |
Note: the SQL query outputs "This is a line.\nAnother line"