<?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: Attributes lost after running SelectHiveQL in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Attributes-lost-after-running-SelectHiveQL/m-p/176887#M77958</link>
    <description>&lt;A rel="user" href="https://community.cloudera.com/users/17015/bearchui.html" nodeid="17015" target="_blank"&gt;@adam chui&lt;/A&gt;&lt;P&gt;As per the documentation of SelectHiveQL processor states that If it is triggered by an incoming FlowFile, then attributes of that FlowFile will be available when evaluating the select query. FlowFile attribute 'selecthiveql.row.count' indicates how many rows were selected. But you can file a jira addressing the issue found.&lt;/P&gt;&lt;P&gt;As a work around to fix this issue You can use &lt;STRONG&gt;PutDistributeCacheMap processor&lt;/STRONG&gt; to keep all your attributes in cache server and fetch the attributes from cache server using &lt;STRONG&gt;FetchDistributeCacheMap processor.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Sample Flow Example:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="72638-flow.png" style="width: 1930px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19635i7BCA77AF4182AAEB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72638-flow.png" alt="72638-flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;i'm using &lt;STRONG&gt;GenerateFlowFile&lt;/STRONG&gt; processor and adding 3 attributes to the flowfile&lt;/P&gt;&lt;P&gt;&lt;EM&gt;attr1
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;56&lt;/PRE&gt;

&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;attr2
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;67&lt;/PRE&gt;

&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;attr3
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;89&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;ReplaceText Processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Search Value
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;(?s)(^.*$)&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Replacement Value
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;${allAttributes("attr1","attr2","attr3"):join("|")}&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;//i'm using allAttributes and keeping all the attributes with "|" pipe delimiter(output flowfile will be 1|2|3)&lt;BR /&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;EM&gt;Maximum Buffer Size
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;1 MB //needs to change the size if the content is more than 1MB size.&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Replacement Strategy
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Always Replace&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Evaluation Mode
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Entire text&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Use &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#multi" target="_blank" rel="nofollow noopener noreferrer"&gt;this&lt;/A&gt; link to evaluate multiple attributes.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;UpdateAttribute:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;We are using this processor to change the filename of flowfile to UUID because We cannot not refer to use UUID as cache identifier&lt;STRONG&gt; reason is &lt;/STRONG&gt;output from SelectHiveQL processor is having same filename but different UUID(i.e until selecthiveq processor flowfile having one uniqueid after selecthiveql processor different uuid).&lt;STRONG&gt;**&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Add &lt;STRONG&gt;new property&lt;/STRONG&gt; as&lt;/P&gt;&lt;P&gt;&lt;EM&gt;filename&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;${UUID()}&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;PutDistributeCache processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Configure &lt;STRONG&gt;DistributedMapCacheServer,&lt;/STRONG&gt;&lt;STRONG&gt;DistributedMapCacheClientService&lt;/STRONG&gt; and enable them(you need to change cache number of entriesas per your needs,&lt;STRONG&gt;persistence&lt;/STRONG&gt;&lt;STRONG&gt; directory&lt;/STRONG&gt; if &lt;STRONG&gt;not mentioned&lt;/STRONG&gt; then all the entries will be &lt;STRONG&gt;stored in memory&lt;/STRONG&gt;).&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Cache Entry Identifier
&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;${filename}&lt;/PRE&gt;&lt;P&gt;Now we have changed the flowfile content and cached the output content with the filename.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;SelectHiveQL processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Feed success relation to SelectHiveQL processor once the processor outputs flowfile with content of the flowfile then feed the success relationship to &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;FetchDistributeCacheMap:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Configs:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="72636-fetchdistributecache.png" style="width: 1720px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19636i0A88C94D6E900ABB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72636-fetchdistributecache.png" alt="72636-fetchdistributecache.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Cache Entry Identifier
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;${filename:substringBefore('.')} //because based on output ff format we are going to have .avro/.csv extensions&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Distributed Cache Service
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;DistributedMapCacheClientService&lt;/PRE&gt;

