使用list数据类型将数据插入Pig中的Cassandra失败

时间:2014-09-20 21:33:05

标签: hadoop cassandra apache-pig datastax-enterprise datastax

我有以下情况:

Cassandra的表:

CREATE TABLE tb_st_test (
  id int,
  email list<text>,
  PRIMARY KEY ((id));

PIG代码:

teste = LOAD 'cql://main/tb_st_test' USING CqlStorage();

testing = FOREACH teste GENERATE $0 as cod, ['emailtest@test.com'] as field:();

insert_test = 
FOREACH testing GENERATE
TOTUPLE(
TOTUPLE('id',cod)
),
TOTUPLE(field);

STORE insert_test INTO 'cql://main/tb_st_test?output_query=UPDATE tb_st_test set email %3D%3F' USING CqlStorage();

这里的想法是阅读表tb_st_test,获取键值,并更新字段电子邮件。 但是当我运行脚本时,我收到以下错误:

后端错误消息

java.io.IOException: org.apache.thrift.transport.TTransportException
        at org.apache.cassandra.hadoop.cql3.CqlRecordWriter$RangeClient.run(CqlRecordWriter.java:256)
Caused by: org.apache.thrift.transport.TTransportException
        at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)
        at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
        at org.apache.thrift.transport.TFramedTransport.readFrame(TFramedTransport.java:129)
        at org.apache.thrift.transport.TFramedTransport.read(TFramedTransport.java:101)
        at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
        at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:362)
        at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:284)
        at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:191)
        at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
        at org.apache.cassandra.thrift.Cassandra$Client.recv_execute_prepared_cql3_query(Cassandra.java:1820)
        at org.apache.cassandra.thrift.Cassandra$Client.execute_prepared_cql3_query(Cassandra.java:1805)
        at org.apache.cassandra.hadoop.cql3.CqlRecordWriter$RangeClient.run(CqlRecordWriter.java:240)

有谁知道它发生了什么?

1 个答案:

答案 0 :(得分:0)

insert_test格式错误,因为列表集合格式应该是TOTUPLE(TOUTUPLE('some email','email2'))。检查https://issues.apache.org/jira/browse/CASSANDRA-5867