title: Generating an Avro Schema from a POJO containing a java.lang.BigDecimal does not work as expected
body: <p>Edit: <a href="https://github.com/filpano/avro-bigdecimal-issue" rel="nofollow noreferrer">Here</a> is a minimal example of this behaviour.</p>
  <hr />
  <p>I have an issue with generating an Avro schema for an existing POJO. What I ultimately wish to do is read generic Avro records from a Kafka Topic and deserialize those back to my own model.</p>
  <p>I am using <code>org.apache.avro:avro:1.11.0</code>.</p>
  <p>The POJO looks similar to the following:</p>
  <pre class="lang-java prettyprint-override"><code>public class TransactionEvent {
  
      private UUID transactionId;
      private BigDecimal total;
      
      // getter/constructor
  }
  </code></pre>
  <p>The following simple code is used to generate an <code>.avsc</code> schema file from the above POJO:</p>
  <pre class="lang-java prettyprint-override"><code>ReflectData rd = ReflectData.AllowNull.get();
  rd.addLogicalTypeConversion(new Conversions.UUIDConversion());
  return rd.getSchema(clazz);
  </code></pre>
  <p>Which yields the following <code>.avsc</code> schema definition:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;type&quot;: &quot;record&quot;,
    &quot;name&quot;: &quot;TransactionEvent&quot;,
    &quot;namespace&quot;: &quot;com.acme&quot;,
    &quot;fields&quot;: [
      {
        &quot;name&quot;: &quot;transactionId&quot;,
        &quot;type&quot;: [
          &quot;null&quot;,
          {
            &quot;type&quot;: &quot;string&quot;,
            &quot;logicalType&quot;: &quot;uuid&quot;
          }
        ],
        &quot;default&quot;: null
      },
      {
        &quot;name&quot;: &quot;total&quot;,
        &quot;type&quot;: [
          &quot;null&quot;,
          {
            &quot;type&quot;: &quot;string&quot;,
            &quot;java-class&quot;: &quot;java.math.BigDecimal&quot;
          }
        ],
        &quot;default&quot;: null
      }
    ]
  }
  </code></pre>
  <p>Since there's no logical conversion, the generator generates the schema with a non-interchangeable definition (<code>&quot;java-type&quot;</code>). This much is clear. However, if I add a logical conversion:</p>
  <pre class="lang-java prettyprint-override"><code>rd.addLogicalTypeConversion(new Conversions.DecimalConversion());
  </code></pre>
  <p>I get the error:</p>
  <pre><code>org.apache.avro.AvroRuntimeException: java.lang.UnsupportedOperationException: No recommended schema for decimal (scale is required)
  </code></pre>
  <p>I would have expected <code>Conversions.DecimalConversion()</code> to take in <code>scale</code>/<code>precision</code> parameters and then generate something like:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;type&quot;: &quot;bytes&quot;,
    &quot;logicalType&quot;: &quot;decimal&quot;,
    &quot;precision&quot;: 4,
    &quot;scale&quot;: 2
  }
  </code></pre>
  <p>which is the <a href="https://avro.apache.org/docs/1.11.0/spec.html#Decimal" rel="nofollow noreferrer">recommended</a> schema definition for decimal values, instead of throwing an exception that I can't do anything about.</p>
  <p>I suppose I could add all my schemas by hand, but the effort required to do so for any non-trivial existing project looking to use Avro is... not little. To be frank, for such a widespread serialization mechanism as Avro, I've found the documentation to be quite lacking.</p>
  <p>What am I doing wrong? I can probably just register my own conversion, but what's even the point of the available <code>DecimalConversion</code> then?</p>