<?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 add the parent row values to child row in the NIFI flow file? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-add-the-parent-row-values-to-child-row-in-the-NIFI/m-p/388241#M246590</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110755"&gt;@kum&lt;/a&gt;&lt;A href="https://www.dollartree-compass.com" target="_self"&gt;dollar tree compass&lt;/A&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Example:&lt;BR /&gt;Flowfile data&lt;/P&gt;&lt;P&gt;branches,name,id,acc,serialNo&lt;/P&gt;&lt;P&gt;parent1,abc,123,1234567788,1&lt;/P&gt;&lt;P&gt;child1,eee,345&lt;/P&gt;&lt;P&gt;child2,rrr,678&lt;/P&gt;&lt;P&gt;parent2,mno,786,97865662762,2&lt;/P&gt;&lt;P&gt;child1,ttt,764&lt;/P&gt;&lt;P&gt;child2,ryy,456&lt;BR /&gt;output:&lt;/P&gt;&lt;P&gt;parent1,abc,123,1234567788,1&lt;/P&gt;&lt;P&gt;child1,eee,345,1234567788,1&lt;/P&gt;&lt;P&gt;child2,rrr,678,1234567788,1&lt;/P&gt;&lt;P&gt;parent2,mno,786,97865662762,2&lt;/P&gt;&lt;P&gt;child1,ttt,764,97865662762,2&lt;/P&gt;&lt;P&gt;child2,ryy,456,97865662762,2&lt;BR /&gt;I have to add the parent last two columns details to Childs of the same parent like parent1 last column details to child1, child2 rows in the flow file.&lt;/P&gt;&lt;P&gt;Please suggest a possible way to use the processor.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110755"&gt;@kum&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve this in NiFi using the following approach:&lt;/P&gt;&lt;P&gt;Extract the Parent Values: Use a processor like EvaluateJsonPath or UpdateAttribute to extract the parent last two columns' details from the FlowFile attributes and store them in new attributes.&lt;/P&gt;&lt;P&gt;Merge Parent Values with Child Rows: Use a processor like UpdateRecord or ExecuteScript to merge the parent values with the child rows. You'll need to write a custom script or configuration to append the parent values to each child row based on the parent's ID.&lt;/P&gt;&lt;P&gt;Here's a basic example using UpdateRecord processor:&lt;/P&gt;&lt;P&gt;Configure a schema that includes all columns from both parent and child rows.&lt;BR /&gt;Use a Record Reader to read the data.&lt;BR /&gt;Use a Record Writer to write the data.&lt;BR /&gt;In the UpdateRecord processor, use a RecordPath to conditionally update child rows with parent values based on their ID.&lt;BR /&gt;Use RecordPath expressions to refer to parent values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for line in flowfile:&lt;BR /&gt;if line.startswith("child"):&lt;BR /&gt;# Get parent values from attributes&lt;BR /&gt;parent_values = flowfile.getAttribute("parent_values")&lt;BR /&gt;# Append parent values to the child row&lt;BR /&gt;child_row = line + "," + parent_values&lt;BR /&gt;# Write the modified child row to the output FlowFile&lt;BR /&gt;output_flowfile.write(child_row)&lt;BR /&gt;else:&lt;BR /&gt;# If it's a parent row, update the parent values attribute&lt;BR /&gt;parent_values = extract_parent_values(line)&lt;BR /&gt;flowfile.setAttribute("parent_values", parent_values)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope my suggestion is helpful to you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regard,&lt;BR /&gt;angela683h&lt;/P&gt;</description>
    <pubDate>Thu, 23 May 2024 10:42:15 GMT</pubDate>
    <dc:creator>angela683h</dc:creator>
    <dc:date>2024-05-23T10:42:15Z</dc:date>
    <item>
      <title>How to add the parent row values to child row in the NIFI flow file?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-add-the-parent-row-values-to-child-row-in-the-NIFI/m-p/388234#M246589</link>
      <description>&lt;P&gt;Example:&lt;BR /&gt;Flowfile data&lt;/P&gt;&lt;P&gt;branches,name,id,acc,serialNo&lt;/P&gt;&lt;P&gt;parent1,abc,123,1234567788,1&lt;/P&gt;&lt;P&gt;child1,eee,345&lt;/P&gt;&lt;P&gt;child2,rrr,678&lt;/P&gt;&lt;P&gt;parent2,mno,786,97865662762,2&lt;/P&gt;&lt;P&gt;child1,ttt,764&lt;/P&gt;&lt;P&gt;child2,ryy,456&lt;BR /&gt;output:&lt;/P&gt;&lt;P&gt;parent1,abc,123,1234567788,1&lt;/P&gt;&lt;P&gt;child1,eee,345,1234567788,1&lt;/P&gt;&lt;P&gt;child2,rrr,678,1234567788,1&lt;/P&gt;&lt;P&gt;parent2,mno,786,97865662762,2&lt;/P&gt;&lt;P&gt;child1,ttt,764,97865662762,2&lt;/P&gt;&lt;P&gt;child2,ryy,456,97865662762,2&lt;BR /&gt;I have to add the parent last two columns details to Childs of the same parent like parent1 last column details to child1, child2 rows in the flow file.&lt;/P&gt;&lt;P&gt;Please suggest a possible way to use the processor.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 08:12:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-add-the-parent-row-values-to-child-row-in-the-NIFI/m-p/388234#M246589</guid>
      <dc:creator>kum</dc:creator>
      <dc:date>2024-05-23T08:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the parent row values to child row in the NIFI flow file?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-add-the-parent-row-values-to-child-row-in-the-NIFI/m-p/388241#M246590</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110755"&gt;@kum&lt;/a&gt;&lt;A href="https://www.dollartree-compass.com" target="_self"&gt;dollar tree compass&lt;/A&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Example:&lt;BR /&gt;Flowfile data&lt;/P&gt;&lt;P&gt;branches,name,id,acc,serialNo&lt;/P&gt;&lt;P&gt;parent1,abc,123,1234567788,1&lt;/P&gt;&lt;P&gt;child1,eee,345&lt;/P&gt;&lt;P&gt;child2,rrr,678&lt;/P&gt;&lt;P&gt;parent2,mno,786,97865662762,2&lt;/P&gt;&lt;P&gt;child1,ttt,764&lt;/P&gt;&lt;P&gt;child2,ryy,456&lt;BR /&gt;output:&lt;/P&gt;&lt;P&gt;parent1,abc,123,1234567788,1&lt;/P&gt;&lt;P&gt;child1,eee,345,1234567788,1&lt;/P&gt;&lt;P&gt;child2,rrr,678,1234567788,1&lt;/P&gt;&lt;P&gt;parent2,mno,786,97865662762,2&lt;/P&gt;&lt;P&gt;child1,ttt,764,97865662762,2&lt;/P&gt;&lt;P&gt;child2,ryy,456,97865662762,2&lt;BR /&gt;I have to add the parent last two columns details to Childs of the same parent like parent1 last column details to child1, child2 rows in the flow file.&lt;/P&gt;&lt;P&gt;Please suggest a possible way to use the processor.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110755"&gt;@kum&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve this in NiFi using the following approach:&lt;/P&gt;&lt;P&gt;Extract the Parent Values: Use a processor like EvaluateJsonPath or UpdateAttribute to extract the parent last two columns' details from the FlowFile attributes and store them in new attributes.&lt;/P&gt;&lt;P&gt;Merge Parent Values with Child Rows: Use a processor like UpdateRecord or ExecuteScript to merge the parent values with the child rows. You'll need to write a custom script or configuration to append the parent values to each child row based on the parent's ID.&lt;/P&gt;&lt;P&gt;Here's a basic example using UpdateRecord processor:&lt;/P&gt;&lt;P&gt;Configure a schema that includes all columns from both parent and child rows.&lt;BR /&gt;Use a Record Reader to read the data.&lt;BR /&gt;Use a Record Writer to write the data.&lt;BR /&gt;In the UpdateRecord processor, use a RecordPath to conditionally update child rows with parent values based on their ID.&lt;BR /&gt;Use RecordPath expressions to refer to parent values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for line in flowfile:&lt;BR /&gt;if line.startswith("child"):&lt;BR /&gt;# Get parent values from attributes&lt;BR /&gt;parent_values = flowfile.getAttribute("parent_values")&lt;BR /&gt;# Append parent values to the child row&lt;BR /&gt;child_row = line + "," + parent_values&lt;BR /&gt;# Write the modified child row to the output FlowFile&lt;BR /&gt;output_flowfile.write(child_row)&lt;BR /&gt;else:&lt;BR /&gt;# If it's a parent row, update the parent values attribute&lt;BR /&gt;parent_values = extract_parent_values(line)&lt;BR /&gt;flowfile.setAttribute("parent_values", parent_values)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope my suggestion is helpful to you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regard,&lt;BR /&gt;angela683h&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 10:42:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-add-the-parent-row-values-to-child-row-in-the-NIFI/m-p/388241#M246590</guid>
      <dc:creator>angela683h</dc:creator>
      <dc:date>2024-05-23T10:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the parent row values to child row in the NIFI flow file?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-add-the-parent-row-values-to-child-row-in-the-NIFI/m-p/388853#M246802</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110770"&gt;@angela683h&lt;/a&gt;&amp;nbsp; i used the same flow to achieve it and thanks for your support&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 09:50:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-add-the-parent-row-values-to-child-row-in-the-NIFI/m-p/388853#M246802</guid>
      <dc:creator>kum</dc:creator>
      <dc:date>2024-06-06T09:50:48Z</dc:date>
    </item>
  </channel>
</rss>

