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

'conversions' array is not populated for Avro Union Logicaltype fields

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Minor
    • Resolution: Unresolved
    • 1.9.2
    • 1.13.0
    • logical types
      • Apache Avro Version [1.9.2]
      • Java Version [11]

    Description

      Steps to reproduce :

      1. Using the maven/gradle plugin generate code with the following avsc:
           
      {
        "type": "record",
        "name": "Messages",
        "namespace": "com.somedomain",
        "fields": [
          {
            "name": "start",
            "type": {
              "type": "long",
              "logicalType": "timestamp-millis"
            }
          },
          {
            "name": "optional_date",
            "type": [
              "null",
              {
                "type": "long",
                "logicalType": "timestamp-millis"
              }
            ],
            "default": null
          }
        ]
      }

       

      Actual behavior
      In the generated code, the return types of the getter methods for both fields are correct, however the conversions array only has an element for the field which isn't a union.
       

        private static final org.apache.avro.Conversion<?>[] conversions =
            new org.apache.avro.Conversion<?>[] {
            new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
            null,
            null
        };
      

       

      Expected output:
      Based on the above avsc the following is expected.
       

        private static final org.apache.avro.Conversion[] conversions =
            new org.apache.avro.Conversion[] {
            new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
            new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
            null
        };
      

       

       

       

      Attachments

        Issue Links

          Activity

            People

              icecreamhead Josh Cooke
              pdebuitlear Pádraig de Buitléar
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m