我们可以在一个查询中使用多个cassandra cql集合(set、list、map)吗?

xe55xuns  于 2021-06-10  发布在  Cassandra
关注(0)|答案(1)|浏览(405)
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[>],...)

为了执行,应该进行哪些更改?

w6lpcovy

w6lpcovy1#

当然,您可以通过一些调整:
1) 如果列的类型未通过下划线链接到列名,则会有所帮助。而不是:

product_title_text,

这将起作用:

product_title text,

2) 您还需要为Map集合提供这两种类型。而不是:

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 ? 否则,您可能需要重新考虑主键定义。

相关问题