&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Put Cache Value In Attribute
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;cache_value //the cached content will be put in to this attribute instead putting into flowfile content&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Max Length To Put In Attribute
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;256 //needs to change the value if max length is more than this value&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Output:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="72637-cached-value.png" style="width: 801px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19637i25428C3B6ACB24EB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72637-cached-value.png" alt="72637-cached-value.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Flowfile will have attribute called cached.value then you can rebuild all your attributes by using &lt;A href="https://community.hortonworks.com/questions/188338/%E2%80%8Bhttps://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#getdelimitedfield" rel="nofollow noopener noreferrer" target="_blank"&gt;getDelimitedField&lt;/A&gt; function&lt;/P&gt;&lt;PRE&gt; ${cached.value:getDelimitedField(1, '|')} //will give attr1 field&lt;/PRE&gt;&lt;P&gt;Even without rebuilding all the attributes again by using above expression language you can directly pull the required attribute value and use them in your flow.&lt;BR /&gt;I have attached my sample flow.xml below, save and upload the xml to your instance and change the as per your needs.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/72639-selecthiveql-attributes-188338.xml" target="_blank"&gt;selecthiveql-attributes-188338.xml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer&lt;/STRONG&gt;, That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://community.cloudera.com/t5/image/serverpage/image-id/6480iDF648D998A3286C2/image-size/large?v=1.0&amp;amp;px=999" border="0" alt="selecthiveql.png" title="selecthiveql.png" /&gt;</description>
    <pubDate>Sun, 18 Aug 2019 09:50:55 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2019-08-18T09:50:55Z</dc:date>
    <item>
      <title>Attributes lost after running SelectHiveQL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Attributes-lost-after-running-SelectHiveQL/m-p/176886#M77957</link>
      <description>&lt;P&gt;Attributes lost after running SelectHiveQL, do you know why? Is it a bug? And how to fix it?&lt;/P&gt;&lt;P&gt;I have some attributes updated before SelectHiveQL, but all the attributes set disappear after running SelectHiveQL, please help.&lt;/P&gt;</description>
      <pubDate>Sun, 06 May 2018 06:33:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Attributes-lost-after-running-SelectHiveQL/m-p/176886#M77957</guid>
      <dc:creator>adamchui</dc:creator>
      <dc:date>2018-05-06T06:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Attributes lost after running SelectHiveQL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Attributes-lost-after-running-SelectHiveQL/m-p/176887#M77958</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/17015/bearchui.html" nodeid="17015" target="_blank"&gt;@adam chui&lt;/A&gt;&lt;P&gt;As per the documentation of SelectHiveQL processor states that If it is triggered by an incoming FlowFile, then attributes of that FlowFile will be available when evaluating the select query. FlowFile attribute 'selecthiveql.row.count' indicates how many rows were selected. But you can file a jira addressing the issue found.&lt;/P&gt;&lt;P&gt;As a work around to fix this issue You can use &lt;STRONG&gt;PutDistributeCacheMap processor&lt;/STRONG&gt; to keep all your attributes in cache server and fetch the attributes from cache server using &lt;STRONG&gt;FetchDistributeCacheMap processor.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Sample Flow Example:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="72638-flow.png" style="width: 1930px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19635i7BCA77AF4182AAEB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72638-flow.png" alt="72638-flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;i'm using &lt;STRONG&gt;GenerateFlowFile&lt;/STRONG&gt; processor and adding 3 attributes to the flowfile&lt;/P&gt;&lt;P&gt;&lt;EM&gt;attr1
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;56&lt;/PRE&gt;

&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;attr2
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;67&lt;/PRE&gt;

