且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换猪拉丁语中的值

更新时间:2023-02-26 11:43:12

使用 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