迄今为止,如何将CQL BIGINT类型转换为?
我使用的是Cassandra,并且有一列数据,该数据代表以bigint
类型存储的Epoch Time毫秒:
request_time bigint
我想将其转换为日期时间对象,以便与某些日子一起使用。我该如何实现这种转换?
我尝试过:
select todate(request_time)
# InvalidRequest: Error from server: code=2200 [Invalid query] message="Input type Int64 is not supported in ToDate."
还有:
select dateof(mintimeuuid(request_time))
# InvalidRequest: Error from server: code=2200 [Invalid query] message="Unable to coerce Int64 into type CassandraTimestamp"
我的Cassandra版本是:
[cqlsh 5.0.1 | Cassandra 3.11.0 | CQL spec 3.4.4 | Native protocol v4]
I am using Cassandra and I have a column of data that represents epoch time milliseconds stored as a bigint
type:
request_time bigint
I would like to convert this to a date time object in order to work with certain days. How can I achieve that conversion?
I have tried:
select todate(request_time)
# InvalidRequest: Error from server: code=2200 [Invalid query] message="Input type Int64 is not supported in ToDate."
and also:
select dateof(mintimeuuid(request_time))
# InvalidRequest: Error from server: code=2200 [Invalid query] message="Unable to coerce Int64 into type CassandraTimestamp"
My Cassandra version is:
[cqlsh 5.0.1 | Cassandra 3.11.0 | CQL spec 3.4.4 | Native protocol v4]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用功能 -
下面的示例 -
您可以使用
Totimestamp
函数。直接在BigInt类型上使用此函数会产生错误 -
我们可以包装
todate
totimestamp 。Use function -
Example below -
Further you can use
totimestamp
function.Directly using this function on bigint type gives error -
We can wrap
todate
insidetotimestamp
.您通过使用内置CQL函数
todate()
有正确的想法。我已经部署了一个Cassandra 3.11.0群集(与您正在运行的版本相同),并且可以确认其有效。这是一个示例输出:
在您的情况下,我相信潜在的问题是您的表在
request_time_time
列中包含无效的数据。您需要检查表中的数据,然后重试。附带说明,Apache Cassandra 3.11.0在5年前发布,您甚至不应该为测试而费力使用它。在撰写本文时,当前支持的版本为C* 3.11.13。干杯!
You had the right idea by using the built-in CQL function
toDate()
.I've deployed a Cassandra 3.11.0 cluster (the same as the version you're running) and can confirm that it works. Here's an example output:
In your case, I believe the underlying issue is that your table contains invalid data in the
request_time
column. You need to check the data in your table and try again.As a side note, Apache Cassandra 3.11.0 was released 5 years ago and you shouldn't even bother using it for testing. At the time of writing, the current supported version is C* 3.11.13. Cheers!