问题描述
我是Cassandra cql的新用户(cqlsh 4.1.1,Cassandra 2.0.8.39,CQL规范3.1.1,Thrift协议19.39.0) - 使用cql COPY命令从CSV格式的文件中的表,我得到以下错误:错误请求:无法将2012/11/11强制转换为格式化的日期(长)
。 如何使用
cql
更改列,以便它接受来自 CSV
文件的日期? Brian说,有一些CQL时间戳类型可以使CQL查询运行,因此有时它看起来很奇怪!几个星期前,我有一个相同的问题,日期时间插入像这样:
INSERT INTO my_table(id,lastvisitdate )VALUES(1682221,'2012-03-25 02:26:04');
我遇到此错误:错误请求:无法强制'2012-03-25 02 :26:04'到格式化的日期(长)! mmmm ...这么糟糕的日期时间似乎是正确的!
经过多次尝试,在坚果之前,我刚刚在时间,Z代表Zulu时间,也是UTC和GMT:
INSERT INTO my_table(id,lastvisitdate)VALUES(1682221, '2012-03-25 02:26:04Z');
Yessss!有用 !所以不要忘记在你的日期时间值的时区,这可能是有帮助的! ; - )
I am new to Cassandra cql (cqlsh 4.1.1, Cassandra 2.0.8.39, CQL spec 3.1.1, Thrift protocol 19.39.0) - using the cql COPY command to a table from a CSV formatted file and I get the following error: Bad Request: unable to coerce '2012/11/11' to a formatted date (long)
.
How do I change a column using cql
so that it accepts the date from my CSV
file?
as Brian said, there are CQL timestamp type to follow to get CQL query running. Sometimes it looks like quite weird indeed ! I've got the same issue few weeks ago with a date time insert like this one :
INSERT INTO my_table (id,lastvisitdate) VALUES (1682221,'2012-03-25 02:26:04');
I got this error : Bad Request: unable to coerce '2012-03-25 02:26:04' to a formatted date (long) ! mmmm... so bad as the date time seems to be correct !
After many tries and before going nuts, I've just added a Z at the end of the time, Z stands for Zulu time which is also UTC and GMT :
INSERT INTO my_table (id,lastvisitdate) VALUES (1682221,'2012-03-25 02:26:04Z');
Yessss ! It works ! So do not forget the timezone in your date time values, it could be helpful ! ;-)
这篇关于无法强制'2012/11/11'格式化日期(长)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!