Search code examples
csvcassandraexportexport-to-csv

Exporting Data from Cassandra to CSV file


Table Name : Product

uid                                  | productcount | term                 | timestamp

304ad5ac-4b6d-4025-b4ea-8b7991a3fe72 |           26 |                dress | 1433110980000
6097e226-35b5-4f71-b158-a1fe39a430c1 |            0 |              #751104 | 1433861040000

Command :

COPY product (uid, productcount, term, timestamp) TO 'temp.csv';

Error:

Improper COPY command.

Am I missing something?


Solution

  • The syntax of your original COPY command is also fine. The problem is with your column named timestamp, which is a data type and is a reserved word in this context. For this reason you need to escape your column name as follows:

    COPY product (uid, productcount, term, "timestamp") TO 'temp.csv';
    

    Even better, try to use a different field name, because this can cause other problems as well.