0

我正在加入 3 个表,在 foreach 中我需要检查 ReadStagingData 包是否为空。 下面是代码

ReadStagingData = Load 'Staging_data.csv' Using PigStorage(',') As     (PL_Posn_id:int,Brok_org_dly:double,Brok_org_ptd:double);

ReadPriorData = Load 'ptd.csv' Using PigStorage(',') As (PL_Posn_id:int,Brok_org_ptd:double);

ReadPriorFunctional = Load 'Functional.csv' Using PigStorage(',') AS (PL_Posn_id:int,Brok_fun_ptd:double,Brok_fun_ltd:double);

JoinDS1 = JOIN ReadPriorData BY PL_Posn_id,ReadPriorFunctional BY PL_Posn_id;

JoinDS2 = JOIN ReadStagingData by PL_Posn_id Left OUTER,JoinDS1 BY      ReadPriorData::PL_Posn_id;

X = Foreach JoinDS2 {
    **test = (NOT(IsEmpty(ReadStagingData))); //Error on this line**
    GENERATE test,ReadStagingData::PL_Posn_id,
    ReadStagingData::Brok_org_dly,
   (ReadStagingData::Brok_org_ptd is not null ? ReadStagingData::Brok_org_ptd:ReadPriorData::Brok_org_ptd+ReadStagingData::Brok_org_dly);
};

Dump X;

当我运行上面的代码时,我收到错误 INVALID PROJECTION ReadStagingData. Please help me

4

1 回答 1

0

在你的关系X中,ReadStagingData不是一个包。该符号ReadStagingData::Brok_org_dly不表示从袋子中投影;它是一个顶级字段,以这种方式命名,JOIN以确保每个字段都被唯一命名。所以ReadStagingData只是一个前缀。

此外,我不确定您为什么要尝试检查 - 因为您正在执行LEFT OUTER连接,所以在X没有相应记录的情况下不会有任何记录 in ReadStagingData。如果你正在做一个RIGHT OUTER连接,那将是不同的。

如果您打算RIGHT OUTER加入,并且想检查来自的字段是否ReadStagingDataNULL,我会这样做:

rsdIsNull = ReadStagingData::PL_Posn_id IS NULL;
于 2013-10-14T15:47:44.170 回答