Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2836

SpecificCompiler does not add DecimalConversion when logical type is a Fixed type

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.2
    • Fix Version/s: 1.10.0
    • Component/s: java, logical types
    • Labels:
      None

      Description

      I have updated to Avro 1.9.2 using the avro-maven-plugin to generate the specific types.

      This is working nicely, except noticed the case of:

      "fields": [
          {
            "name": "unionOfFixedDecimal",
            "type": ["null", {
              "namespace": "org.apache.avro.codegentest.testdata",
              "name": "FixedInUnion",
              "type": "fixed",
              "size": 12,
              "logicalType": "decimal",
              "precision": 28,
              "scale": 15
            }]
          }] 

      This is a fixed type that has a logical type of decimal.

      When the source is generated, the type is BigDecimal. However the DecimalConversion is missing and then it breaks when used.

      It seems easy to workaround by manually adding the logical conversion before using.

      However the fix seems to be in SpecificCompiler#getClassNamesOfPrimitiveFields which is used by #getUsedConversionClasses

        Attachments

        1. AVRO-2836.patch
          7 kB
          Matthew McMahon

          Activity

            People

            • Assignee:
              maccamlc Matthew McMahon
              Reporter:
              maccamlc Matthew McMahon
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: