[ 
https://issues.apache.org/jira/browse/AVRO-3179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17485401#comment-17485401
 ] 

Ryan Skraba commented on AVRO-3179:
-----------------------------------

Hello!  I just want to confirm that my generated class of Value had *{{public 
void setNomandat(java.math.BigDecimal value)}}*

I'm not using Kafka or postgres in my example.

Are you setting the {*}enableDecimalLogicalType{*}?  My maven plugin is 
configured like this:
{code:java}
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.avro</groupId>
      <artifactId>avro-maven-plugin</artifactId>
      <version>1.10.2</version>
      <executions>
        <execution>
          <goals>
            <goal>schema</goal>
            <goal>protocol</goal>
            <goal>idl-protocol</goal>
          </goals>
          <phase>generate-sources</phase>
          <configuration>
            <enableDecimalLogicalType>true</enableDecimalLogicalType>
            <fieldVisibility>public</fieldVisibility>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build> {code}
And I'm using *{{mvn generate-sources}}* to generate the specific records.

You can also use avro-tools:
{code:java}
mvn dependency:get -Dartifact=org.apache.avro:avro-tools:1.10.2
java -jar 
~/.m2/repository/org/apache/avro/avro-tools/1.10.2/avro-tools-1.10.2.jar 
compile -bigDecimal schema table.avsc . 
grep -r setNomandat .
# you should see public void setNomandat(java.math.BigDecimal value){code}
 

> ClassCastException: java.math.BigDecimal cannot be cast to java.nio.ByteBuffer
> ------------------------------------------------------------------------------
>
>                 Key: AVRO-3179
>                 URL: https://issues.apache.org/jira/browse/AVRO-3179
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.10.2
>            Reporter: MarcelKobain
>            Priority: Blocker
>         Attachments: table.avsc
>
>
> Hello,
> I think we have the same problem as AVRO-2212.
> I have classCassException with a bigDecimal.
>  
> Context : 
> I am doing an ETL with postgres >> KafkaConnect >> KafkaStream
> I get schemas with mvn schema-registry:download
>  I generate pojo with : mvn clean avro:schema
> Then I launch my app to stream a table source to a table target
> see schema here : [^table.avsc]
>  
> I have fixed passing on the 1.10.1 version and it works. But When i take 
> 1.10.2 I have the bug : 
> Caused by: java.lang.ClassCastException: java.math.BigDecimal cannot be cast 
> to java.nio.ByteBufferCaused by: java.lang.ClassCastException: 
> java.math.BigDecimal cannot be cast to java.nio.ByteBuffer at 
> postgres.table.Value.put(Value.java:240) at 
> org.apache.avro.generic.GenericData.setField(GenericData.java:818) at 
> org.apache.avro.specific.SpecificDatumReader.readField(SpecificDatumReader.java:139)
>  at 
> org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:247)
>  at 
> org.apache.avro.specific.SpecificDatumReader.readRecord(SpecificDatumReader.java:123)
>  at 
> org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:179)
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to