gpt4 book ai didi

java - DataStax Cassandra Exception : InvalidRequestException(why:there were 2 markers(? ) 在 CQL 中但有 3 个绑定(bind)变量

转载 作者:可可西里 更新时间:2023-11-01 14:41:31 26 4
gpt4 key购买 nike

我按照这里的例子:https://github.com/apache/cassandra/blob/trunk/examples/hadoop_cql3_word_count/src/WordCount.java编写我自己的 MR 作业,它从表 A 读取数据并将相同的数据写入表 B。表 A 和 B 都存储在 Cassandra 中,DataStax 版本。

我的 MR 作业读取所有数据没有问题,然后我也可以写入 HDFS,但是当我尝试写回表 B 时,它抛出错误:

attempt_201311051600_0300_r_000000_2: java.io.IOException: InvalidRequestException(why:there were 2 markers(?) in CQL but 3 bound variables)
attempt_201311051600_0300_r_000000_2: at org.apache.cassandra.hadoop.cql3.CqlRecordWriter$RangeClient.run(CqlRecordWriter.java:248)
attempt_201311051600_0300_r_000000_2: Caused by: InvalidRequestException(why:there were 2 markers(?) in CQL but 3 bound variables)
attempt_201311051600_0300_r_000000_2: at org.apache.cassandra.thrift.Cassandra$execute_prepared_cql3_query_result.read(Cassandra.java:41868)
attempt_201311051600_0300_r_000000_2: at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
attempt_201311051600_0300_r_000000_2: at org.apache.cassandra.thrift.Cassandra$Client.recv_execute_prepared_cql3_query(Cassandra.java:1689)
attempt_201311051600_0300_r_000000_2: at org.apache.cassandra.thrift.Cassandra$Client.execute_prepared_cql3_query(Cassandra.java:1674)
attempt_201311051600_0300_r_000000_2: at org.apache.cassandra.hadoop.cql3.CqlRecordWriter$RangeClient.run(CqlRecordWriter.java:232)

我的准备语句是:

String query = "UPDATE " + KEYSPACE + "." + OUT_COLUMN_FAMILY + " SET amt=?, good_desc='?' ";
CqlConfigHelper.setOutputCql(job.getConfiguration(), query);

我试图在 context.write(keys, variables); 之前在我的 reducer 中打印出列表(变量是列表),它实际上只包含 2 个值,例如:

INFO  - 2013-11-07 15:43:36.683; poc.cassandra.mr.access.CassandraReducer; --> tx_id: 2577620422:10001372:debit
INFO - 2013-11-07 15:43:36.684; poc.cassandra.mr.access.CassandraReducer; 0: 12919
INFO - 2013-11-07 15:43:36.684; poc.cassandra.mr.access.CassandraReducer; 1: Express

最佳答案

这意味着您试图将 3 个参数传递给准备好的语句,而您只有两个 '?'占位符。所以你传递的参数比你准备好的占位符多。不幸的是,命名参数也会发生这种情况(他们可以简单地忽略不匹配的参数,这有时会非常方便)。

关于java - DataStax Cassandra Exception : InvalidRequestException(why:there were 2 markers(? ) 在 CQL 中但有 3 个绑定(bind)变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19847550/

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