在cassandra中更新自定义类型的集合类型

Update a collection type of a custom type in cassandra

如何将新元素附加到 Cassandra 中自定义类型的集合。

custom_type 是:

CREATE TYPE custom_type (
   normal_type    TEXT,
   set_type Set<TEXT>
);

要更新的 table 是:

CREATE TABLE test_table (
   id          TEXT,
   my_type      FROZEN<custom_type>,
   clustering_key TEXT,
   PRIMARY KEY ((id),clustering_key)
);

尝试了以下查询但没有成功。

@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 | Cassandra 3.11.1 | CQL spec 3.4.4

当您说 frozen 时,整个值将被视为一个片段(blob),因此您无法更新该字段的部分内容。 Official documentation 状态:

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.