在cassandra中更新自定义类型的集合类型 [英] Update a collection type of a custom type in cassandra
问题描述
如何在Cassandra中以自定义类型向集合中添加新元素。
How can I append a new element to a set which is in a custom type in Cassandra.
custom_type为:
custom_type is :
CREATE TYPE custom_type (
normal_type TEXT,
set_type Set<TEXT>
);
要更新的表是:
CREATE TABLE test_table (
id TEXT,
my_type FROZEN<custom_type>,
clustering_key TEXT,
PRIMARY KEY ((id),clustering_key)
);
在下面的查询中尝试过,但没有用。
Tried below query but did not work.
@Query("update test_table set my_type.set_type = my_type.set_type + {'newelement'} where id=?1 and clustering_key=?2")
关于如何做到这一点的任何想法?
使用 [cqlsh 5.0.1 |卡桑德拉3.11.1 | CQL规范3.4.4
Any Idea on how to do that?
Using [cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4
推荐答案
您说冻结
,则将整个值视为一个(blob),因此您无法更新此字段的部分内容。 官方文档指出:
When you say frozen
, then the whole value is treated as one piece (blob), so you can't update parts of this field. Official documentation states:
使用Frozen关键字时,无法更新用户定义类型值的部分。整个值必须被覆盖。 Cassandra将冻结的用户定义类型的值视为blob。
When using the frozen keyword, you cannot update parts of a user-defined type value. The entire value must be overwritten. Cassandra treats the value of a frozen, user-defined type like a blob.
这篇关于在cassandra中更新自定义类型的集合类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!