5

I am running a bash script to extract data from a table via presto...

./presto --server myprestoserver:8889 --catalog mycatalog --schema myschema --execute "select * from TABLEResultsAuditLog;" > /mydirectory/audit.dat

This command will successfully and extract the table results and send them to the audit.dat file. What I am looking for is to replace the --execute "select * from TABLEResultsAuditLog;" section and have a file located in /mydirectory/audit.sql which would then contain the sql statement which I need executed. I have tried using

./presto --server myprestoserver:8889 --catalog mycatalog --schema myschema < /mydirectory/audit.sql > /mydirectory/audit.dat

where the audit.sql contains the select statement only, but this only populates the audit.dat file with the query statement and not the results. I'm not familiar with bash scripting, so its probably an easy fix for someone!!

Gregoire Ducharme
  • 1,095
  • 12
  • 24
Jason Coleman
  • 51
  • 1
  • 2

1 Answers1

6

Presto CLI has --file option for this purpose:

presto-cli --server ... --file input.sql > output-file
Piotr Findeisen
  • 19,480
  • 2
  • 52
  • 82