&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;attr3
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;89&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;ReplaceText Processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Search Value
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;(?s)(^.*$)&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Replacement Value
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;${allAttributes("attr1","attr2","attr3"):join("|")}&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;//i'm using allAttributes and keeping all the attributes with "|" pipe delimiter(output flowfile will be 1|2|3)&lt;BR /&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;EM&gt;Maximum Buffer Size
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;1 MB //needs to change the size if the content is more than 1MB size.&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Replacement Strategy
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Always Replace&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Evaluation Mode
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Entire text&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Use &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#multi" target="_blank" rel="nofollow noopener noreferrer"&gt;this&lt;/A&gt; link to evaluate multiple attributes.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;UpdateAttribute:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;We are using this processor to change the filename of flowfile to UUID because We cannot not refer to use UUID as cache identifier&lt;STRONG&gt; reason is &lt;/STRONG&gt;output from SelectHiveQL processor is having same filename but different UUID(i.e until selecthiveq processor flowfile having one uniqueid after selecthiveql processor different uuid).&lt;STRONG&gt;**&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Add &lt;STRONG&gt;new property&lt;/STRONG&gt; as&lt;/P&gt;&lt;P&gt;&lt;EM&gt;filename&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;${UUID()}&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;PutDistributeCache processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Configure &lt;STRONG&gt;DistributedMapCacheServer,&lt;/STRONG&gt;&lt;STRONG&gt;DistributedMapCacheClientService&lt;/STRONG&gt; and enable them(you need to change cache number of entriesas per your needs,&lt;STRONG&gt;persistence&lt;/STRONG&gt;&lt;STRONG&gt; directory&lt;/STRONG&gt; if &lt;STRONG&gt;not mentioned&lt;/STRONG&gt; then all the entries will be &lt;STRONG&gt;stored in memory&lt;/STRONG&gt;).&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Cache Entry Identifier
&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;${filename}&lt;/PRE&gt;&lt;P&gt;Now we have changed the flowfile content and cached the output content with the filename.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;SelectHiveQL processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Feed success relation to SelectHiveQL processor once the processor outputs flowfile with content of the flowfile then feed the success relationship to &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;FetchDistributeCacheMap:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Configs:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="72636-fetchdistributecache.png" style="width: 1720px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19636i0A88C94D6E900ABB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72636-fetchdistributecache.png" alt="72636-fetchdistributecache.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Cache Entry Identifier
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;${filename:substringBefore('.')} //because based on output ff format we are going to have .avro/.csv extensions&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Distributed Cache Service
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;DistributedMapCacheClientService&lt;/PRE&gt;

&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Put Cache Value In Attribute
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;cache_value //the cached content will be put in to this attribute instead putting into flowfile content&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;Max Length To Put In Attribute
&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;256 //needs to change the value if max length is more than this value&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Output:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="72637-cached-value.png" style="width: 801px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19637i25428C3B6ACB24EB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72637-cached-value.png" alt="72637-cached-value.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Flowfile will have attribute called cached.value then you can rebuild all your attributes by using &lt;A href="https://community.hortonworks.com/questions/188338/%E2%80%8Bhttps://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#getdelimitedfield" rel="nofollow noopener noreferrer" target="_blank"&gt;getDelimitedField&lt;/A&gt; function&lt;/P&gt;&lt;PRE&gt; ${cached.value:getDelimitedField(1, '|')} //will give attr1 field&lt;/PRE&gt;&lt;P&gt;Even without rebuilding all the attributes again by using above expression language you can directly pull the required attribute value and use them in your flow.&lt;BR /&gt;I have attached my sample flow.xml below, save and upload the xml to your instance and change the as per your needs.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/72639-selecthiveql-attributes-188338.xml" target="_blank"&gt;selecthiveql-attributes-188338.xml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer&lt;/STRONG&gt;, That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://community.cloudera.com/t5/image/serverpage/image-id/6480iDF648D998A3286C2/image-size/large?v=1.0&amp;amp;px=999" border="0" alt="selecthiveql.png" title="selecthiveql.png" /&gt;</description>
      <pubDate>Sun, 18 Aug 2019 09:50:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Attributes-lost-after-running-SelectHiveQL/m-p/176887#M77958</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T09:50:55Z</dc:date>
    </item>
  </channel>
</rss>

