使用 Pig 从文件中获取第二条记录

Fetch the second record from the file using the Pig

我的数据是这样的:

(Alicia,2,Maths,Chemistry,Physics)
(Mac,2,Maths,Chemistry,Botany)
(Hardik,6,Maths,Chemistry,Zoology)
(Maneesh,9,Hindi,Chemistry,Physics)

我想创建一个只包含第二条记录数据的关系,(Mac,2,Maths,Chemistry,Botany) 然后我想执行进一步的操作。 我尝试使用 LIMIT 命令,但我会得到一些记录而不是特定记录。

使用过滤器获取特定的records.Assuming你有一个与示例数据集的关系 A,然后下面的 Pig 语句将为你找到你正在寻找的记录。

B = FILTER A BY (A.[=10=] == 'Mac');

这可能会完成工作。

a = load '<your data>';
b = rank a;
c = filter b by [=10=] == 2;

希望对您有所帮助!