<?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 Attribute expression in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378720#M243641</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/70529"&gt;@lafi_oussama&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If I am understanding correctly, this sounds like expected behavior.&amp;nbsp; You are writing a NiFi Expression Language (NEL) statement to an attribute via your python script so it is not being evaluated by the NEL process.&lt;BR /&gt;&lt;BR /&gt;I am not clear on why you are using a python script here anyway.&lt;BR /&gt;&lt;BR /&gt;As i understand your use case:&lt;BR /&gt;1. NiFi is ingesting files with various filenames.&lt;BR /&gt;2. Depending on the filename, you want to add an attr1 attribute to the FlowFile with a specific path value&lt;BR /&gt;3. If the filename does not match and value, you want to add an attr1 attribute to FlowFile with value "notfind".&lt;BR /&gt;&lt;BR /&gt;This use case can easily be handled by a single UpdateAttribute processor through the use of the "Advanced" functionality without needing to develop and manage a python script. The "Advanced" functionality&amp;nbsp; works like an If/Then/Else.&lt;BR /&gt;Would look something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1699378337727.png" style="width: 689px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/38859i2ED9E3534A139287/image-dimensions/689x496?v=v2" width="689" height="496" role="button" title="MattWho_0-1699378337727.png" alt="MattWho_0-1699378337727.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Outside the "Advanced" UI is the Else.&amp;nbsp; Any dynamic attributes add here are added to FlowFile only if the same attribute was NOT added by a rule in the "Advanced" section.&lt;BR /&gt;So here you set attr1 = "notfind".&lt;/P&gt;&lt;P&gt;Inside the "Advanced" section you create one or more rules.&amp;nbsp; Each rule has a Conditon (If) and an Action (then) sections.&amp;nbsp; If the condition NEL resolves to "true" then actions are applied to FlowFile.&amp;nbsp; So you set up a rule for each flowfile filename type. If none of teh rules match then the default attr = notfind is set.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_1-1699378817160.png" style="width: 710px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/38860i6773A5517E8A8062/image-dimensions/710x385?v=v2" width="710" height="385" role="button" title="MattWho_1-1699378817160.png" alt="MattWho_1-1699378817160.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on one or more of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2023 17:41:33 GMT</pubDate>
    <dc:creator>MattWho</dc:creator>
    <dc:date>2023-11-07T17:41:33Z</dc:date>
    <item>
      <title>NiFi Attribute expression</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378661#M243622</link>
      <description>&lt;P&gt;Hello All&lt;/P&gt;&lt;P&gt;I need your Helps&lt;/P&gt;&lt;P&gt;I have a flowfile attribute with this expression attr1="${filename:find('OD_NCE.*.gz'):ifElse("/isod/brt_fin_fd_OD_NCE_pipe_sep","notfind")}"&lt;/P&gt;&lt;P&gt;I want to have the value of expression not the string&lt;/P&gt;&lt;P&gt;How I can execute this.&lt;/P&gt;&lt;P&gt;For Information : I read this expression from file and after this I convert the content to attributes&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 16:46:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378661#M243622</guid>
      <dc:creator>lafi_oussama</dc:creator>
      <dc:date>2023-11-06T16:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Attribute expression</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378665#M243623</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/70529"&gt;@lafi_oussama&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am not clear in your ask here.&lt;BR /&gt;I assume you are using the above NiFi Expression language (NEL) statement in an Update Attribute processor?&lt;BR /&gt;&lt;BR /&gt;Assuming the NiFi FlowFile has a filename=&lt;STRONG&gt;blah-&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;OD_NCE-2023.gz&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${filename:find('OD_NCE.*.gz')  &amp;lt;-- resolves to true

