Summary
This article provides a solution for failed cqlsh COPY
command as a result of a custom time format feature enhancement.
Symptoms
An attempt to copy a table in cqlsh
fails as the following example illustrates:
cqlsh> COPY music.songs (title, year, artist) TO 'songs.csv' ;
Shell instance has no attribute 'display_timestamp_format'
Cause
The issue is related to the new TIME_FORMAT option for the COPY
command introduced by CASSANDRA-8970.
The feature was originally implemented in Cassandra 2.2 and 3.0, then backported to Cassandra 2.1 with a defect which ended up affecting the Cassandra versions which shipped with DataStax Enterprise 4.7.4 and 4.8.1.
Workaround
The defect was fixed by CASSANDRA-10633 which was shipped in DSE versions 4.7.6 and 4.8.3.
In order to copy the data without upgrading DSE, follow these steps:
Step 1 - Download the DSE tarball version 4.7.6 or 4.8.3 (or newer) on your workstation. For example, dse-4.8.3-bin.tar.gz.
Step 2 - Unpack the tarball.
Step 3 - On the workstation or server where you are running the COPY
command, move the existing copy of the cqlsh
file to a temporary location.
Step 4 - Copy the file bin/cqlsh
from your workstation to the machine where you are running the COPY
command.
NOTE - It is only necessary to update the workstation or server where you intend to run the COPY
command.
Step 5 - Run the COPY
command in cqlsh
as before.
Solution
As stated above, the fix was incorporated in the latest versions of DataStax Enterprise so upgrade as appropriate.
See also
DSE doc - cqlsh COPY
Cassandra JIRA - CASSANDRA-8970 Allow custom time_format on cqlsh COPY TO
Cassandra JIRA - CASSANDRA-10633 cqlsh copy uses wrong variable name for time_format