【问题标题】:Exception in thread "main" java.lang.IllegalArgumentException: location.city is not a column defined in this metadata线程“主”java.lang.IllegalArgumentException 中的异常:location.city 不是此元数据中定义的列
【发布时间】:2015-09-10 20:52:01
【问题描述】:

这是我的 CQL 表

CREATE TYPE ks_demo.location (
lat float,
lon float,
locName text,
city text,
state text,
country text,
pin int
);    

create table publishMsg
(
    rowKey uuid,
    msgId timeuuid,
    postedBy text,
    postedById uuid,
    title text,
    details text,
    tags set<text>,
    location frozen<location>,
    blocked boolean,
    anonymous boolean,
    hasPhotos boolean,
    PRIMARY KEY(rowKey, msgId)      
)

create table publishMsg_by_user
(
    userId uuid,
    msgId timeuuid,
    postedBy text,
    title text,
    details text,
    tags set<text>,
    location frozen<location>,
    blocked boolean,
    anonymous boolean,
    hasPhotos boolean,
    PRIMARY KEY(rowKey, msgId)      
)

这里是datastax java查询

Select.Where query = QueryBuilder.select().column("userId").column("msgId")
.column("location.city")
       .from(AppConstants.KEYSPACE, "publishMsg_by_user")
       .where(QueryBuilder.eq("userId",userId));

如果我这样做了

ResultSet  execute         = session.execute(query);
Iterator<Row> iterator        = execute.iterator();        
while(iterator.hasNext())
{
    Row row = iterator.next();
    row.getString("location.city")
}
row.getString("location.city")

它正在显示

Exception in thread "main" java.lang.IllegalArgumentException: location.city is not a column defined in this metadata

【问题讨论】:

  • 你用的是什么版本的驱动?
  • @manish 您的查询提到了“userId”列,但它不在表定义中。应该吗?
  • 您能否发布publishMsg_by_user 的CQL 而不仅仅是publishMsg?我们这里没有所有信息。

标签: java cassandra datastax cql3 datastax-java-driver


【解决方案1】:

你可以试试:

String city = row.getUDTValue("location").getString("city")

【讨论】:

    猜你喜欢
    • 2017-11-18
    • 2020-07-18
    • 2013-09-01
    • 2014-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多