bincod evaluation in pig

南笙酒味 提交于 2020-01-05 04:32:05

问题


I am trying to replace the missing values with some precomputed value.

So i posted the question here and followed the advice and here is the code snippet

input = LOAD 'data.txt' USING PigStorage(',') AS
(
id1:double  ,  id21:double  );

gin = foreach input generate
        id1 IS NULL ? 2 : id1,
        id2 IS NULL ? 4 : id2;

But I am getting an error mismatched input 'IS' expecting SEMI_COLON?


回答1:


Try adding parentheses in the bincond. The following works properly for me:

Contents of input:

0.9,1.11
,0.3
10.3,

Script:

inp = LOAD 'input' USING PigStorage(',') AS (id1:double, id2:double );

gin = foreach inp generate
    ((id1 IS NULL) ? 2 : id1),
    ((id2 IS NULL) ? 4 : id2);

DUMP gin;

Output:

(0.9,1.11)
(2.0,0.3)
(10.3,4.0)


来源:https://stackoverflow.com/questions/13400940/bincod-evaluation-in-pig

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!