<?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: Nifi how to sql join two flowfiles in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/298264#M219068</link>
    <description>&lt;P&gt;Hi mahendra&lt;/P&gt;&lt;P&gt;Thank you for you answer&lt;/P&gt;&lt;P&gt;In effect i'm using a nifi cluster so the second option isn't viable.&lt;/P&gt;&lt;P&gt;I will work in your first approach and return back when i will finish, to write my results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jun 2020 17:44:50 GMT</pubDate>
    <dc:creator>SirV</dc:creator>
    <dc:date>2020-06-18T17:44:50Z</dc:date>
    <item>
      <title>Nifi how to sql join two flowfiles</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/298227#M219042</link>
      <description>&lt;P&gt;Hi everyone&lt;/P&gt;
&lt;P&gt;I have spent several days trying to solve the following case.&lt;/P&gt;
&lt;P&gt;I need to join two flowfiles (master-detail) using Nifi flow, I tried using queryrecord and mergerecord but i couldn't did it.&lt;/P&gt;
&lt;P&gt;I have some json based files in a HDFS (Apache Spark) i need to make a join&amp;nbsp;and put de result in a database table (using nifi v1.11.4). I can read HDFS files but i cant' perform a join.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;master_file&lt;/STRONG&gt;&amp;nbsp;content:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp; "FALLA_ID" : 40217,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp; "FALLA_FECHA" : "1998-01-01 00:00:00",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp; "FALLA_RPT_NRO" : 25,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp; "FALLA_FRECUENCIA" : "60.0000"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;detail_file&lt;/STRONG&gt; content:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"FALLA_ID" : 40217,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"PRINCIPAL" : 1,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"FALLA_DTL_ID" : 1,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"FALLA_CLASE" : 1,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"TPF_FALLA_ID" : 1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;},&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"FALLA_ID" : 40217,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"PRINCIPAL" : 1,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"FALLA_DTL_ID" : 2,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"FALLA_CLASE" : 2,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;"TPF_FALLA_ID" : 5&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected_File content:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp; "FALLA_ID" : 40217,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp; "FALLA_FECHA" : "1998-01-01 00:00:00",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp; "FALLA_RPT_NRO" : 25,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp; "FALLA_FRECUENCIA" : "60.0000",&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp; "PRINCIPAL" : 1,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;&amp;nbsp;&amp;nbsp;"FALLA_CLASE" : 2&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier,monospace" size="2"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, the FALLA_ID field is the common field to make a join.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you some ideas?&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 22:03:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/298227#M219042</guid>
      <dc:creator>SirV</dc:creator>
      <dc:date>2020-06-17T22:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi how to sql join two flowfiles</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/298241#M219050</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/79142"&gt;@SirV&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see there are 2 possible options :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Merge two flow files based on common key ('&lt;SPAN&gt;FALLA_ID'&lt;/SPAN&gt;) using MergeContent processor :&lt;/P&gt;&lt;P&gt;&amp;nbsp; - Use EvaluateJsonPath first to get '&lt;SPAN&gt;FALLA_ID&lt;/SPAN&gt;' value to flow file attribute.&lt;/P&gt;&lt;P&gt;&amp;nbsp; - Use MergeContent processor to merge master-detail flow files, you need to use above step extracted&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FALLA_ID value in '&lt;SPAN&gt;Correlation Attribute Name' filed of MergeContent processor, so that it always merge flow files based on common FALL_ID value, so that you can get single merged file for each FALL_ID.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; - Use JOLTTransformJson to transform your merged json to desired format of output json.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Cache the first flow file content in to cache with key as '&lt;SPAN&gt;FALLA_ID' value&lt;/SPAN&gt;&amp;nbsp;and merge when second flow file arrives :&lt;/P&gt;&lt;P&gt;&amp;nbsp; - Use NiFi DistributedMap Cache (or any other external cache like Ignite) to cache the first flow.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; (It will be key-value pair in cache, so use key as FALL_ID and value as whole flow file content.)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Before caching the FF just check if that key is already present in cache, if already present means first (master/details) file has already arrived, so you can read that file and dont need to cache the current flow file.&lt;/P&gt;&lt;P&gt;&amp;nbsp; - Now you have 1 file in FF Content and a file in FF Attribute (which is read from cache), now you can use&amp;nbsp; ExceuteScript and write simple script (of your choice - python/groovy)&amp;nbsp; to club FF content and attributes to form a desired output json&lt;BR /&gt;&lt;BR /&gt;Note : This cache approach has to be picked carefully based on your file volumes and content size etc else it may fill up your memory.&lt;BR /&gt;Also if you are in multi node cluster mode, NiFi DistributedCache will be independent for each node and does not interact with other nodes so if master file and details files get picked by different nodes then logic will fail !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please ACCEPT if it helps/resolves your problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Mahendra&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 06:43:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/298241#M219050</guid>
      <dc:creator>hegdemahendra</dc:creator>
      <dc:date>2020-06-18T06:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi how to sql join two flowfiles</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/298264#M219068</link>
      <description>&lt;P&gt;Hi mahendra&lt;/P&gt;&lt;P&gt;Thank you for you answer&lt;/P&gt;&lt;P&gt;In effect i'm using a nifi cluster so the second option isn't viable.&lt;/P&gt;&lt;P&gt;I will work in your first approach and return back when i will finish, to write my results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 17:44:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/298264#M219068</guid>
      <dc:creator>SirV</dc:creator>
      <dc:date>2020-06-18T17:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi how to sql join two flowfiles</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/298312#M219096</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi mahendra&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm back, i did try your first approach and it helps me to solve my requirement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you again&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 15:13:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/298312#M219096</guid>
      <dc:creator>SirV</dc:creator>
      <dc:date>2020-06-19T15:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi how to sql join two flowfiles</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/351217#M236196</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/37332"&gt;@hegdemahendra&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/79142"&gt;@SirV&lt;/a&gt;&amp;nbsp;, I have a same scenario, and your point 1 resolution seems straight forward, but i didn't get in "MergeContent" processor. Your first data&lt;SPAN&gt;EvaluateJsonPath&amp;nbsp;is going to add in MergeContent with comman attribute "FILLA_ID" and detail_file content also going to MergeContent processor. but its not giving result with mapped field. sharing in my flow. Please suggest.&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="samrathal_0-1661951596411.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35419iD8BA4026BC36A543/image-size/medium?v=v2&amp;amp;px=400" role="button" title="samrathal_0-1661951596411.png" alt="samrathal_0-1661951596411.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 13:13:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/351217#M236196</guid>
      <dc:creator>samrathal</dc:creator>
      <dc:date>2022-08-31T13:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi how to sql join two flowfiles</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/358610#M237895</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/79142"&gt;@SirV&lt;/a&gt;&amp;nbsp; can you please send me the code , m also stuck in the same situation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 07:25:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-how-to-sql-join-two-flowfiles/m-p/358610#M237895</guid>
      <dc:creator>nikku</dc:creator>
      <dc:date>2022-11-30T07:25:18Z</dc:date>
    </item>
  </channel>
</rss>

