我们可以在单个查询中使用多个cassandra CQL集合(set,list,map吗?

问题描述 投票:1回答:1
create table seller(
    seller_id int primary key,
    seller_name text,
    seller_email set<text>, 
    seller_address map<text>, 
    seller_phone list<text>,
    product_id int,
    product_title_text,
    product_description text,
    product_trackno int,
    product_bidoption text,
    bid_startdate date,
    bid_closedate date,
    bid_startprice int,
    bid_withdrawdate date);

    SyntaxException: line 1:110 mismatched input '>' expecting ',' (...<text>,
        seller_address map<text[>],...)

要执行什么更改?

cassandra cql cqlsh
1个回答
2
投票
1)如果没有通过下划线将列的类型链接到列名,则很有帮助。代替:

product_title_text,

这将起作用:

product_title text,

2)您还需要为地图集合提供两种类型。代替:

seller_address map<TEXT>,

这将起作用:

seller_address map<TEXT,TEXT>, 

完整CQL:

create table seller(
  seller_id int primary key,
  seller_name text,
  seller_email set<TEXT>,
  seller_address map<TEXT,TEXT>, 
  seller_phone list<TEXT>, 
  product_id int,
  product_title text,
  product_description text,
  product_trackno int,
  product_bidoption text,
  bid_startdate date,
  bid_closedate date,
  bid_startprice int,
  bid_withdrawdate date);

而且,您真的只想按seller_id查询此表吗?如果没有,您可能需要重新考虑主键定义。

© www.soinside.com 2019 - 2024. All rights reserved.