替换pig拉丁语中的值

icnyk63a  于 2021-06-24  发布在  Pig
关注(0)|答案(1)|浏览(401)

我有一个数据集的形式:

id1, id2, id3

id1、id2或id3中的一个(或全部三个。。或任何两个)可以在记录中丢失。
现在如果id1丢失了,我想用1替换它

id2 by 3 
 id3 by 7

我该怎么做。谢谢

3yhwsihp

3yhwsihp1#

使用bincond操作符测试值是否为null,然后用所需的值替换它。摘自《编程清管器》,第5章:

2 == 2 ? 1 : 4 --returns 1 
2 == 3 ? 1 : 4 --returns 4 
null == 2 ? 1 : 4 -- returns null
2 == 2 ? 1 : 'fred' -- type error, both values must be of the same type

在你的例子中,

id2 IS NULL ? 3 : id2

相关问题