[
https://issues.apache.org/jira/browse/CASSANDRA-21131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18053744#comment-18053744
]
Jens Geyer commented on CASSANDRA-21131:
----------------------------------------
PS: also note the error messagwes at import:
{code}
Failed to import 3 rows: ParseError - Invalid row length 0 should be 3, given
up without retries
Failed to process 3 rows; failed rows written to import_cycling_cyclist_name.err
{code}
These are very likely caused by the two additional empty lines in the file.
[^cyclist.csv]
> CSV Export and Import changes data unexpectedly
> -----------------------------------------------
>
> Key: CASSANDRA-21131
> URL: https://issues.apache.org/jira/browse/CASSANDRA-21131
> Project: Apache Cassandra
> Issue Type: Bug
> Reporter: Jens Geyer
> Priority: Normal
> Attachments: console.txt, cyclist.csv
>
>
> I'm following the example gine at the docs, just slightly changed:
> https://docs.datastax.com/en/cql-oss/3.x/cql/cql_reference/cqlshCopy.html
> {code}
> CREATE KEYSPACE cycling WITH REPLICATION = { 'class' :
> 'NetworkTopologyStrategy', 'datacenter1' : 1 } ;
> CREATE TABLE cycling.cyclist_name ( id UUID PRIMARY KEY, lastname text,
> firstname text ) ;
> INSERT INTO cycling.cyclist_name (id, lastname, firstname)
> VALUES (5b6962dd-3f90-4c93-8f61-eabfa4a803e2, 'VOS','Marianne');
> INSERT INTO cycling.cyclist_name (id, lastname, firstname)
> VALUES (88888888-8888-8888-8888-888888888888, 'V\S','\"Marianne"\');
> SELECT * FROM cycling.cyclist_name ;
> {code}
> This gives:
> {code}
> id | firstname | lastname
> --------------------------------------+----------------+----------
> 5b6962dd-3f90-4c93-8f61-eabfa4a803e2 | Marianne | VOS
> 88888888-8888-8888-8888-888888888888 | \\"Marianne"\\ | V\\S
> (2 rows)
> {code}
> Now export to a file, then import from the very same file:
> {code}
> COPY cycling.cyclist_name TO 'cyclist.csv' WITH HEADER = TRUE ;
> TRUNCATE cycling.cyclist_name ;
> COPY cycling.cyclist_name FROM 'cyclist.csv' WITH HEADER = TRUE ;
> SELECT * FROM cycling.cyclist_name ;
> {code}
> Now the result is this:
> {code}
> id | firstname | lastname
> --------------------------------------+--------------------+----------
> 5b6962dd-3f90-4c93-8f61-eabfa4a803e2 | Marianne | VOS
> 88888888-8888-8888-8888-888888888888 | \\\\"Marianne"\\\\ | V\\\\S
> (2 rows)
> {code}
> I did not change any data in between. Just export and reimport.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]