<?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>topic Big Data module 2: Question on PIG operator FOREACH...GENERATE in SAS Academy for Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Big-Data-module-2-Question-on-PIG-operator-FOREACH-GENERATE/m-p/582873#M416</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Please see the attachment on PIG relating to an example on the operator. FOREACH...GENERATE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The syntax says:&amp;nbsp;"alias = FOREACH{block|nested block} ..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not see the combination of&amp;nbsp;block and nested block in the example in the attachment..&lt;/P&gt;&lt;P&gt;There are just 2 fields in the example : county and population.&amp;nbsp; Why of these is the nested block ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;ODesh.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2019 15:56:50 GMT</pubDate>
    <dc:creator>odesh</dc:creator>
    <dc:date>2019-08-21T15:56:50Z</dc:date>
    <item>
      <title>Big Data module 2: Question on PIG operator FOREACH...GENERATE</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Big-Data-module-2-Question-on-PIG-operator-FOREACH-GENERATE/m-p/582873#M416</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Please see the attachment on PIG relating to an example on the operator. FOREACH...GENERATE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The syntax says:&amp;nbsp;"alias = FOREACH{block|nested block} ..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not see the combination of&amp;nbsp;block and nested block in the example in the attachment..&lt;/P&gt;&lt;P&gt;There are just 2 fields in the example : county and population.&amp;nbsp; Why of these is the nested block ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;ODesh.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 15:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Big-Data-module-2-Question-on-PIG-operator-FOREACH-GENERATE/m-p/582873#M416</guid>
      <dc:creator>odesh</dc:creator>
      <dc:date>2019-08-21T15:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Big Data module 2: Question on PIG operator FOREACH...GENERATE</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Big-Data-module-2-Question-on-PIG-operator-FOREACH-GENERATE/m-p/582993#M418</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;&amp;nbsp; Answer from instructors:&lt;/P&gt;
&lt;P&gt;=== beginnning of comment ===&lt;/P&gt;
&lt;P&gt;The screen shot is showing just the accepted syntax that is appropriate for the FOREACH operator .. so you can use a block with columns as shown in the example&amp;nbsp;&amp;nbsp; &lt;U&gt;&lt;STRONG&gt;OR&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp;&amp;nbsp; you can use a nested block, &lt;U&gt;&lt;STRONG&gt;which the example does NOT show&lt;/STRONG&gt;&lt;/U&gt;.&amp;nbsp;&amp;nbsp; Here is an example of a next FOREACH block.&amp;nbsp; You will notice that is leveraging additional PIG operators and keywords to generate the desired columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The nested blocks is similar to writing nested subqueries in SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;result = foreach grpd_cstr{&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;total_orders = SUM(grpd_cstr_itm_cnt.itmCnt);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;srtd_orders = order grpd_cstr_itm_cnt by itmCnt desc;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;higest_bought = limit srtd_orders 1;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;generate FLATTEN(higest_bought),total_orders as totalCnt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;};&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;=== end of comment ===&lt;/P&gt;
&lt;P&gt;=== a useful link ===&lt;/P&gt;
&lt;P&gt;&lt;A href="https://pig.apache.org/docs/r0.17.0/basic.html" target="_blank"&gt;https://pig.apache.org/docs/r0.17.0/basic.html&lt;/A&gt; Pig syntax guide &lt;/P&gt;
&lt;P&gt;=== === ===&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this clarifies your question,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 13:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Big-Data-module-2-Question-on-PIG-operator-FOREACH-GENERATE/m-p/582993#M418</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-08-22T13:31:41Z</dc:date>
    </item>
  </channel>
</rss>

