title: Error about schema name when using UpdateRecord with AvroReader and AvroRecordSetWriter in Apache Ni-Fi
body: <p>I have created an Apache Ni-Fi pipeline to fetch data from a MySQL server into InfluxDB.</p>
  <p>The first processor is QueryDatabaseTable which uses DBCPConnectioPool to connect to the MySQL database.</p>
  <p>This processor does some data transformations (column drop, column rename and data filtering (dropping out certain rows)).</p>
  <p>The content of the output of this processor is the following one:</p>
  <pre><code>[ {
    &quot;original_id&quot; : 1,
    &quot;time_stamp&quot; : &quot;2021-01-11 09:00:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 3,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 2,
    &quot;time_stamp&quot; : &quot;2021-01-11 09:10:00.0&quot;,
    &quot;apartment_id&quot; : null,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 3,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 3,
    &quot;time_stamp&quot; : &quot;2021-01-11 09:20:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : null,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 3,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 4,
    &quot;time_stamp&quot; : &quot;2021-01-11 09:30:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : null,
    &quot;metric&quot; : 3,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 5,
    &quot;time_stamp&quot; : &quot;2021-01-11 10:00:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 18,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 6,
    &quot;time_stamp&quot; : &quot;2021-01-11 10:10:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 20,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 7,
    &quot;time_stamp&quot; : &quot;2021-01-11 10:20:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 7,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 8,
    &quot;time_stamp&quot; : &quot;2021-01-11 10:30:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 4,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 9,
    &quot;time_stamp&quot; : &quot;2021-01-11 10:40:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 8,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 10,
    &quot;time_stamp&quot; : &quot;2021-01-11 11:00:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 150,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 5.0
  }, {
    &quot;original_id&quot; : 11,
    &quot;time_stamp&quot; : &quot;2021-01-11 12:00:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 5,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 0.0
  }, {
    &quot;original_id&quot; : 12,
    &quot;time_stamp&quot; : &quot;2021-01-11 12:10:00.0&quot;,
    &quot;apartment_id&quot; : 69,
    &quot;room_id&quot; : 77,
    &quot;sensor_id&quot; : 8,
    &quot;metric&quot; : 5,
    &quot;valueSum&quot; : 25.0,
    &quot;valueDiv&quot; : 0.0
  } ]
  </code></pre>
  <p>The next processor is UpdateRecord, which I use to do some further data transformation (replace NULL values with zeros in some columns and adding a new column).</p>
  <p>Those are the relevant configurations in the processor for the above mentioned data transformations:</p>
  <ul>
  <li>/apartment_id: ${field.value:replaceNull(0)}</li>
  <li>/room_id: ${field.value:replaceNull(0)}</li>
  <li>/sensor_id: ${field.value:replaceNull(0)}</li>
  <li>/original_db: 1</li>
  </ul>
  <p>As a record reader I use AvroReader controller service with the following configurations:</p>
  <ul>
  <li>Schema Access Strategy: Use 'Schema Name' Property</li>
  <li>Schema Registry: AvroSchemaRegistry</li>
  <li>Schema Name: $(firstschema)</li>
  </ul>
  <p>As a record writer I use AvroRecordSetWriter controller service with the following configurations:</p>
  <ul>
  <li>Schema Write Strategy: Embeded Avro Schema</li>
  <li>Schema Access Strategy: Use 'Schema Name' Property</li>
  <li>Schema Registry: AvroSchemaRegistry</li>
  <li>Schema Name: $(secondschema)</li>
  </ul>
  <p>In the AvroSchemaRegistry I have configured the following properties:</p>
  <p>firstschema</p>
  <pre><code>{
       &quot;type&quot;: &quot;record&quot;,
       &quot;namespace&quot;: &quot;mysql.influx&quot;,
       &quot;name&quot;: &quot;firstschema&quot;,
       &quot;fields&quot;: [
         { &quot;name&quot;: &quot;time_stamp&quot;, &quot;type&quot;: &quot;string&quot; },
         { &quot;name&quot;: &quot;apartment_id&quot;, &quot;type&quot;: &quot;int&quot; },
         { &quot;name&quot;: &quot;room_id&quot;, &quot;type&quot;: &quot;int&quot; },
         { &quot;name&quot;: &quot;sensor_id&quot;, &quot;type&quot;: &quot;int&quot; },
         { &quot;name&quot;: &quot;metric&quot;, &quot;type&quot;: &quot;int&quot; },
         { &quot;name&quot;: &quot;original_id&quot;, &quot;type&quot;: &quot;long&quot; },
         { &quot;name&quot;: &quot;valueSum&quot;, &quot;type&quot;: &quot;double&quot; },
         { &quot;name&quot;: &quot;valueDiv&quot;, &quot;type&quot;: &quot;double&quot; }
       ]
  }
  </code></pre>
  <p>secondschema</p>
  <pre><code>{
       &quot;type&quot;: &quot;record&quot;,
       &quot;namespace&quot;: &quot;mysql.influx&quot;,
       &quot;name&quot;: &quot;secondschema&quot;,
       &quot;fields&quot;: [
         { &quot;name&quot;: &quot;time_stamp&quot;, &quot;type&quot;: &quot;string&quot; },
         { &quot;name&quot;: &quot;apartment_id&quot;, &quot;type&quot;: &quot;int&quot; },
         { &quot;name&quot;: &quot;room_id&quot;, &quot;type&quot;: &quot;int&quot; },
         { &quot;name&quot;: &quot;sensor_id&quot;, &quot;type&quot;: &quot;int&quot; },
         { &quot;name&quot;: &quot;metric&quot;, &quot;type&quot;: &quot;int&quot; },
         { &quot;name&quot;: &quot;original_db&quot;, &quot;type&quot;: &quot;int&quot; },
         { &quot;name&quot;: &quot;original_id&quot;, &quot;type&quot;: &quot;long&quot; },
         { &quot;name&quot;: &quot;valueSum&quot;, &quot;type&quot;: &quot;double&quot; },
         { &quot;name&quot;: &quot;valueDiv&quot;, &quot;type&quot;: &quot;double&quot; }
       ]
  }
  </code></pre>
  <p>When running the flow I get the following error on the second processor:</p>
  <blockquote>
  <p>UpdateRecord[id=017e1004-c2d8-14cf-6d9d-374a1143abb0]  Failed to
  process
  StandardFlowFileRecord[uuid=c52d4145-ba5f-4f51-8f90-5313f461dbd8,claim=StandardContentClaim
  [resourceClaim=StandardResourceClaim[id=1644394716708-2,
  container=default, section=2], offset=850134,
  length=1143],offset=0,name=c52d4145-ba5f-4f51-8f90-5313f461dbd8,size=1143];
  will route to failure: ${firstschema} did not provide appropriate
  Schema Name</p>
  </blockquote>
  <p>I obtain the same result when I change the setting in the AvroRecordSetWriter controller service as follows:</p>
  <ul>
  <li>Schema Write Strategy: Set 'schema.name' Attribute</li>
  </ul>
  <p>Also, I obtain the same result if I make the following changes to AvroReader configuration:</p>
  <ul>
  <li>Schema Name: $(mysql.influx.firstschema)</li>
  </ul>
  <p>The reason why I am not using the option Schema Access Strategy: Use Embedded Avro Schema in AvroReader controller service is that by doing so I get an issue with the format of the time stamp later on in the flow, as described in this other post:</p>
  <p><a href="https://stackoverflow.com/questions/71047227/error-when-using-putinfluxdatabaserecord-in-apache-ni-fi-due-to-time-stamp">Error when using PutInfluxDatabaseRecord in Apache Ni-Fi due to time stamp</a></p>
  <p>I am using Apache Ni-Fi 1.15.2</p>
  <p>Any hint what I am doing wrong?</p>
  <p>Thanks,</p>
  <p>Bernardo</p>