问题
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