cql - Column order when importing CSV into Cassandra with cqlsh -


i'm new cassandra. cql appears ignore column order in create table statement, , order columns primary key first , remaining columns in lexicographic order. understand that's how they're stored internally, coming traditional database perspective, disregarding column order , leaking implementation detail user surprising. documented anywhere?

[cqlsh 4.1.1 | cassandra 2.1.8 | cql spec 3.1.1 | thrift protocol 19.39.0]  cqlsh:test> create table test (c int primary key, b text, int); cqlsh:test> describe table test;  create table test (   c int,   int,   b text,   primary key (c) ) 

that makes difficult import csv file columns in order thought using.

cqlsh:test> copy test stdin; [use \. on line end input] [copy] 1,abc,2 bad request: line 1:44 no viable alternative @ input ',' (... c, b) values ([abc],...) aborting import @ record #0 (line 1). previously-inserted values still present.  0 rows imported in 7.982 seconds.  cqlsh:test> copy test stdin; [use \. on line end input] [copy] 1,2,abc [copy] \.  1 rows imported in 14.911 seconds. 

the solution appears to specify columns in copy statement (or reorder csv data).

copy test (c, b, a) stdin; [use \. on line end input] [copy] 1,abc,2 [copy] \.  1 rows imported in 5.727 seconds. 

you should specify columns wish transact with. never assume column order cassandra, if alter csv file match order it's safer specify exact columns on tables many columns.

cassandra uses column order , specific storage locations make accessing data faster.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -