Apache Cassandra COPY FROM, datetime entered incorrectly

Author: Vipin Jain

Originally Sourced from: https://stackoverflow.com/questions/59424759/apache-cassandra-copy-from-datetime-entered-incorrectly

I can see a strange issue with COPY FROM command in Cassandra with datetime values.

My timezone and my server's timezone is same. IST (GMT+5:30)

First i tried inserting a value with INSERT query.

INSERT INTO activity (home_id, datetime, event, code_used) VALUES ('H01474777', '2014-05-21 07:32:16', 'alarm set', '5599');

It gave me the below row.

 home_id   | datetime                        | code_used | event
-----------+---------------------------------+-----------+-----------
 H01474777 | 2014-05-21 02:02:16.000000+0000 |      5599 | alarm set

Here Cassandra is showing the time value in GMT by removing +5:30

But when i tried to insert the below via the COPY FROM command and you can see that it added +5:30 when showing the GMT value, its like when adding the row it added 11 hours to the time. See file, query and output below respectively.

home_id|datetime|event|code_used
H02257222|2014-05-21 05:29:47|alarm set|1566
H01474777|2014-05-21 07:32:16|alarm set|5599

Query:

COPY activity (home_id, datetime, event, code_used) FROM '/home/cass/events.csv' WITH HEADER = TRUE AND DELIMITER = '|';

Result:

 home_id   | datetime                        | code_used | event
-----------+---------------------------------+-----------+-----------
 H01474777 | 2014-05-21 13:02:16.000000+0000 |      5599 | alarm set
 H01474777 | 2014-05-21 02:02:16.000000+0000 |      5599 | alarm set --Old row from insert query.
 H02257222 | 2014-05-21 10:59:47.000000+0000 |      1566 | alarm set

Here the first 2 rows are same data and the first 2 columns of the table are primary key but still another row has been created where as there should have been 2 rows only.