0
votes

I have a table in Cassandra (cqlsh 5.0.1 | Cassandra 3.5.0):

CREATE TABLE IF NOT EXISTS tytandb.test1

( BS_CUSTOMER_ID INT,

CRM_CUSTOMER_ID INT,

ID INT,

PRIMARY KEY (BS_CUSTOMER_ID) );

And I have a CSV file:

"BS_CUSTOMER_ID","CRM_CUSTOMER_ID","ID"

"1179","4","4"

"1226","122","122"

"1237","161",""

And I am loading this file in CQLSH with this command:

COPY TEST1 (BS_CUSTOMER_ID, CRM_CUSTOMER_ID, ID) FROM 't_customers_13.csv' WITH HEADER = 'true' AND DELIMITER = ',' AND QUOTE = '"' AND NULL = '';

And I am receiving this error message:

Failed to import 1 rows: ParseError - invalid literal for int() with base 10: '', given up without retries

It is the 3rd value (NULL) in the last line that causes the error.

Why I cannot copy NULL (empty value) into an INT column? And what I can do to copy NULL into INT columns?

I have the same problem with TIMESTAMP columns.

With VARCHAR it's OK and I can copy NULL values into VARCHAR columns.

Any ideas?

1
For any NULL column values in your CSV, you might try simply omitting those column names from your CQL INSERT statement entirely. When that particular row is then SELECT (using the column name whose value wasn't added), you should get a NULL value for that row column. - Castaglia
Sounds like a good idea. But I cannot omit any column as almost all of them may contain NULLs in my case. - Paweł Andrzej Hadam

1 Answers