我有一个数据模式,其中我有50+列。现在我有一个场景,需要将四个int列添加到一起。有可能四分之一的人都是空的。
if i do null + 1 + null + 7 i get the result as null which is true as per given in the PIG
https://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#Nulls
i.e. if either sub-expression is null, the resulting expression is null.
有人能告诉我如何处理这种情况吗。我是否需要定义一个自定义项,或只是关心空,然后执行添加操作是好的。提前谢谢
1条答案
按热度按时间bq9c1y661#
一个选项是,如果列值为null,则将列值设置为零,否则继续使用原始值。下面的示例。
输入文件
Pig手稿:
输出: