2013-07-29 73 views
0

我使用 卡桑德拉 - 1.2补丁5234 - 通过CQL3创建的表不能访问到猪 Hadoop的 - 1.1.2 猪0.11.1运行PIG脚本

我有卡桑德拉表

datatypetest(num int PRIMARY KEY,ascii ascii,blob blob,text text,varnum varint);

和datatypetest测试数据是

num | ascii | blob | text | varnum 
-----+-------+--------+--------+------ 
    13 | 126 | 0x0003 | John | null 

我跑以下PIG脚本

test1 = LOAD 'cassandra://keyspace1/datatypetest' USING CassandraStorage() AS 
(num:int, columns: bag {T: tuple(name, value)}); 

和输出是为Test1

(12,{((),),((ascii),125),((blob),��),((text),deepak)}) 

正如你在别名如下在输出中可以看到,它不是以下格式

(<row_key>,{(<column_name1>,<value1>),(<column_name2>,<value2>)}) 

内袋有元组,它有另一个内部元组和第一个内部元组,我认为这个键是空的。

我不能使用columns.ascii或columns.blob或columns.text访问各列,元组像下面,并得到一个例外

test2 = FOREACH test1 GENERATE num, columns.text; 
2013-07-29 09:11:58,488 [main] ERROR org.apache.pig.tools.grunt.Grunt - 
ERROR 1200: Pig script failed to parse: 
<line 3, column 8> pig script failed to validate:  
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1128: 
Cannot find field text in name:tuple(),value:bytearray 

我怎样才能访问列的元组。 在此先感谢。

回答

0

引用使用CQL3创建的表时,不应使用CassandraStorageCassandraStorage类似于Thrift API。当访问CQL3表,请使用CqlStorage

test1 = LOAD 'cql://keyspace1/datatypetest' USING CqlStorage(); 

这应该给你的名称/值元组的列及其内容。响应应该是这个样子:

((name,13),(ascii,126),(blob,"blobvalue"),(text,John)) 

然而,似乎是返回的集合和CqlStorage生成模式之间的不匹配。 (See this question。)