How to export the query result in csv format in trino

Viewed 965
--server {servername}:{port} \
--catalog cassandra --schema  {demo} --user admin \
--execute "SELECT * from users" \
--output-format CSV > result.csv

but it is not working giving "mismatched input ''. Expecting: " error

1 Answers

The issue here appears to be related to special characters and quoting. I have changed a couple things in your CLI command below:

  1. Added quotes around "{demo}" due to special characters
  2. Changed query quotes to single quotes
  3. Double quoted the table name within the query (in this example, it might not help, but if there are special characters within the table name it will.)

With all three in place the query should run and export properly. From there, remove parts as necessary to find the one or many that was causing the error.

--server {servername}:{port} \
--catalog cassandra --schema "{demo}" --user admin \
--execute 'SELECT * from "users"' \
--output-format CSV > result.csv
Related