<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: How to FILTER in nested foreach in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-FILTER-in-nested-foreach/m-p/160423#M57232</link>
    <description>&lt;P&gt;We can achieve this using JOIN as follows. &lt;/P&gt;&lt;P&gt;1. JOIN A and B BY Id.&lt;/P&gt;&lt;P&gt; B_joined = JOIN A by Id, B by Id;&lt;/P&gt;&lt;P&gt;2. JOIN A and C by Id:&lt;/P&gt;&lt;P&gt;C_joined = JOIN A by Id, C by Id;&lt;/P&gt;&lt;P&gt;Now, we can get the required fields of A and C from their respective joined data sets as follows:&lt;/P&gt;&lt;P&gt;B_filtered  = FOREACH B_joined GENERATE B::Id,B::t1;&lt;/P&gt;&lt;P&gt;C_filtered  =FOREACH C_joined GENERATE C::Id;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Mar 2017 13:17:34 GMT</pubDate>
    <dc:creator>kib</dc:creator>
    <dc:date>2017-03-17T13:17:34Z</dc:date>
    <item>
      <title>How to FILTER in nested foreach</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-FILTER-in-nested-foreach/m-p/160422#M57231</link>
      <description>&lt;P&gt;I have many files. one of which,say, header.csv, serves as a header file,i.e., it contains primary key(in database analogy) which servers as foreign key in the rest of the files.&lt;/P&gt;&lt;P&gt;Now, I want to do FOREACH and FILTER as follows:&lt;/P&gt;&lt;P&gt;A =LOAD  'header.csv' AS (Id:chararray,f1:chararrat,f2:chararray);&lt;/P&gt;&lt;P&gt;B = LOAD  'file1.csv' AS (Id:chararray,t1:chararray);&lt;/P&gt;&lt;P&gt;C = LOAD  'file2.csv' AS (Id:chararray)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;..........&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;D = foreach A {&lt;/P&gt;&lt;P style="margin-left: 20px;"&gt;file1_filtered = FILTER file1 BY Id == A.Id;&lt;/P&gt;&lt;P&gt;     file2_filtered = FILTER file2 BY Id == A.Id;&lt;/P&gt;&lt;P style="margin-left: 20px;"&gt;GENERATE file1_filtered,file2_filtered;&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;Finally I need to access the relations file1_filtered and file2_filtered.
When I follow this approach I got the following error:&lt;/P&gt;&lt;P&gt;"ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: Pig script failed to parse:
&amp;lt;line 2651, column 28&amp;gt; expression is not a project expression: (Name: ScalarExpression) Type: null Uid: null)"&lt;/P&gt;&lt;P&gt;How can I achieve this in Pig?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 19:34:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-FILTER-in-nested-foreach/m-p/160422#M57231</guid>
      <dc:creator>kib</dc:creator>
      <dc:date>2017-03-16T19:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to FILTER in nested foreach</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-FILTER-in-nested-foreach/m-p/160423#M57232</link>
      <description>&lt;P&gt;We can achieve this using JOIN as follows. &lt;/P&gt;&lt;P&gt;1. JOIN A and B BY Id.&lt;/P&gt;&lt;P&gt; B_joined = JOIN A by Id, B by Id;&lt;/P&gt;&lt;P&gt;2. JOIN A and C by Id:&lt;/P&gt;&lt;P&gt;C_joined = JOIN A by Id, C by Id;&lt;/P&gt;&lt;P&gt;Now, we can get the required fields of A and C from their respective joined data sets as follows:&lt;/P&gt;&lt;P&gt;B_filtered  = FOREACH B_joined GENERATE B::Id,B::t1;&lt;/P&gt;&lt;P&gt;C_filtered  =FOREACH C_joined GENERATE C::Id;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 13:17:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-FILTER-in-nested-foreach/m-p/160423#M57232</guid>
      <dc:creator>kib</dc:creator>
      <dc:date>2017-03-17T13:17:34Z</dc:date>
    </item>
  </channel>
</rss>

