Executing "COPY" command gives an error

16 views
Skip to first unread message

Sami Merilä

unread,
Oct 17, 2024, 4:12:51 AM10/17/24
to DataStax Node.js Driver for Apache Cassandra Mailing List
Hi, 

Seems that I can run DDLs nicely with the driver ("ALTER KEYSPACE ..."). 
But trying to run a COPY command through NodeJs driver results in:

const err = new errors.ResponseError(code, message);
^
ResponseError: line 1:0 no viable alternative at input 'COPY' ([COPY]...)
at FrameReader.readError (/vagrant/newDriverProject/node_modules/cassandra-driver/lib/readers.js:389:17)
at Parser.parseBody (/vagrant/newDriverProject/node_modules/cassandra-driver/lib/streams.js:209:66)
at Parser._transform (/vagrant/newDriverProject/node_modules/cassandra-driver/lib/streams.js:152:10)
at Parser.Transform._write (node:internal/streams/transform:205:23)
at writeOrBuffer (node:internal/streams/writable:391:12)
at _write (node:internal/streams/writable:332:10)
at Parser.Writable.write (node:internal/streams/writable:336:10)
at Protocol.ondata (node:internal/streams/readable:754:22)
at Protocol.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:315:12) {
info: 'Represents an error message from the server',
code: 8192,
coordinator: '10.255.1.101:9042',
query: "COPY my.table TO '/tmp/output.csv' WITH HEADER = TRUE;"

It looks as if driver does not recognise COPY as a valid command at all (just replace COPY with 'tadaa' and you'll get the same call stack). 
Should it be supported?

Cheers,
Sami

Bret McGuire

unread,
Oct 17, 2024, 10:32:29 AM10/17/24
to DataStax Node.js Driver for Apache Cassandra Mailing List, Sami Merilä
   Hey Sami, thanks for the question!

   The "COPY" command used by cqlsh is actually implemented within cqlsh itself; it isn't part of the the CQL language supported by the server.  That's why you're getting the error you're getting; the server just doesn't know what to do with a query like "COPY my.table TO '/tmp/output.csv' WITH HEADER = TRUE".

   It's worth pointing out that the exact same thing applies to the DESCRIBE command.

   Thanks again!

    - Bret -

Sami Merilä

unread,
Oct 18, 2024, 2:21:17 AM10/18/24
to DataStax Node.js Driver for Apache Cassandra Mailing List, Bret McGuire, Sami Merilä
Makes sense. Thanks Bret.
Reply all
Reply to author
Forward
0 new messages