<?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: ExecuteSQL dynamic query.. in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144087#M48373</link>
    <description>&lt;P&gt;So if the customer_name value for id=CCCDD was "Matt" then you'd like the first output row to read:&lt;/P&gt;&lt;PRE&gt;XXXXX, BBBBB, CCCCC, CCCDD, Matt&lt;/PRE&gt;&lt;P&gt;Is that correct? If so, you could do the following:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Use &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.SplitText/index.html"&gt;SplitText&lt;/A&gt; to split the incoming CSV into one flow file per line&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.ExtractText/index.html"&gt;ExtractText&lt;/A&gt; to store the four column values as attributes (example template called Working_With_CSV &lt;A target="_blank" href="https://cwiki.apache.org/confluence/display/NIFI/Example+Dataflow+Templates"&gt;here&lt;/A&gt;), let's assume the attribute for the fourth column is called "column.4"&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.ReplaceText/index.html"&gt;ReplaceText&lt;/A&gt; to set the content of the flow file to a SQL statement "select customer_name from table where id=${column.4} limit 1"&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.ExecuteSQL/index.html"&gt;ExecuteSQL&lt;/A&gt; to execute the statement&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.avro.ConvertAvroToJSON/index.html"&gt;ConvertAvroToJson&lt;/A&gt; to get the record into JSON (for further processing)&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.EvaluateJsonPath/index.html"&gt;EvaluateJsonPath&lt;/A&gt; to get the value of customer_name into an attribute (named "customer.name" with a JSON Path of $[0].customer_name or something like that)&lt;/LI&gt;&lt;LI&gt;ReplaceText to set the row back to the original columns plus the new one, with something like "${column.1},${column.2},${column.3},${column.4}, ${customer.name}"&lt;/LI&gt;&lt;LI&gt;(optional) &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.MergeContent/index.html"&gt;MergeContent&lt;/A&gt; to join the rows back together (if you need them as one file)&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Fri, 09 Dec 2016 01:39:15 GMT</pubDate>
    <dc:creator>mburgess</dc:creator>
    <dc:date>2016-12-09T01:39:15Z</dc:date>
    <item>
      <title>ExecuteSQL dynamic query..</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144086#M48372</link>
      <description>&lt;P&gt;Beloved forum,&lt;/P&gt;&lt;P&gt;is it possible to have dynamic query using ExecuteSQL processor ? &lt;/P&gt;&lt;P&gt;e.x. &lt;/P&gt;&lt;PRE&gt;FileX.txt content (comma separated)
XXXXX, BBBBB, CCCCC, CCCDD
XXXXX, EEEEE, CCCCC, DDDDD

outputstream
XXXXX, BBBBB, CCCCC, CCCDD, 'select customer_name from table where id=CCCDD limit 1'
XXXXX, EEEEE, CCCCC, DDDDD, 'select customer_name from table where id=DDDDD limit 1'

&lt;/PRE&gt;&lt;P&gt;I want to amend the select statement result to the original file ?&lt;/P&gt;&lt;P&gt;Thankssss&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 00:31:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144086#M48372</guid>
      <dc:creator>yahya_najjar</dc:creator>
      <dc:date>2016-12-09T00:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteSQL dynamic query..</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144087#M48373</link>
      <description>&lt;P&gt;So if the customer_name value for id=CCCDD was "Matt" then you'd like the first output row to read:&lt;/P&gt;&lt;PRE&gt;XXXXX, BBBBB, CCCCC, CCCDD, Matt&lt;/PRE&gt;&lt;P&gt;Is that correct? If so, you could do the following:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Use &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.SplitText/index.html"&gt;SplitText&lt;/A&gt; to split the incoming CSV into one flow file per line&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.ExtractText/index.html"&gt;ExtractText&lt;/A&gt; to store the four column values as attributes (example template called Working_With_CSV &lt;A target="_blank" href="https://cwiki.apache.org/confluence/display/NIFI/Example+Dataflow+Templates"&gt;here&lt;/A&gt;), let's assume the attribute for the fourth column is called "column.4"&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.ReplaceText/index.html"&gt;ReplaceText&lt;/A&gt; to set the content of the flow file to a SQL statement "select customer_name from table where id=${column.4} limit 1"&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.ExecuteSQL/index.html"&gt;ExecuteSQL&lt;/A&gt; to execute the statement&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.avro.ConvertAvroToJSON/index.html"&gt;ConvertAvroToJson&lt;/A&gt; to get the record into JSON (for further processing)&lt;/LI&gt;&lt;LI&gt;&lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.EvaluateJsonPath/index.html"&gt;EvaluateJsonPath&lt;/A&gt; to get the value of customer_name into an attribute (named "customer.name" with a JSON Path of $[0].customer_name or something like that)&lt;/LI&gt;&lt;LI&gt;ReplaceText to set the row back to the original columns plus the new one, with something like "${column.1},${column.2},${column.3},${column.4}, ${customer.name}"&lt;/LI&gt;&lt;LI&gt;(optional) &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.MergeContent/index.html"&gt;MergeContent&lt;/A&gt; to join the rows back together (if you need them as one file)&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Fri, 09 Dec 2016 01:39:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144087#M48373</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2016-12-09T01:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteSQL dynamic query..</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144088#M48374</link>
      <description>&lt;P&gt;its working, many thanks..&lt;/P&gt;&lt;P&gt;is it possible to have the same through executescript processor ?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 07:21:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144088#M48374</guid>
      <dc:creator>yahya_najjar</dc:creator>
      <dc:date>2016-12-09T07:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteSQL dynamic query..</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144089#M48375</link>
      <description>&lt;P&gt;is it possible to route files based on file content, &lt;/P&gt;&lt;P&gt;route to processor A if field2 = BBBBB, and to processor  B if field2 = AAAA ? &lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 09:50:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144089#M48375</guid>
      <dc:creator>yahya_najjar</dc:creator>
      <dc:date>2016-12-13T09:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteSQL dynamic query..</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144090#M48376</link>
      <description>&lt;P&gt;Yes, you can use something like the regex from step 2 above in a &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.RouteOnContent/index.html"&gt;RouteOnContent&lt;/A&gt; processor, or after the ExtractText (step 2 above) you can use &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.RouteOnAttribute/index.html"&gt;RouteOnAttribute&lt;/A&gt; looking for values of column.2.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 22:44:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144090#M48376</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2016-12-13T22:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteSQL dynamic query..</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144091#M48377</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;&lt;/P&gt;&lt;P&gt;shall I put the regex as property ? can you advise further how to define it ? &lt;/P&gt;&lt;P&gt;Thanks a million&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 00:00:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144091#M48377</guid>
      <dc:creator>yahya_najjar</dc:creator>
      <dc:date>2016-12-14T00:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteSQL dynamic query..</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144092#M48378</link>
      <description>&lt;P&gt;Yes you can add a dynamic property whose value is a regular expression (see the documentation for more details).&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 22:47:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/ExecuteSQL-dynamic-query/m-p/144092#M48378</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2016-12-14T22:47:41Z</dc:date>
    </item>
  </channel>
</rss>

