내가 돼지 라틴어로 초보자입니다 실패와 나는 FILTER 문에 대한 문제를 발견했다. 예 봐 :사용 필터는
1,2,3
2,3,4
3,4,5
4,5,6
내가 그의 첫 번째 필드 '3'인 레코드를 선택합니다 :
우리가 내용이있는 데이터 파일 (TEST.TXT)가 가정하자. 돼지 스크립트는 다음과 같습니다.
t = LOAD 'test.txt' USING PigStorage(',');
t1 = FOREACH t GENERATE $0 AS i0:chararray, $1 AS i1:chararray, $2 AS i2:chararray;
f1 = FILTER t1 BY i0 == '3';
DUMP f1
작업은 성공적으로 실행되지만 출력 결과는 아무 것도 아닙니다. F1 쇼를 EXPLAIN :
#--------------------------------------------------
# Map Reduce Plan
#--------------------------------------------------
MapReduce node scope-27
Map Plan
f1: Store(fakefile:org.apache.pig.builtin.PigStorage) - scope-26
|
|---f1: Filter[bag] - scope-22
| |
| Equal To[boolean] - scope-25
| |
| |---Project[chararray][0] - scope-23
| |
| |---Constant(3) - scope-24
|
|---t1: New For Each(false,false,false)[bag] - scope-21
| |
| Project[bytearray][0] - scope-15
| |
| Project[bytearray][1] - scope-17
| |
| Project[bytearray][2] - scope-19
|
|---t: Load(file:///Users/woody/test.txt:PigStorage(',')) - scope-14--------
Global sort: false
----------------
을 그러나, 나는에 머리 2 개 라인을 변경하는 경우 :
t1 = LOAD 'test.txt' USING PigStorage(',') AS (i0:chararray, i1:chararray, i2:chararray)
이 작업은 잘 작동하고 결과가 (즉, LOAD 문에서 스키마를 지정) 또한 맞습니다. 이 경우 EXPLAIN f1은 다음을 표시합니다.
#--------------------------------------------------
# Map Reduce Plan
#--------------------------------------------------
MapReduce node scope-33
Map Plan
f1: Store(fakefile:org.apache.pig.builtin.PigStorage) - scope-32
|
|---f1: Filter[bag] - scope-28
| |
| Equal To[boolean] - scope-31
| |
| |---Project[chararray][0] - scope-29
| |
| |---Constant(3) - scope-30
|
|---t1: New For Each(false,false,false)[bag] - scope-27
| |
| Cast[chararray] - scope-19
| |
| |---Project[bytearray][0] - scope-18
| |
| Cast[chararray] - scope-22
| |
| |---Project[bytearray][1] - scope-21
| |
| Cast[chararray] - scope-25
| |
| |---Project[bytearray][2] - scope-24
|
|---t1: Load(file:///Users/woody/test.txt:PigStorage(',')) - scope-17--------
Global sort: false
----------------
돼지의 버그입니까? 또는 그것을 피할 수있는 좋은 방법이 있습니까? 내 컴퓨터에
돼지 --version은 다음과 같습니다
Apache Pig version 0.9.2 (r1232772)
compiled Jan 18 2012, 07:57:19
미성숙 일지 모르지만 나는 기다렸습니다. –
정말 재밌 네요? : D –
두 번째 경로를 사용하지 않고 AS와 함께 LOAD 문에서 스키마를 할당 할 수 없습니까? 이는 실행 가능한 솔루션뿐만 아니라보다 효율적인 코딩처럼 보입니다. –