如何存储到元组中定义名称的文件?

时间:2015-04-16 09:35:45

标签: hadoop apache-pig

我们说我有以下示例代码:

USERS = LOAD 'Users' AS (location, name, age, date);
STORE USERS INTO '**%location%**-records.json' USING JsonStorage();

我想将数据中给定位置的记录存储到特定文件中。我无法找到任何可以表明猪可以做到这一点的事情,但我乐观地认为它可以吗?

1 个答案:

答案 0 :(得分:0)

据我所知,我们不能用猪变量来做。我指的是一种方法。可能这很有用。

USERS = LOAD 'Users' AS (location, name, age, date);

SPLIT USERS INTO
location1 IF location matches 'location1',
location2 IF location matches 'location2',
location3 IF (location matches 'location3')
;

STORE location1 INTO 'location1-records.json' USING JsonStorage();
STORE location2 INTO 'location2-records.json' USING JsonStorage();
STORE location3 INTO 'location3-records.json' USING JsonStorage();