:ifElse("/isod/brt_fin_fd_OD_NCE_pipe_sep","notfind")}  &amp;lt;-- since above is "true", the if else function would return "/isod/brt_fin_fd_OD_NCE_pipe_sep" and that woud be assigned to the "attr1" attribute on the outbound FlowFile.&lt;/LI-CODE&gt;&lt;P&gt;If your filename does not match your java regular expression "&lt;SPAN&gt;OD_NCE.*.gz" (result in false) would result in attr1 = notfind&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So I am not clear on what you are asking for:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;I want to have the value of expression not the string&lt;/LI-CODE&gt;&lt;P&gt;Can you provide an example of what you want to be assigned to FlowFile Attribute "attr1" and what you are actually getting?&lt;BR /&gt;&lt;BR /&gt;This info is also not clear to me:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; I read this expression from file and after this I convert the content to attributes&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;How are you reading expression from file?&amp;nbsp; What exactly are you reading?&lt;BR /&gt;Why are you converting FlowFile content to FlowFile attributes?&amp;nbsp; FlowFile Attributes reside within the NiFi's JVM heap.&amp;nbsp; So you'll want to avoid this unless absolutely&amp;nbsp;necessary and when you so, only extract the minimum needed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on one or more of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 19:08:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378665#M243623</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2023-11-06T19:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Attribute expression</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378699#M243633</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have a file that contains multiple properties like this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;${filename:find('OD_FUS.*.gz'):ifElse("/isod/brt_fin_fd_OD_FUS_pipe_sep",&lt;BR /&gt;${filename:find('OD_NCE.*.gz'):ifElse("/isod/brt_fin_fd_OD_NCE_pipe_sep",&lt;BR /&gt;${filename:find('DATA_Liste_Partenaire.*.gz'):ifElse("/baccarat/brt_fin_rn_partenaire","notfind")})})}&lt;/P&gt;&lt;P&gt;I developed python script that read this file and assign all this content on attribute attr1&amp;nbsp;&lt;/P&gt;&lt;P&gt;And my flow read multiple files and will check if the file match any pattern from will give him destination in HDFS example:&lt;/P&gt;&lt;P&gt;filename=OD_FUS20231010.gz.20231010.csv&amp;nbsp;&lt;/P&gt;&lt;P&gt;attr1 will have the value "/isod/brt_fin_fd_OD_FUS_pipe_sep"&lt;/P&gt;&lt;P&gt;and if the filename does not exists attr1 will have "notfind"&lt;/P&gt;&lt;P&gt;But now when I write the expression to attr1 he taked it as string he didn't execute it like this&amp;nbsp;${filename:find('OD_FUS.*.gz'):ifElse("/isod/brt_fin_fd_OD_FUS_pipe_sep",&lt;BR /&gt;${filename:find('OD_NCE.*.gz'):ifElse("/isod/brt_fin_fd_OD_NCE_pipe_sep",&lt;BR /&gt;${filename:find('DATA_Liste_Partenaire.*.gz'):ifElse("/baccarat/brt_fin_rn_partenaire","notfind")})})}&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 08:46:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378699#M243633</guid>
      <dc:creator>lafi_oussama</dc:creator>
      <dc:date>2023-11-07T08:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Attribute expression</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378720#M243641</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/70529"&gt;@lafi_oussama&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If I am understanding correctly, this sounds like expected behavior.&amp;nbsp; You are writing a NiFi Expression Language (NEL) statement to an attribute via your python script so it is not being evaluated by the NEL process.&lt;BR /&gt;&lt;BR /&gt;I am not clear on why you are using a python script here anyway.&lt;BR /&gt;&lt;BR /&gt;As i understand your use case:&lt;BR /&gt;1. NiFi is ingesting files with various filenames.&lt;BR /&gt;2. Depending on the filename, you want to add an attr1 attribute to the FlowFile with a specific path value&lt;BR /&gt;3. If the filename does not match and value, you want to add an attr1 attribute to FlowFile with value "notfind".&lt;BR /&gt;&lt;BR /&gt;This use case can easily be handled by a single UpdateAttribute processor through the use of the "Advanced" functionality without needing to develop and manage a python script. The "Advanced" functionality&amp;nbsp; works like an If/Then/Else.&lt;BR /&gt;Would look something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1699378337727.png" style="width: 689px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/38859i2ED9E3534A139287/image-dimensions/689x496?v=v2" width="689" height="496" role="button" title="MattWho_0-1699378337727.png" alt="MattWho_0-1699378337727.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Outside the "Advanced" UI is the Else.&amp;nbsp; Any dynamic attributes add here are added to FlowFile only if the same attribute was NOT added by a rule in the "Advanced" section.&lt;BR /&gt;So here you set attr1 = "notfind".&lt;/P&gt;&lt;P&gt;Inside the "Advanced" section you create one or more rules.&amp;nbsp; Each rule has a Conditon (If) and an Action (then) sections.&amp;nbsp; If the condition NEL resolves to "true" then actions are applied to FlowFile.&amp;nbsp; So you set up a rule for each flowfile filename type. If none of teh rules match then the default attr = notfind is set.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_1-1699378817160.png" style="width: 710px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/38860i6773A5517E8A8062/image-dimensions/710x385?v=v2" width="710" height="385" role="button" title="MattWho_1-1699378817160.png" alt="MattWho_1-1699378817160.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on one or more of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 17:41:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378720#M243641</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2023-11-07T17:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Attribute expression</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378740#M243649</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is like what you sad&lt;/P&gt;&lt;P&gt;But I have big number of expressions and can be added at any time so I want at every change go to the processor and add new expression, so my solution was to create file that contains all expressions and with python write its to attr1&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 08:37:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378740#M243649</guid>
      <dc:creator>lafi_oussama</dc:creator>
      <dc:date>2023-11-08T08:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Attribute expression</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378747#M243655</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the solution is to add updateAttribute:&lt;/P&gt;&lt;P&gt;attr1=${attr1:evaluateELString()}&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 10:51:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Attribute-expression/m-p/378747#M243655</guid>
      <dc:creator>lafi_oussama</dc:creator>
      <dc:date>2023-11-08T10:51:03Z</dc:date>
    </item>
  </channel>
</rss>

