Фильтр По операции не работает в Pig, не уверены, что происходит? - PullRequest
1 голос
/ 29 мая 2020

Я застрял, пытаясь извлечь твиты, используя Pig для определенного c местоположения с использованием границ широты и долготы. затем он умирает.

Мой сценарий

REGISTER 'hdfs/json-simple-1.1.jar';
REGISTER 'hdfs/elephant-bird-hadoop-compat-4.1.jar';
REGISTER 'hdfs/elephant-bird-pig-4.1.jar';

-- this is just one day, there is a bunch more data, once the script is working well
-- /data/ProjectDataset/statuses.log.2014-12-31.gz
tweets_all = LOAD '/data/ProjectDataset/statuses.log.2014-12-3*' USING com.twitter.elephantbird.pig.load.JsonLoader('-nestedLoad') AS (json:map[]);

-- JUST THE COORDINATES
-- to get the geo locations of tweets
tweets_all = FOREACH tweets_all GENERATE FLATTEN(json#'created_at') as time_stamp:chararray, FLATTEN(json#'id') as id:chararray, FLATTEN(json#'coordinates') as (coords_map:map[]);

-- remove duplicates
tweets = DISTINCT tweets_all;

-- filter for tweets with geo tags
filtered = FILTER tweets BY (coords_map IS NOT NULL);

-- parse the date time and unpack the geo data
locs1 = foreach filtered generate ToDate(time_stamp, 'EEE MMM dd HH:mm:ss Z yyyy') as time_stamp, coords_map#'coordinates' as coordinates:bag{t1:tuple(f1:double, f2:double)}, id as id;

-- reference longitude and latitude
locs2 = foreach locs1 generate BagToTuple(coordinates).$0 as longitude:double, BagToTuple(coordinates).$1 as latitude:double, id, time_stamp;

-- filter for tweets with geo tags with longs between (-70.0 and -80.0) and lats between (35.0 and 45.0)
geo_filtered = FILTER locs2 BY (longitude > 35) and (longitude < 45) and (latitude > -80) and (latitude < -70);

-- look at the top results
tops = limit geo_filtered 10;
dump tops;

Он работает до locs2, потому что при выполнении tops = limit locs2 5; и dump tops; возвращается:

(- 81.9536, 34.9307, 549701401182351360, 2014-12-29T23: 00: 01.000Z)

(- 46.455577, -23.505258, 549701401186938883, 2014-12-29T23: 00: 01.000Z)

(179.0, 81.0, 549701401191129089, 2014-12-29T23: 00: 01.000Z)

(- 4.186111, 39.742536, 549701401203732481, 2014-12-29T23: 00: 01.000Z)

(12.094579, 57.928088 , 549701401207930880, 2014-12-29T23: 00: 01.000Z)

Кроме того, запуск describe locs2 приводит к:

locs2: {longitude: double, latitude: double, id: chararray, time_stamp: datetime}

Мне явно не нравится работа фильтра на locs2, но я не могу понять почему?

Заранее спасибо! * 1 033 *

...