Cassandra data loading sequence for columns disabling

315 Views Asked by At

I am new to cassandra. I created the below cassandra table with primary keys.

Create table Query:

create table DB.EMP(
Name    text,
age       int,
id  int,
loc  text,
salary     double,
PRIMARY KEY (id,salary)
);

I loaded above table with below data using command:

Command ::: copy emp from '/home/data' with delimiter=',';

Data ::: /home/data 

"Sdd,25,123,Chennai,28000" 

I am getting this error:

Using 1 child processes

Starting copy of pmm.emp with columns ['id', 'salary', 'age', 'loc', 'name'].
Failed to import 1 rows: ParseError - invalid literal for int() with base 10: 'Sdd' -  given up without retries
Failed to process 1 rows; failed rows written to import_db_emp.err
Processed: 0 rows; Rate:       0 rows/s; Avg. rate:       0 rows/s
0 rows imported from 1 files in 0.170 seconds (0 skipped).

Please suggest how can I load the data.

Is there any way I can disable , alphabetical order insertion option except primary keys.

1

There are 1 best solutions below

0
On

Is there any way I can disable, alphabetical order insertion option except primary keys?

No. Cassandra stores the column names that way to ensure proper on-disk order.

An easy solution would be to specify your column order in your COPY command:

aploetz@cqlsh:stackoverflow> COPY emp (name,age,id,loc,salary) 
                               FROM '/home/aploetz/data.txt' WITH DELIMITER=',';

Reading options from the command line: {'delimiter': ','}
Using 1 child processes

Starting copy of stackoverflow.emp with columns [name, age, id, loc, salary].
Processed: 1 rows; Rate:       0 rows/s; Avg. rate:       1 rows/s
1 rows imported from 1 files in 1.919 seconds (0 skipped).