Cassandra 2.1.0-beta2:ColumnDefinition的set literal无效

时间:2014-05-15 04:40:02

标签: cassandra

我正在尝试使用嵌套用户定义类型的Cassandra 2.1.0-beta2。这些是通过cqlsh 5.0.0创建的结构:

CREATE TYPE channelsource(id text, sources set<text>);
CREATE TYPE primaryfeed(name text, type text, multisource channelsource);

CREATE TABLE somedata (
source text PRIMARY KEY, 
unitid text, 
dayssincebirth text, 
reporttime text,
somefeed primaryfeed
);

此样本插入失败:

INSERT INTO somedata (source, unitid, dayssincebirth, reporttime, somefeed)
VALUES('GFDS8-v1.2.3', 'xxxxxxxx-ABCD-1234-B8F9-11111177F4', '89', '13:02:39',
{'dha', 'foo', {'someid', {'aa', 'cc'}}});

出现此错误:

code=2200 [Invalid query] message="Invalid set literal for ColumnDefinition
{name=somefeed, type=org.apache.cassandra.db.marshal.UserType
(bispace,7072696d61727966656564,6e616d65:org.apache.cassandra.db.marshal.UTF8Type,
74797065:org.apache.cassandra.db.marshal.UTF8Type,6d756c7469736f75726365:
org.apache.cassandra.db.marshal.UserType(bispace,6368616e6e656c736f75726365,6964
:org.apache.cassandra.db.marshal.UTF8Type,736f7572636573:
org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type))),
 kind=REGULAR, componentIndex=0, indexName=null, indexType=null} of type primaryfeed"

关于我应该使用的正确语法的任何指针?我假设在2.1之后支持嵌套的用户定义类型。

1 个答案:

答案 0 :(得分:1)

你基本上也需要传递字段的名称,即

{name: 'dha', type: 'foo', ...}

更多详细信息,请参阅本文http://www.datastax.com/dev/blog/cql-in-2-1

注意:您使用的语法({'val', 'val'})是集合的语法,它解释了您看到的错误。

相关问题