如何在猪拉丁语中使用过滤器操作员

时间:2015-03-23 16:34:42

标签: hadoop foreach filter apache-pig

我正在尝试在foreach中使用FILTER运算符来过滤我的一些数据,但它会引发错误。我使用以下查询:

ctm_pm_v1_stg = LOAD '/datalake/uhc/ei/pi_ara/hive/warehouse/ctm_pm.db/ctm_pm_t1' USING PigStorage ('\u0001') AS (lob:chararray,day_phnno:chararray,eve_phnno:chararray,mbr_name:chararray,hic_no:chararray,contract_no:chararray,ctm_risk_category:chararray);
ctm_pm_v1 = FOREACH ctm_pm_v1_stg {
fdata = FILTER ctm_pm_v1_stg by ctm_risk_category=='High';
GENERATE ctm_risk_category;
};

如果有人对此有所了解请帮助我。 提前谢谢。

1 个答案:

答案 0 :(得分:2)

Nested FOREACH仅适用于行李,但您的relation(ctm_pm_v1_stg)没有任何行李。要解决此问题,请删除嵌套部分,仅使用FILTER stmt

ctm_pm_v1_stg = LOAD '/datalake/uhc/ei/pi_ara/hive/warehouse/ctm_pm.db/ctm_pm_t1' USING PigStorage ('\u0001') AS (lob:chararray,day_phnno:chararray,eve_phnno:chararray,mbr_name:chararray,hic_no:chararray,contract_no:chararray,ctm_risk_category:chararray);
fdata = FILTER ctm_pm_v1_stg by (ctm_risk_category=='High');
DUMP fdata;