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 DE05217A3A for ; Wed, 22 Apr 2015 14:31:08 +0000 (UTC) Received: (qmail 41369 invoked by uid 500); 22 Apr 2015 14:30:59 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 41328 invoked by uid 500); 22 Apr 2015 14:30:59 -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 41316 invoked by uid 99); 22 Apr 2015 14:30:59 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Apr 2015 14:30:59 +0000 Date: Wed, 22 Apr 2015 14:30:59 +0000 (UTC) From: "Stefania (JIRA)" To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CASSANDRA-9217) Error in cqlsh COPY TO 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-9217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14507165#comment-14507165 ] Stefania commented on CASSANDRA-9217: ------------------------------------- I see, thanks. > Error in cqlsh COPY TO > ---------------------- > > Key: CASSANDRA-9217 > URL: https://issues.apache.org/jira/browse/CASSANDRA-9217 > Project: Cassandra > Issue Type: Bug > Reporter: Brian Cantoni > Assignee: Tyler Hobbs > Labels: cqlsh > Fix For: 2.1.5 > > Attachments: 9217-2.1.txt > > > On the current 2.1 branch I notice a few (possibly related) problems with cqlsh copy commands. I'm writing them here together but we can separate if there are different causes. > *1. Cannot import from CSV if column name is 'date'* > Test file monthly.csv contents: > {noformat} > stationid,metric,date > LAE,barometricpressure,2014-01-01 00:00:00+0000 > LAE,barometricpressure,2014-02-01 00:00:00+0000 > LAE,barometricpressure,2014-03-01 00:00:00+0000 > {noformat} > Steps: > {noformat} > CREATE KEYSPACE IF NOT EXISTS weathercql WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '1' }; > CREATE TABLE IF NOT EXISTS weathercql.monthly ( > stationid text, > metric text, > date timestamp, > primary key (stationid, metric, date) > ); > COPY weathercql.monthly (stationid, metric, date) FROM 'monthly.csv' WITH HEADER='true'; > {noformat} > Result: the copy command fails unless date is enclosed in double quotes: > {noformat} > cqlsh> COPY weathercql.monthly (stationid, metric, date) FROM 'monthly.csv' WITH HEADER='true'; > Improper COPY command. > cqlsh> COPY weathercql.monthly (stationid, metric, "date") FROM 'monthly.csv' WITH HEADER='true'; > 3 rows imported in 0.096 seconds. > {noformat} > If I instead name the 'date' column as 'datex', it works without quotes. > The same steps work on Cassandra 2.1.4 (release build). > *2. Cannot copy to CSV* > Sample data: > {noformat} > create keyspace if not exists test with replication = {'class':'SimpleStrategy', 'replication_factor':1}; > create table if not exists test.kv (key int primary key, value text); > insert into test.kv (key,value) values (1,'alpha'); > insert into test.kv (key,value) values (2,'beta'); > insert into test.kv (key,value) values (3,'charlie'); > {noformat} > When you try to export to CSV, it throws what appears to be a Python error, and the file is not created correctly: > {noformat} > cqlsh> copy test.kv (key,value) to 'test.csv'; > global name 'meter' is not defined > {noformat} > The same steps work on Cassandra 2.1.4 (release build). > *3. Copy from CSV inside CQL command file doesn't work* > File kv.csv: > {noformat} > key,value > 1,'a' > 2,'b' > 3,'c' > {noformat} > File kv.cql: > {noformat} > create keyspace if not exists test with replication = {'class': 'SimpleStrategy', 'replication_factor':1}; > create table if not exists test.kv (key int primary key, value text); > truncate test.kv; > copy test.kv (key, value) from 'kv.csv' with header='true'; > select * from test.kv; > {noformat} > When command file passed to cqlsh, an error is reported on the `copy` command and it doesn't work: > {noformat} > $ bin/cqlsh -f kv.cql > kv.cql:5:descriptor 'lower' requires a 'str' object but received a 'unicode' > key | value > -----+------- > (0 rows) > {noformat} > The same commands work correctly when run directly inside cqlsh or when executed with -e option like: {{bin/cqlsh -e "copy test.kv (key, value) from 'kv.csv' with header='true';"}}. > This third issue appears to also be broken in 2.1.4 and 2.1.3 release builds, but works in 2.1.2. -- This message was sent by Atlassian JIRA (v6.3.4#6332)