<?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: PutDatabaseRecord &amp;quot;bytes&amp;quot; avro data type fails with error &amp;quot;Cannot cast an instance of [Ljava.lang.Object; to type Types.ARRAY&amp;quot; in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368538#M240190</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/103151"&gt;@cotopaul&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thanks for your prompt reply, it was clear and to the point. I have followed the same steps and it works for Apache Nifi 1.18.0 (open-source/community).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The version I have observed the issue on is Apache Nifi 1.11.4 (open-source/community).&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Apr 2023 11:51:47 GMT</pubDate>
    <dc:creator>kspyropoulos</dc:creator>
    <dc:date>2023-04-14T11:51:47Z</dc:date>
    <item>
      <title>PutDatabaseRecord "bytes" avro data type fails with error "Cannot cast an instance of [Ljava.lang.Object; to type Types.ARRAY"</title>
      <link>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368417#M240171</link>
      <description>&lt;P&gt;I am using ExecuteSQL Nifi processor to read from a Postgresql table defined as per below:&lt;/P&gt;&lt;P&gt;CREATE TABLE otherdatatype(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; column1 int,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; column2 varchar(255),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; column3 bytea&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;I get the values of that table successfully, as per below:&lt;/P&gt;&lt;P&gt;column1 : 1&lt;/P&gt;&lt;P&gt;column2 : "hello world"&lt;/P&gt;&lt;P&gt;column3 :&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;\x4920616d206261636b20616761696e2e2e2e (converted to text "&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;I am back again...")&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the AVRO schema automatically generated by ExecuteSQL Nifi processor is:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;&amp;nbsp; "type": "record",&lt;BR /&gt;&amp;nbsp; "name": "otherdatatype",&lt;BR /&gt;&amp;nbsp; "namespace": "any.data",&lt;BR /&gt;&amp;nbsp; "fields": [{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "name": "column1",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "type": ["null", "int"]&lt;BR /&gt;&amp;nbsp; }, {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "name": "column2",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "type": ["null", "string"]&lt;BR /&gt;&amp;nbsp; }, {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "name": "column3",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "type": ["null", "bytes"]&lt;BR /&gt;&amp;nbsp; }]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Then I try to use&amp;nbsp;PutDatabaseRecord Nifi processor to insert the values already read into another table, as per below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-04-13 at 13.41.18.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37264iBDD408DC937993FA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-04-13 at 13.41.18.png" alt="Screenshot 2023-04-13 at 13.41.18.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The AvroReaderInferSchema record reader property is set to an AvroReader controller that is using the embedded Avro Schema:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-04-13 at 13.50.41.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37265i426B443EB867A11B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-04-13 at 13.50.41.png" alt="Screenshot 2023-04-13 at 13.50.41.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV class="attribute-name"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="attribute-name"&gt;Then execution fails, the flowfile is placed in the failure queue and the below value is provided in the relevant error attribute :&lt;/DIV&gt;&lt;DIV class="attribute-name"&gt;putdatabaserecord.error : Cannot cast an instance of [Ljava.lang.Object; to type Types.ARRAY&lt;/DIV&gt;&lt;DIV class="attribute-name"&gt;&lt;P&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;DIV class="attribute-name"&gt;Any ideas what the issue here is? Am I doing something wrong? Is it a bug with PutDatabaseRecord processor? Is there any other alternative (other processor or other controller)?&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Apr 2023 12:54:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368417#M240171</guid>
      <dc:creator>kspyropoulos</dc:creator>
      <dc:date>2023-04-13T12:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: PutDatabaseRecord "bytes" avro data type fails with error "Cannot cast an instance of [Ljava.lang.Object; to type Types.ARRAY"</title>
      <link>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368438#M240174</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/104594"&gt;@kspyropoulos&lt;/a&gt;&amp;nbsp; Welcome to the Cloudera Community!&lt;BR /&gt;&lt;BR /&gt;To help you get the best possible solution, I have tagged our NiFi experts&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/103151"&gt;@cotopaul&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp; who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;Please keep us updated on your post, and we hope you find a satisfactory solution to your query.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 14:55:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368438#M240174</guid>
      <dc:creator>DianaTorres</dc:creator>
      <dc:date>2023-04-13T14:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: PutDatabaseRecord "bytes" avro data type fails with error "Cannot cast an instance of [Ljava.lang.Object; to type Types.ARRAY"</title>
      <link>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368449#M240177</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/104594"&gt;@kspyropoulos&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;I would honestly start by asking what NiFi are you currently running (open source or cloudera)? In addition what is the version of your NiFi? I know that the questions might sound silly, but each version has (or does not have) some features.&lt;BR /&gt;&lt;BR /&gt;Next, I would ask you if the table you are inserting to has the same table structure (same column type) and if you are using the correct avro schema? I reproduced your flow as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CREATE TABLE test_voice (
column1 INT,
column2 varchar(255),
column3 bytea
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In NiFi (1.19.1) I set an ExecuteSQL processor, configured as follows: a simple DBCP Connection Pool pointing to my PostgreSQL Database, the simple select * from my_table as SQL select Query and !!! Use Avro Logical Types = true !!!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cotopaul_0-1681401118699.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37269iD1CC2A45AEA6ACE8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cotopaul_0-1681401118699.png" alt="cotopaul_0-1681401118699.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;After executing the flow, in the success queue, I get a single flowfile with a single row (because I inserted only 1 row for my test)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;insert into test_voice(column1,column2,column3) values(1,'hello','\x4920616d206261636b20616761696e2e2e2e')&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cotopaul_1-1681401216777.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37270iF8245B7CFE2210D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cotopaul_1-1681401216777.png" alt="cotopaul_1-1681401216777.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In terms of schema, we have:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cotopaul_2-1681401253457.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37271i52025FB56FD6630B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cotopaul_2-1681401253457.png" alt="cotopaul_2-1681401253457.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So far so good. Now, we will update the current row in my PostgreSQL database, column1=1 to column1=2, so that we could check if the insert took place.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;update test_voice set column1='2' where column1='1'; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, using PutDatabaseRecord, we will insert the row in our database. For PutDatabaseRecord, I have configured the following: RecordReader = Avro Reader with Inherit Record Schema, Database Type = PostgreSQL, Statement Type = INSERT, Database Connection Pooling Service = The one used in ExecuteSQL, Catalog Name, Schema Name and Table Name taken out of PostgreSQL. Everything else left as default.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cotopaul_3-1681401481955.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37272i57B6F100306F622E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cotopaul_3-1681401481955.png" alt="cotopaul_3-1681401481955.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cotopaul_4-1681401510344.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37273i822C3A824BC65D2C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cotopaul_4-1681401510344.png" alt="cotopaul_4-1681401510344.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I executed the flow, the row was inserted within the DB.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cotopaul_5-1681401549011.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37274i1BB4B067C6B4C51E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cotopaul_5-1681401549011.png" alt="cotopaul_5-1681401549011.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cotopaul_6-1681401568814.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37275iD70548C97A5A8803/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cotopaul_6-1681401568814.png" alt="cotopaul_6-1681401568814.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I can tell you that PutDatabaseRecord works just fine. Unfortunately for you, it seems that you problem is located somewhere else .... my points are on either the AVRO schema or the table you are trying to insert into &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 16:03:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368449#M240177</guid>
      <dc:creator>cotopaul</dc:creator>
      <dc:date>2023-04-13T16:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: PutDatabaseRecord "bytes" avro data type fails with error "Cannot cast an instance of [Ljava.lang.Object; to type Types.ARRAY"</title>
      <link>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368538#M240190</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/103151"&gt;@cotopaul&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thanks for your prompt reply, it was clear and to the point. I have followed the same steps and it works for Apache Nifi 1.18.0 (open-source/community).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The version I have observed the issue on is Apache Nifi 1.11.4 (open-source/community).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 11:51:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368538#M240190</guid>
      <dc:creator>kspyropoulos</dc:creator>
      <dc:date>2023-04-14T11:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: PutDatabaseRecord "bytes" avro data type fails with error "Cannot cast an instance of [Ljava.lang.Object; to type Types.ARRAY"</title>
      <link>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368546#M240192</link>
      <description>&lt;P&gt;I have also tested the same with&amp;nbsp;&lt;SPAN&gt;Apache Nifi 1.15.3 (open-source/community) and it works. It did not work though when testing with Apache Nifi 1.13.2 (open-source/community) it still fails with the same error message.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 14:03:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/PutDatabaseRecord-quot-bytes-quot-avro-data-type-fails-with/m-p/368546#M240192</guid>
      <dc:creator>kspyropoulos</dc:creator>
      <dc:date>2023-04-14T14:03:54Z</dc:date>
    </item>
  </channel>
</rss>

