cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brandon Williams (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CASSANDRA-7407) COPY command does not work properly with collections causing failure to import data
Date Thu, 19 Jun 2014 12:59:24 GMT

     [ https://issues.apache.org/jira/browse/CASSANDRA-7407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Brandon Williams updated CASSANDRA-7407:
----------------------------------------

         Reviewer: Brandon Williams  (was: Aleksey Yeschenko)
    Reproduced In: 2.0.7, 1.2.16  (was: 1.2.16, 2.0.7)
    Fix Version/s: 2.1 rc2
           Labels:   (was: patch)

+1

> COPY command does not work properly with collections causing failure to import data
> -----------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-7407
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-7407
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>         Environment: cqlsh 4.1.1, 
> Cassandra 2.0.7.31,
> CQL spec 3.1.1,
> Thrift protocol 19.39.0
>            Reporter: Jose Martinez Poblete
>            Assignee: Mikhail Stepura
>             Fix For: 1.2.17, 2.0.9, 2.1 rc2
>
>         Attachments: CASSANDRA-1.2-7407.patch
>
>
> The COPY command does not properly format collections in the output CSV - to be able
to re-import the data.
> Here is how you can replicate the problem:
> {noformat}
> CREATE TABLE user_colors ( 
> user_id int PRIMARY KEY, 
> colors list<ascii> 
> );
> UPDATE user_colors SET colors = ['red','blue'] WHERE user_id=5; 
> UPDATE user_colors SET colors = ['purple','yellow'] WHERE user_id=6; 
> UPDATE user_colors SET colors = ['black''] WHERE user_id=7;
> COPY user_colors (user_id, colors) TO 'output.csv';
> CREATE TABLE user_colors2 ( 
> user_id int PRIMARY KEY, 
> colors list<ascii> 
> );
> COPY user_colors2 (user_id, colors ) FROM 'user_colors.csv';
> Bad Request: line 1:68 no viable alternative at input ']'
> Aborting import at record #0 (line 1). Previously-inserted values still present.
> 0 rows imported in 0.007 seconds.
> {noformat}
> The CSV file seems to be malformed
> - The single quotes within the collection are missing
> - The double quotes for collection on user_id=7 are missing and causing COPY to fail.
> {noformat}
> 5,"[red, blue]"
> 7,[black]
> 6,"[purple, yellow]"
> {noformat}
> Should be like this
> {noformat}
> 5,"['red', 'blue']"
> 7,"['black']"
> 6,"['purple', 'yellow']"
> {noformat}
> Once the file is changed, the import works
> {noformat}
> COPY user_colors2 (user_id, colors ) FROM 'user_colors.csv';
> 3 rows imported in 0.012 seconds.
> SELECT * FROM user_colors2;
>  user_id | colors
> ---------+------------------
>        5 |      [red, blue]
>        7 |          [black]
>        6 | [purple, yellow]
> (3 rows)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message