<?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 Renaming NiFi attributes  when you don't know how many attributes could be in the Flowfile at DesignTime in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Renaming-NiFi-attributes-when-you-don-t-know-how-many/m-p/136523#M27595</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Here is some background on what I want to do:&lt;/P&gt;&lt;P&gt;I'm reading HL7 message files and want to create an HBase table with that data.&lt;/P&gt;&lt;P&gt;The ExtractHL7Attributes processor parses HL7 messages and creates attributes in this fashion - &amp;lt;Segment Name&amp;gt; &amp;lt;dot&amp;gt; &amp;lt;Field Index&amp;gt;. If the segment is repeating, the naming will be &amp;lt;Segment Name&amp;gt; &amp;lt;underscore&amp;gt; &amp;lt;Segment Index&amp;gt; &amp;lt;dot&amp;gt; &amp;lt;Field Index&amp;gt;. Examples of attributes it creates are "MHS.12" with a value of "2.1" and "OBX_11.3" with a value of "93000^CPT4".&lt;/P&gt;&lt;P&gt;I want to write these attributes and their values to an HBase table, where the attributes (MHS.12) become column names and the values become the cells in the HBase table. This works fine, but the column names MHS.12 and OBX_11.3 are not very meaningful for an HBase table.&lt;/P&gt;&lt;P&gt;So, using an UpdateAttributes processor, I'm able to rename the columns as follows:&lt;/P&gt;&lt;P&gt;OBX_1.1 --&amp;gt; OBX_1_Set
ID&lt;/P&gt;&lt;P&gt;OBX_1.2 --&amp;gt; OBX_1_ValueType&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;OBX_8.1 --&amp;gt; OBX_8_Set ID&lt;/P&gt;&lt;P&gt;OBX_8.2 --&amp;gt; OBX_8_ValueType&lt;/P&gt;&lt;P&gt;But for this to work, you need to know how many attributes (or OBX segments) will be in the flow file at design time; Since OBX segment can repeat itself many times in the message and since
we can’t anticipate the max number of OBX segments a message could have at
design time, I am unable to rename all attributes at design time; &lt;/P&gt;&lt;P&gt;Any suggestions on how to make this work ?&lt;/P&gt;&lt;P&gt;Is creating a custom processor the route to take ?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Sun, 08 May 2016 10:53:53 GMT</pubDate>
    <dc:creator>Raj_B</dc:creator>
    <dc:date>2016-05-08T10:53:53Z</dc:date>
    <item>
      <title>Renaming NiFi attributes  when you don't know how many attributes could be in the Flowfile at DesignTime</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Renaming-NiFi-attributes-when-you-don-t-know-how-many/m-p/136523#M27595</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Here is some background on what I want to do:&lt;/P&gt;&lt;P&gt;I'm reading HL7 message files and want to create an HBase table with that data.&lt;/P&gt;&lt;P&gt;The ExtractHL7Attributes processor parses HL7 messages and creates attributes in this fashion - &amp;lt;Segment Name&amp;gt; &amp;lt;dot&amp;gt; &amp;lt;Field Index&amp;gt;. If the segment is repeating, the naming will be &amp;lt;Segment Name&amp;gt; &amp;lt;underscore&amp;gt; &amp;lt;Segment Index&amp;gt; &amp;lt;dot&amp;gt; &amp;lt;Field Index&amp;gt;. Examples of attributes it creates are "MHS.12" with a value of "2.1" and "OBX_11.3" with a value of "93000^CPT4".&lt;/P&gt;&lt;P&gt;I want to write these attributes and their values to an HBase table, where the attributes (MHS.12) become column names and the values become the cells in the HBase table. This works fine, but the column names MHS.12 and OBX_11.3 are not very meaningful for an HBase table.&lt;/P&gt;&lt;P&gt;So, using an UpdateAttributes processor, I'm able to rename the columns as follows:&lt;/P&gt;&lt;P&gt;OBX_1.1 --&amp;gt; OBX_1_Set
ID&lt;/P&gt;&lt;P&gt;OBX_1.2 --&amp;gt; OBX_1_ValueType&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;OBX_8.1 --&amp;gt; OBX_8_Set ID&lt;/P&gt;&lt;P&gt;OBX_8.2 --&amp;gt; OBX_8_ValueType&lt;/P&gt;&lt;P&gt;But for this to work, you need to know how many attributes (or OBX segments) will be in the flow file at design time; Since OBX segment can repeat itself many times in the message and since
we can’t anticipate the max number of OBX segments a message could have at
design time, I am unable to rename all attributes at design time; &lt;/P&gt;&lt;P&gt;Any suggestions on how to make this work ?&lt;/P&gt;&lt;P&gt;Is creating a custom processor the route to take ?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2016 10:53:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Renaming-NiFi-attributes-when-you-don-t-know-how-many/m-p/136523#M27595</guid>
      <dc:creator>Raj_B</dc:creator>
      <dc:date>2016-05-08T10:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming NiFi attributes  when you don't know how many attributes could be in the Flowfile at DesignTime</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Renaming-NiFi-attributes-when-you-don-t-know-how-many/m-p/136524#M27596</link>
      <description>&lt;P&gt;Raj, I think you can achieve what you're looking to do using an ExecuteScript processor after ExtractHL7Attributes to match against and rename the attributes in question. For example, the Ruby script attached below matches against the segment name and field index, and then uses the `element_names` mapping to rewrite the field index to its respective element name while keeping the segment name and segment index the same.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4084-execute-script-hl7-properties.png" style="width: 1690px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/22018iCB0EA0CF1EABAFD1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="4084-execute-script-hl7-properties.png" alt="4084-execute-script-hl7-properties.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4085-execute-script-hl7-provenance.png" style="width: 1590px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/22019i64AE72154FA02E3C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="4085-execute-script-hl7-provenance.png" alt="4085-execute-script-hl7-provenance.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;That said, with as many segments and elements as are in HL7, having to include this mapping may be more cumbersome than you were hoping. You can of course externalize it to a file or DB, but since the HL7 element names are fixed, I don't think the overhead is worth it. I thought a little bit about whether you could use ReplaceTextWithMapping here too but you'll still have to rewrite the attribute names so you're mapping on a contiguous string -- we need to match against segment name and field index, but segment index is in between in the ExtractHL7Attributes output.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 08:50:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Renaming-NiFi-attributes-when-you-don-t-know-how-many/m-p/136524#M27596</guid>
      <dc:creator>jfrazee</dc:creator>
      <dc:date>2019-08-19T08:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming NiFi attributes  when you don't know how many attributes could be in the Flowfile at DesignTime</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Renaming-NiFi-attributes-when-you-don-t-know-how-many/m-p/136525#M27597</link>
      <description>&lt;P&gt;Thanks very much for the detailed answer, ideas, screenshots, and sample code, that's very helpful.&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 10:41:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Renaming-NiFi-attributes-when-you-don-t-know-how-many/m-p/136525#M27597</guid>
      <dc:creator>Raj_B</dc:creator>
      <dc:date>2016-05-09T10:41:02Z</dc:date>
    </item>
  </channel>
</rss>

