匹配猪不工作

时间:2016-12-09 17:07:07

标签: apache-pig

我正在尝试使用匹配来过滤记录。

daily = load '/user/data/NYSE_daily'as (exchange:chararray, symbol:chararray, date:chararray, open:float,high:float, low:float, close:float, volume:int, adj_close:float);

以下声明有效

dailythisyear = filter daily by $2 matches '.*20*.'; 

但是,当我更改匹配条件时,过滤器无法正常工作

dailythisyear = filter daily by $2 matches '20'
dailythisyear = filter daily by $2 matches '.*2009*.'; 

样本数据

(NYSE,CRT,2009-06-24,26.0,26.79,26.0,26.25,13000,25.07)
(NYSE,CRT,2009-06-23,24.6,25.43,24.11,25.43,10900,24.28)
(NYSE,CRT,2009-06-22,24.88,25.08,23.99,24.64,23700,23.53)
(NYSE,CRT,2009-05-29,24.76,26.54,24.13,26.41,26600,25.22)
(NYSE,CRT,2009-05-28,23.75,24.52,23.42,24.5,12700,23.4)
(NYSE,CRT,2009-05-27,23.55,24.04,22.75,23.55,16500,22.49)
(NYSE,CRT,2009-05-26,22.9,23.55,22.72,23.55,20900,22.37)
(NYSE,CRT,2009-05-22,23.29,23.95,22.51,22.75,13100,21.61)
(NYSE,CRT,2009-05-21,23.41,23.8,22.71,23.28,14400,22.11)
(NYSE,CRT,2009-05-20,22.55,23.95,22.55,23.66,14200,22.47)
(NYSE,CRT,2009-04-29,19.95,20.9,19.85,20.35,16200,19.33)
(NYSE,CRT,2009-04-28,19.32,20.59,19.32,19.85,19900,18.85)

HadoopVersion PigVersion UserId StartedAt FinishedAt功能   2.7.1.2.4.0.0-169 0.15.0.2.4.0.0-169 root 2016-12-09 16:58:49 2016-12-09 16:59:15 FILTER

1 个答案:

答案 0 :(得分:0)

检查语法,它应该是'。* 2009。*'

dailythisyear = filter daily by ($2 matches '.*2009.*');