B = FOREACH A GENERATE (foo is null ? 'something' : (case foo
when 'S' then '1'
when 'W' then '2'
...
else '3'
end));
例子
1 1
2 1
3 1
4 2
脚本-为测试生成一些空值并替换为“something”
A = LOAD '/test20.txt' AS (f1:int,f2:int);
B = FOREACH A GENERATE $0;
C = FOREACH A GENERATE $1;
D = JOIN B BY $0 LEFT OUTER,C BY $0;
E = FOREACH D GENERATE $0, ($1 is null ? 'SOMETHING' : (case $1
when 1 then 'One'
when 2 then 'Two'
when 3 then 'Three'
when 4 then 'Four'
else 'UNKNOWN'
end));
DUMP E;
1条答案
按热度按时间ctzwtxfj1#
我不认为您可以在case语句中检查null。相反,您可以使用bincond运算符首先检查null值,然后使用case语句检查其余的“foo”值
假设只有一个字段在几行中有空值
例子
脚本-为测试生成一些空值并替换为“something”
输出