<?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 String value in nifi Custom Processor code?? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-add-String-value-in-nifi-Custom-Processor-code/m-p/192957#M68531</link>
    <description>&lt;P&gt;With nifi 1.3 you have the record based processors. So you can forward the output of executesql or your custom processor to QueryRecord. Set it up to read Avro. Now add a query like so select col_a,col_b..'${query_id}','${query_time}','${query_end_time}' from flowfile'. this will add the data you need to the query resultset.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="39538-screen-shot-2017-09-26-at-122146-am.png" style="width: 1634px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18236iDA156B357315336E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="39538-screen-shot-2017-09-26-at-122146-am.png" alt="39538-screen-shot-2017-09-26-at-122146-am.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Aug 2019 07:04:27 GMT</pubDate>
    <dc:creator>knarayanan</dc:creator>
    <dc:date>2019-08-18T07:04:27Z</dc:date>
    <item>
      <title>How to add String value in nifi Custom Processor code??</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-add-String-value-in-nifi-Custom-Processor-code/m-p/192954#M68528</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I have created custom processor same like ExecuteSQL.&lt;BR /&gt;after executing query all data get in resultset  .&lt;BR /&gt;I have to add one external string value .&lt;BR /&gt;String queryID="123456" -it may be static or dynamic.&lt;BR /&gt;Where I have to add that value in resultSet or flowfile?? and how to add that value??&lt;BR /&gt;using convert AvroToJson I have take that queryID using EvaluateJsonPath processor and use further operation.&lt;BR /&gt;the code is same like below,&lt;/P&gt;&lt;P&gt;Can someone point me at an example to get me going&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;--------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;fileToProcess = session.write(fileToProcess, new OutputStreamCallback() {&lt;BR /&gt;  @Overrid&lt;BR /&gt;  public void process(final OutputStream out) throws IOException {&lt;BR /&gt;  try {&lt;BR /&gt;  logger.debug("Executing query {}", new Object[]{selectQuery});&lt;BR /&gt;  final ResultSet resultSet = st.executeQuery(selectQuery);&lt;BR /&gt;  final JdbcCommon.AvroConversionOptions options = JdbcCommon.AvroConversionOptions.builder()&lt;BR /&gt;  .convertNames(convertNamesForAvro)&lt;BR /&gt;  .useLogicalTypes(useAvroLogicalTypes)&lt;BR /&gt;  .defaultPrecision(defaultPrecision)&lt;BR /&gt;  .defaultScale(defaultScale)&lt;BR /&gt;  .build();&lt;BR /&gt;  nrOfRows.set(JdbcCommon.convertToAvroStream(resultSet, out, options, null));&lt;BR /&gt;  } catch (final SQLException e) {&lt;BR /&gt;  throw new ProcessException(e);&lt;BR /&gt;  }&lt;BR /&gt;  }&lt;BR /&gt;  });&lt;BR /&gt;&lt;BR /&gt;  long duration = stopWatch.getElapsed(TimeUnit.MILLISECONDS);&lt;BR /&gt;&lt;BR /&gt;  // set attribute how many rows were selected&lt;BR /&gt;  fileToProcess = session.putAttribute(fileToProcess, RESULT_ROW_COUNT, String.valueOf(nrOfRows.get()));&lt;BR /&gt;  fileToProcess = session.putAttribute(fileToProcess, RESULT_QUERY_DURATION, String.valueOf(duration));&lt;BR /&gt;  fileToProcess = session.putAttribute(fileToProcess, CoreAttributes.MIME_TYPE.key(), JdbcCommon.MIME_TYPE_AVRO_BINARY);&lt;BR /&gt;&lt;BR /&gt;  logger.info("{} contains {} Avro records; transferring to 'success'",&lt;BR /&gt;  new Object[]{fileToProcess, nrOfRows.get()});&lt;BR /&gt;  session.getProvenanceReporter().modifyContent(fileToProcess, "Retrieved " + nrOfRows.get() + " rows", duration);&lt;BR /&gt;session.transfer(fileToProcess, REL_SUCCESS);&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 12:57:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-add-String-value-in-nifi-Custom-Processor-code/m-p/192954#M68528</guid>
      <dc:creator>waghmithu</dc:creator>
      <dc:date>2017-09-25T12:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to add String value in nifi Custom Processor code??</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-add-String-value-in-nifi-Custom-Processor-code/m-p/192955#M68529</link>
      <description>&lt;P&gt;Wouldn't it make sense to add this as an attribute? See the calls to session.putAttribute() in the code above.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 15:13:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-add-String-value-in-nifi-Custom-Processor-code/m-p/192955#M68529</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-09-25T15:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to add String value in nifi Custom Processor code??</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-add-String-value-in-nifi-Custom-Processor-code/m-p/192956#M68530</link>
      <description>&lt;P&gt;after executing query i get resultset. now i want add some value into resultset like query id , query start time , query end time in resultset, so i can get in nifi flow.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 15:52:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-add-String-value-in-nifi-Custom-Processor-code/m-p/192956#M68530</guid>
      <dc:creator>waghmithu</dc:creator>
      <dc:date>2017-09-25T15:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to add String value in nifi Custom Processor code??</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-add-String-value-in-nifi-Custom-Processor-code/m-p/192957#M68531</link>
      <description>&lt;P&gt;With nifi 1.3 you have the record based processors. So you can forward the output of executesql or your custom processor to QueryRecord. Set it up to read Avro. Now add a query like so select col_a,col_b..'${query_id}','${query_time}','${query_end_time}' from flowfile'. this will add the data you need to the query resultset.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="39538-screen-shot-2017-09-26-at-122146-am.png" style="width: 1634px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18236iDA156B357315336E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="39538-screen-shot-2017-09-26-at-122146-am.png" alt="39538-screen-shot-2017-09-26-at-122146-am.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 07:04:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-add-String-value-in-nifi-Custom-Processor-code/m-p/192957#M68531</guid>
      <dc:creator>knarayanan</dc:creator>
      <dc:date>2019-08-18T07:04:27Z</dc:date>
    </item>
  </channel>
</rss>

