我举了一个例子: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);
(变量是列表),它实际上只包含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
1条答案
按热度按时间gdrx4gfi1#
这意味着您试图向准备好的语句传递3个参数,而您只有两个“?”占位符。所以传递的参数比准备好的占位符要多。不幸的是,命名参数也会发生这种情况(它们可以忽略不匹配的参数,这有时非常方便)。