Pig Join 使用 OR 条件运算符抛出错误
Pig Join by using OR conditional operator throws error
child = load 'file_name' using PigStorage('\t') as (child_code : chararray, child_id : int, child_precode_id : int);
parents = load 'file_name' using PigStorage('\t') as (child_id : int, child_internal_id : chararray, mother_id : int, father_id : int);
joined = JOIN child by child_id, parents by child_id;
mainparent = FOREACH joined GENERATE child_id as child_id_source, child_precode_id, child_code;
store parent into '(location of file)' using PigStorage('\t');
childfirst = JOIN mainparent by (child_id_source), parents by (mother_id OR father_id);
firstgen = FOREACH childfirst GENERATE child_id, child_precode_id, child_code;
store firstgen into 'file_location' using PigStorage('\t');
当我使用 OR 条件时出现以下错误:
ERROR org.apache.pig.PigServer - exception during parsing: Error
during parsing. Pig script failed to parse:
NoViableAltException(91@[]) Failed to parse: Pig script failed to
parse: NoViableAltException(91@[])
以下语法不正确,Pig 中没有条件连接
childfirst = JOIN mainparent by (child_id_source), parents by (mother_id OR father_id);
如果您想将一个键与另一个键的关系连接到 2 个键上,则创建两个连接并合并 dataset.Note,您可能必须区分结果关系。
childfirst = JOIN mainparent by (child_id_source), parents by (mother_id);
childfirst1 = JOIN mainparent by (child_id_source), parents by (father_id);
childfirst2 = UNION childfirst,childfirst1;
childfirst3 = DISTINCT childfirst2;
firstgen = FOREACH childfirst3 GENERATE child_id, child_precode_id, child_code;
store firstgen into 'file_location' using PigStorage('\t');
child = load 'file_name' using PigStorage('\t') as (child_code : chararray, child_id : int, child_precode_id : int);
parents = load 'file_name' using PigStorage('\t') as (child_id : int, child_internal_id : chararray, mother_id : int, father_id : int);
joined = JOIN child by child_id, parents by child_id;
mainparent = FOREACH joined GENERATE child_id as child_id_source, child_precode_id, child_code;
store parent into '(location of file)' using PigStorage('\t');
childfirst = JOIN mainparent by (child_id_source), parents by (mother_id OR father_id);
firstgen = FOREACH childfirst GENERATE child_id, child_precode_id, child_code;
store firstgen into 'file_location' using PigStorage('\t');
当我使用 OR 条件时出现以下错误:
ERROR org.apache.pig.PigServer - exception during parsing: Error during parsing. Pig script failed to parse: NoViableAltException(91@[]) Failed to parse: Pig script failed to parse: NoViableAltException(91@[])
以下语法不正确,Pig 中没有条件连接
childfirst = JOIN mainparent by (child_id_source), parents by (mother_id OR father_id);
如果您想将一个键与另一个键的关系连接到 2 个键上,则创建两个连接并合并 dataset.Note,您可能必须区分结果关系。
childfirst = JOIN mainparent by (child_id_source), parents by (mother_id);
childfirst1 = JOIN mainparent by (child_id_source), parents by (father_id);
childfirst2 = UNION childfirst,childfirst1;
childfirst3 = DISTINCT childfirst2;
firstgen = FOREACH childfirst3 GENERATE child_id, child_precode_id, child_code;
store firstgen into 'file_location' using PigStorage('\t');