<?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 Re: Filter rows by comparing dates with Pig in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Filter-rows-by-comparing-dates-with-Pig/m-p/2294619#M67479</link>
    <description>Ok, since nobody replied to this thread i tried it myself after some researching and found a solution to this. 
&lt;BR /&gt;I'm sorry that i still can't upload an image but i try to tell you how my solution works. 
&lt;BR /&gt;Before filtering records with &amp;gt;= or &amp;lt;= and dates works you need to modify the dates a bit. So you need a tPigMap component right after loading the results with a tPigLoad component. With the map component you need to modify the date field to be processable (comparable) by Pig. 
&lt;BR /&gt;My expression looks like this (for the las_modified field in the output schema): 
&lt;BR /&gt; 
&lt;PRE&gt;ToDate(row1.last_modified, 'yyyy-MM-dd HH:mm:ss.SSS') &lt;/PRE&gt; 
&lt;BR /&gt;This tells Pig to convert the string into a date. (the .SSS part is needed because it was produced by Sqoop which i used to import RDBMS data from a mysql table and it is the microsends part) 
&lt;BR /&gt;The output of this component can then be connected to a tPigFilterRow component. I my case i wanted to get all records that have been modified since a date in a context variable. So my component settings look like follows: 
&lt;BR /&gt;Logical: AND 
&lt;BR /&gt;Column: last_modified 
&lt;BR /&gt;Operator: greater than 
&lt;BR /&gt;Value: 
&lt;BR /&gt; 
&lt;PRE&gt;"ToDate('" + TalendDate.formatDate("yyyy-MM-dd HH:mm:ss", context.latest_update) + "', 'yyyy-MM-dd HH:mm:ss')"&lt;/PRE&gt; 
&lt;BR /&gt;This will convert the "latest_update" date variable in my context into a string which then can be converted by Pig into a datetime object. 
&lt;BR /&gt;I hope you can comprehend what i did!</description>
    <pubDate>Tue, 28 Jun 2016 13:11:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-06-28T13:11:31Z</dc:date>
    <item>
      <title>Filter rows by comparing dates with Pig</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Filter-rows-by-comparing-dates-with-Pig/m-p/2294618#M67478</link>
      <description>Hey, 
&lt;BR /&gt;I'm trying to filter rows with the tPigFilterRow component. My file has a "last_modified" field that will be read as chararray and i want to compare it with a date that is stored in my context. I think i need to change both values to a datetime object with the ToDate() method provided by Pig but i'm not sure if that is the only or the best way. 
&lt;BR /&gt;Is it possible with the tPigMap or the tPigCode component? 
&lt;BR /&gt;Can you help me? 
&lt;BR /&gt;Thanks!</description>
      <pubDate>Sat, 16 Nov 2024 10:33:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Filter-rows-by-comparing-dates-with-Pig/m-p/2294618#M67478</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T10:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Filter rows by comparing dates with Pig</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Filter-rows-by-comparing-dates-with-Pig/m-p/2294619#M67479</link>
      <description>Ok, since nobody replied to this thread i tried it myself after some researching and found a solution to this. 
&lt;BR /&gt;I'm sorry that i still can't upload an image but i try to tell you how my solution works. 
&lt;BR /&gt;Before filtering records with &amp;gt;= or &amp;lt;= and dates works you need to modify the dates a bit. So you need a tPigMap component right after loading the results with a tPigLoad component. With the map component you need to modify the date field to be processable (comparable) by Pig. 
&lt;BR /&gt;My expression looks like this (for the las_modified field in the output schema): 
&lt;BR /&gt; 
&lt;PRE&gt;ToDate(row1.last_modified, 'yyyy-MM-dd HH:mm:ss.SSS') &lt;/PRE&gt; 
&lt;BR /&gt;This tells Pig to convert the string into a date. (the .SSS part is needed because it was produced by Sqoop which i used to import RDBMS data from a mysql table and it is the microsends part) 
&lt;BR /&gt;The output of this component can then be connected to a tPigFilterRow component. I my case i wanted to get all records that have been modified since a date in a context variable. So my component settings look like follows: 
&lt;BR /&gt;Logical: AND 
&lt;BR /&gt;Column: last_modified 
&lt;BR /&gt;Operator: greater than 
&lt;BR /&gt;Value: 
&lt;BR /&gt; 
&lt;PRE&gt;"ToDate('" + TalendDate.formatDate("yyyy-MM-dd HH:mm:ss", context.latest_update) + "', 'yyyy-MM-dd HH:mm:ss')"&lt;/PRE&gt; 
&lt;BR /&gt;This will convert the "latest_update" date variable in my context into a string which then can be converted by Pig into a datetime object. 
&lt;BR /&gt;I hope you can comprehend what i did!</description>
      <pubDate>Tue, 28 Jun 2016 13:11:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Filter-rows-by-comparing-dates-with-Pig/m-p/2294619#M67479</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-28T13:11:31Z</dc:date>
    </item>
  </channel>
</rss>

