问题
System:
CentOS 6.7 x86_64 cqlsh 5.0.1 | Cassandra 2.2.1 | CQL spec 3.3.0
I'm having problem inserting (copy csv file) timestamp field with the format '%d-%m-%Y %H:%M:%S' ,
This format not supported by default, so I've created it manually in the ~/.cassandra/cqlshrc file:
[ui]
time_format = %d-%m-%Y %H:%M:%S
and started cqlsh again, but I'm still unable to insert:
system@cqlsh> insert into nir.nir_test (END_DATE) values ('01-09-2015 18:55:50');
InvalidRequest: code=2200 [Invalid query] message="Unable to coerce '01-09-2015 18:55:50' to a formatted date (long)"
Any advice?
回答1:
The [ui] configuration in cqlshrc only affects the output format. It gets applied when you query a timestamp column. For example:
select END_DATE from nir.nir_test;
Might output:
end_date
---------------------
01-09-2015 18:55:50
But for insertion, you need to use one of the specified formats. For example:
insert into nir.nir_test (END_DATE) values ('2015-09-01 18:55:50');
This probably means that you'll need to convert the timestamps in the CSV file before trying to insert them.
来源:https://stackoverflow.com/questions/32496272/custom-cassandra-cqlsh-time-format