custom cassandra / cqlsh time_format

半城伤御伤魂 提交于 2019-12-10 18:46:00

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!