替换猪拉丁语中的值 [英] replacing values in pig latin

查看:72
本文介绍了替换猪拉丁语中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集,格式为:

I have a dataset in form:

id1, id2, id3

记录中可能缺少id1,id2或id3中的任何一个(或全部三个..或任何两个).

Either of id1,id2 or id3 (or all three.. or any two) can be missing in a record.

现在,如果缺少id1,我想将其替换为1

Now if id1 is missing I want to replace it with 1

 id2 by 3 
 id3 by 7

我该怎么做. 谢谢

推荐答案

使用bincond运算符测试该值是否为空,然后将其替换为所需的值.在Programming Pig中,第5章:

Use the bincond operator to test if the value is null and then replace it with the desired value. From Programming Pig, Chapter 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

这篇关于替换猪拉丁语中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