pig 10 filter chararray by is not null不起作用

tp5buhyn  于 2021-06-25  发布在  Pig
关注(0)|答案(1)|浏览(372)

我是新来的Pig,我在玩它,来到一个路障。
假设我有以下几点:

dump test;

(1,2014-04-08 12:09:23.0)
(2,2014-04-08 12:09:23.0)
(3,null)
(4,null)

我想过滤“test”来删除空值,所以我会这样做:

filter_test = filter test by test.column2 is not null;

给我这样的东西:

(1,2014-04-08 12:09:23.0)
(2,2014-04-08 12:09:23.0)

但它返回相同的东西。它不会删除空行。
我用的是10号Pig,日期栏是chararray类型。
谢谢你的帮助。

3pvhb19x

3pvhb19x1#

column2没有空值,它是一个字符。请参阅实空值和空为字符的示例。
示例1:null为chararray
输入文件

1,2014-04-08 12:09:23.0
2,2014-04-08 12:09:23.0
3,null
4,null

清管器:

A = LOAD 'input.txt' USING PigStorage(',') AS (f1:int,f2:chararray);
B = FILTER A BY f2!='null';
DUMP B;

输出:

(1,2014-04-08 12:09:23.0)
(2,2014-04-08 12:09:23.0)

示例2:实空值
输入文件

1,2014-04-08 12:09:23.0
2,2014-04-08 12:09:23.0
3,
4,

清管器:

A = LOAD 'input.txt' USING PigStorage(',') AS (f1:int,f2:chararray);
B = FILTER A BY f2 is not null;
DUMP B;

输出:

(1,2014-04-08 12:09:23.0)
(2,2014-04-08 12:09:23.0)

相关问题