没有根据 Apache Pig 中定义的模式获取输出

Not getting the ouptut according to defined schema in Apache Pig

我是 pig latin 的新手,我在我的数据上尝试了这个模式,

A = LOAD 'data' USING PigStorage(',') AS (f1:int, f2:int, B:bag{T:tuple(t1:int,t2:int)});

我的样本数据是

10,1,{(2,4),(5,6)}  
10,3,{(1,3),(6,9)}

在执行 \d A 时,我终端上的输出是:

(10,1,)  
(10,3,)

请告诉我我做错了什么。

您的示例数据不正确 format.Your 加载语句使用“,”作为字段 separator.However包中的元组也由“,”分隔,因此数据加载不正确。

解决此问题的一种方法是为 fields.For 示例选项卡、竖线、分号选择不同的分隔符。

使用制表符作为字段分隔符,使用逗号作为元组分隔符

10  1   {(2,4),(5,6)}
10  3   {(1,3),(6,9)}

制表符分隔字段的脚本

A = LOAD 'test8.txt' using PigStorage('\t') AS (f1:int, f2:int, B:bag{T:tuple(t1:int,t2:int)});
DUMP A;

输出

或者,您可以在不指定字段的情况下加载示例数据

10,1,{(2,4),(5,6)}
10,3,{(1,3),(6,9)}

不带架构但以“,”作为字段分隔符的加载脚本

A = LOAD '/test8.txt' USING PigStorage(',');
DUMP A;

输出