我有这张table
user_authentication_token (
token_id uuid,
user_id uuid,
email text,
expiration_time timestamp,
is_sign_up boolean,
PRIMARY KEY ((token_id, user_id, email, expiration_time))
我在表中有这些数据
token_id | user_id | email | expiration_time | is_sign_up
--------------------------------------+--------------------------------------+-------------------------+---------------------------------+------------
98b0456a-05b2-4aca-a6c7-6a1f382e19aa | b284d51d-efbb-4204-b342-a2486029a5c5 | manu.chadha@hotmail.com | 2018-09-01 09:40:59.634000+0000 | True
但我无法查询。InvalidRequest: Error from server: code=2200 [Invalid query] message="Unable to coerce '2018-09-01 09:40:59.634000+0000' to a formatted date (long)"
错误-InvalidRequest: Error from server: code=2200 [Invalid query] message="Unable to coerce '2018-09-01 09:40:59.634000+0000' to a formatted date (long)"
我做错了什么?
我使用Cassandra Java Datastax
驱动程序和以下代码插入了该行
def insertValues(tableName:String, model:UserToken):Insert = {
QueryBuilder.insertInto(tableName).value("token_id",model.tokenId)
.value("email",model.email)
.value("user_id",model.userId)
.value("expiration_time",model.expirationTime.getMillis())
.value("is_sign_up",model.isSignUp)
.ifNotExists(); }}
有趣的是,时间戳存储为long
,但cqlsh
以可读格式显示它。可能我需要再次将其转换为long
,但我该怎么做呢?
1条答案
按热度按时间6rqinv9w1#
您的时间戳不应超过毫秒:
**更新:**添加了由Manu Chadha发现的时区偏移量。