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

yyyllmsg  于 2021-06-14  发布在  Cassandra
关注(0)|答案(0)|浏览(191)

Cassandra3.11.0
在ubuntu 16.04.4、jre-8中运行
我正在尝试创建一个具有uuid字段的表,如下所示:

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

执行此操作后,架构将“policy\u id”显示为“timeuuid”,而不是“uuid”。
看到了一个[类似的问题]:使用cassandraadminoperations.createtable在cassandra表中创建uuid类型字段
但这是否适用于cqlsh?
删除表/键空间并重试,但没有成功。
这是间歇性问题。
获取以下异常:

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)

在cassandra日志中也可以看到:

org.apache.cassandra.exceptions.ConfigurationException: Column family ID mismatch (found e686a660-8994-11e9-984c-2767f9f5fd28; expected e5d72c80-8994-11e9-b706-831d59206120)
    at org.apache.cassandra.config.CFMetaData.validateCompatibility(CFMetaData.java:808) ~[apache-cassandra-3.11.0.jar:3.11.0]
    at org.apache.cassandra.config.CFMetaData.apply(CFMetaData.java:770) ~[apache-cassandra-3.11.0.jar:3.11.0]
    at org.apache.cassandra.config.Schema.updateTable(Schema.java:621) ~[apache-cassandra-3.11.0.jar:3.11.0]
    at org.apache.cassandra.schema.SchemaKeyspace.updateKeyspace(SchemaKeyspace.java:1430) ~[apache-cassandra-3.11.0.jar:3.11.0]
    at org.apache.cassandra.schema.SchemaKeyspace.mergeSchema(SchemaKeyspace.java:1386) ~[apache-cassandra-3.11.0.jar:3.11.0]
    at org.apache.cassandra.schema.SchemaKeyspace.mergeSchemaAndAnnounceVersion(SchemaKeyspace.java:1336) ~[apache-cassandra-3.11.0.jar:3.11.0]
    at org.apache.cassandra.service.MigrationTask$1.response(MigrationTask.java:91) ~[apache-cassandra-3.11.0.jar:3.11.0]
    at org.apache.cassandra.net.ResponseVerbHandler.doVerb(ResponseVerbHandler.java:53) [apache-cassandra-3.11.0.jar:3.11.0]
    at org.apache.cassandra.net.MessageDeliveryTask.run(MessageDeliveryTask.java:66) [apache-cassandra-3.11.0.jar:3.11.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_131]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
    at org.apache.cassandra.concurrent.NamedThreadFactory.lambda$threadLocalDeallocator$0(NamedThreadFactory.java:81) [apache-cassandra-3.11.0.jar:3.11.0]
    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_131]

策略\u id应具有数据类型“uuid”,但它具有数据类型“timeuuid”。
在cql语句中需要任何额外的关键字来创建表吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题