我正在探讨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查询是否不支持上面提到的那个?
答案 0 :(得分:3)
根据您的架构,假设book列系列包含所有必需的列,您的查询可能只是:
SELECT BookTitle FROM book WHERE year_of_publication='1999'
我不相信Cassandra CQL支持子选择语法(还)。根据{{3}},过滤限制为:
答案 1 :(得分:3)
您正在尝试执行Cassandra CQL不支持的连接。