本文介绍了使用IN运算符的“聚类”列中的Cassandra更新和删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的表

CREATE TABLE quorum.omg (
id int,
a int,
b text,
c text,
PRIMARY KEY ((id, a), b)
) WITH CLUSTERING ORDER BY (b DESC)

当我使用IN运算符执行选择语句时,它对于最后一个分区键和最后一个集群键都可以正常工作

When i'am doing a select statement using IN operator, it works fine for last partition key and last clustering key

SELECT * FROM  omg WHERE id=1 AND a IN ( 1,2) AND b IN ( 'a','b' ) ;

 id | a | b | c
----+---+---+----
  1 | 1 | b | hi
  1 | 2 | a | hi

但是当我执行更新和删除操作时,会抛出这样的错误

But when i do update and delete it is throwing error like this

UPDATE omg SET c = 'lalala' WHERE id=1 AND a IN ( 1,2) AND b IN ( 'a','b' ) ;
InvalidRequest: code=2200 [Invalid query] message="Invalid operator IN for PRIMARY KEY part b"

DELETE from omg  WHERE id=1 AND a IN ( 1,2) AND b IN ( 'a','b' ) ;
InvalidRequest: code=2200 [Invalid query] message="Invalid operator IN for  PRIMARY KEY part b"

我的错误是什么?预先感谢。

What is my mistake? Thanks in advance.

推荐答案

摘自UPDATE上的DataStax文档():

From the DataStax documentation on UPDATE (http://docs.datastax.com/en/cql/3.1/cql/cql_reference/update_r.html):

您的最后一个分区键是 a ,但是您正尝试在集群键 b 中使用它code>。尝试在WHERE子句中使用特定的完整主键更新/删除。

Your last partition key is a, yet you are trying to use it on your clustering key b. Try to UPDATE/DELETE with a specific, complete primary key in your WHERE clause.

这篇关于使用IN运算符的“聚类”列中的Cassandra更新和删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 09:13