Hi,
Can we get an option to save results from interactive mode to a file?
e.g. "SELECT * FROM temp_table FORMAT CSV TOFILE '~/results.csv'"
Probably
SELECT * FROM temp_table FORMAT CSV INTO OUTFILE '~/results.csv'
(for those who familiar with MySQL)
It will be client only option; client will send query to server without this modifier, receive result and write to outfile. If server will receive query with INTO OUTFILE, that was sent directly, it will understand syntax, but throw an exception. (Also possible to allow server to write data to local filesystem, but need special respect to some security considerations.)
Client only option will be great! Thanks
Maybe we need to place INTO OUTFILE before FORMAT.
SELECT * FROM temp_table INTO OUTFILE '~/results.csv' FORMAT CSV
Because maybe we later would like to add support for something like FROM FILE for INSERT query, and in INSERT query, everything after FORMAT section is parsed as data for insertion by separate parser, so in INSERTs, FORMAT must be last.
I don't think INTO OUTFILE before FORMAT is necessary as INTO is already a keyword in INSERT so you can't use it twice, moreover I can't think of a scenario where you insert data to a database and also output that to a file.
I mean different thing.
If we have an option to run clickhouse-client interactively, and then save query result to file,
than, for symmetry,
we also would like to have an option to run clickhouse-client interactively, and then use a file to read as source of data for INSERT query.
okay then the INTO OUTFILE before FORMAT will work as well.
in stable now
Most helpful comment
Maybe we need to place
INTO OUTFILEbeforeFORMAT.SELECT * FROM temp_table INTO OUTFILE '~/results.csv' FORMAT CSVBecause maybe we later would like to add support for something like
FROM FILEforINSERTquery, and inINSERTquery, everything afterFORMATsection is parsed as data for insertion by separate parser, so inINSERTs,FORMATmust be last.