为什么cqlsh的“ CREATE”语句将“ uuid”字段创建为“ timeuuid”?

时间:2019-06-10 13:03:59

标签: cassandra cqlsh

卡桑德拉3.11.0
 在Ubuntu 16.04.4,JRE-8中运行
我正在尝试使用uuid字段创建表,如下所示:

const suits = ['Heart','Diamond','Spade','Club']
const vals = ['2','3','4','5','6','7','8','9','K','Q','J','A']
const deck = vals .flatMap (value => suits .map (suit => ({value, suit}) ))


console .log (
  deck
)

执行此操作后,架构显示“ policy_id”创建为“ timeuuid”而不是“ uuid”。
看到了[相似的问题]:creating uuid type field in Cassandra table using CassandraAdminOperations.createTable
但这适用于cqlsh吗?

删除表/键空间,然后重试,但没有运气。
这是间歇性的问题。
出现以下异常:

CREATE TABLE IF NOT EXISTS policy (
  tenant_id         text,
  policy_id         uuid,
  name              text,
  enabled           boolean,
  creation_time     bigint,
  PRIMARY KEY (tenant_id, name)
);

还在cassandra日志中看到以下内容:

Exception while loading CQL script:
com.datastax.driver.core.exceptions.InvalidQueryException: Type error: cannot assign result of function system.uuid (type uuid) to id (type timeuuid)
        at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:50)
        at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
        at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
        at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:68)
        at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:43)

policy_id应具有数据类型“ uuid”,但其数据类型为“ timeuuid”。
cql语句中需要其他任何关键字来创建表吗?

0 个答案:

没有答案