【问题标题】:Inserting value to a cassandra UDT将值插入到 cassandra UDT
【发布时间】:2018-02-27 06:29:16
【问题描述】:

这是我创建的类型,

CREATE TYPE urs.dest (
destinations frozen<list<text>>);

这是桌子,

CREATE TABLE urs.abc (
id int,
locations map<text, frozen<dest>>,
PRIMARY KEY(id));

当我尝试从 cqlsh 插入值时,

尝试 1:

insert into urs.abc (id, locations ) values (1, {'coffee': { 'abcd', 'efgh'}});

尝试 2:

insert into urs.abc (id, locations ) values (1, {'coffee': ['abcd', 'efgh']});

尝试 3:

insert into urs.abc (id) values (1);
update urs.abc set locations = locations + {'coffee': {'abcd','qwer'}} where id=1;

我收到以下错误,

Error from server: code=2200 [Invalid query] message="Invalid map literal for locations: value {'abcd', 'qwer'} is not of type frozen<dest>"

谁能告诉我为我的 UDT 增值的正确方法?

【问题讨论】:

    标签: insert cql cqlsh user-defined-types cassandra-3.0


    【解决方案1】:

    表创建似乎很好

    要插入表到urs.abc 使用这个

    insert into urs.abc (id, locations ) values (1, {'coffee':{ destinations: ['abcd', 'efgh']}});
    

    您缺少字段名称destinations

    【讨论】:

      猜你喜欢
      • 2016-09-15
      • 2015-08-03
      • 1970-01-01
      • 2017-04-04
      • 2016-09-15
      • 2018-08-23
      • 1970-01-01
      • 2015-10-18
      • 1970-01-01
      相关资源
      最近更新 更多