gpt4 book ai didi

Cassandra Hector——查询不工作

转载 作者:行者123 更新时间:2023-12-03 07:58:14 27 4
gpt4 key购买 nike

我正在对 cassandra cql 查询进行一些探索。我安装了 cassandra 1.0 并使用 hector java api 。我遇到这样的异常:-

me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:line 1:99 extraneous input ')' expecting EOF)
at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:50)
at me.prettyprint.cassandra.model.CqlQuery$1.execute(CqlQuery.java:127)
at me.prettyprint.cassandra.model.CqlQuery$1.execute(CqlQuery.java:94)
at me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:101)
at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:232)
at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecuteOperation(ExecutingKeyspace.java:97)
at me.prettyprint.cassandra.model.CqlQuery.execute(CqlQuery.java:93)
at CassandraBulkUpload.inComplexQuery(CassandraBulkUpload.java:80)
at CassandraBulkUpload.<init>(CassandraBulkUpload.java:60)
at BulkDataLoadExample.main(BulkDataLoadExample.java:22)
Caused by: InvalidRequestException(why:line 1:99 extraneous input ')' expecting EOF)
at org.apache.cassandra.thrift.Cassandra$execute_cql_query_result.read(Cassandra.java:30983)
at org.apache.cassandra.thrift.Cassandra$Client.recv_execute_cql_query(Cassandra.java:1708)
at org.apache.cassandra.thrift.Cassandra$Client.execute_cql_query(Cassandra.java:1682)
at me.prettyprint.cassandra.model.CqlQuery$1.execute(CqlQuery.java:100)

我正在尝试运行此查询:-

CqlQuery<String, String, String> cqlQuery = new CqlQuery<String, String, String>(HFactory.createKeyspace("largedata",cluster),stringSerializer,stringSerializer,stringSerializer);
String cql= "SELECT BookTitle FROM book WHERE isbn in((SELECT id FROM book b where year_of_publication='\"1999\"'))";
cqlQuery.setQuery(cql);
QueryResult<CqlRows<String, String, String>> result = cqlQuery.execute();

我还在 year_of_publication 上创建了二级索引。谁能告诉我 cql cassandra 查询是否不支持上述查询?

最佳答案

根据您的模式,假设 book 列族包含所有必要的列,您的查询可能只是:

SELECT BookTitle FROM book WHERE year_of_publication='1999'

我认为 Cassandra CQL 不支持子选择语法(目前)。根据cql-reference ,过滤仅限于:

  • SELECT ... WHERE KEY = keyname AND name1 = value1
  • SELECT ... WHERE KEY >= startkey and KEY =< endkey AND name1 = value1
  • SELECT ... WHERE KEY IN ('', '', '', ...)

关于Cassandra Hector——查询不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8442383/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com