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

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

问题描述

我有一个数据集形式:

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 运算符测试该值是否为空,然后将其替换为所需的值.来自编程猪,第 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天全站免登陆