Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0E16611A24 for ; Tue, 17 Jun 2014 15:12:09 +0000 (UTC) Received: (qmail 50046 invoked by uid 500); 17 Jun 2014 15:12:08 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 50017 invoked by uid 500); 17 Jun 2014 15:12:08 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 50005 invoked by uid 99); 17 Jun 2014 15:12:08 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jun 2014 15:12:08 +0000 Date: Tue, 17 Jun 2014 15:12:08 +0000 (UTC) From: "Brandon Williams (JIRA)" To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CASSANDRA-7407) COPY command does not work properly with collections causing failure to import data MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CASSANDRA-7407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14033898#comment-14033898 ] Brandon Williams commented on CASSANDRA-7407: --------------------------------------------- I'm not sure I understand the problem here. It sounds like the CSV was malformed, so fix the CSV? > 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 > Labels: 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 > ); > 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 > ); > 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)