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

Inconsistent data types for logicalType = date

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.9.1
    • None
    • java, logical types
    • None

    Description

      When defining a date field in the avro schema the generated java class files contains different types based on the given types.

       

      Giving a schema that contains date's, some are optional and some required.

      {
          "type": "record",
          "name": "DateData",
          "namespace": "com.keylane.ics.data",
          "fields": [
              {
                  "name": "dateAsInt",
                  "type": "int",
                  "logicalType": "date"
              },
              {
                  "name": "dateAsOptionalInt",
                  "type": [
                      "null",
                      "int"
                  ],
                  "logicalType": "date"
              },
              {
                  "name": "dateAsObject",
                  "type": [
                      {
                          "type": "int",
                          "logicalType": "date"
                      }
                  ]
              },
              {
                  "name": "dateAsOptionalLocalDate",
                  "type": [
                      "null",
                      {
                          "type": "int",
                          "logicalType": "date"
                      }
                  ]
              }
          ]
      }
      

       

      The generated class file defines the 4 fields with different java types

       

        @Deprecated public int dateAsInt;
        @Deprecated public java.lang.Integer dateAsOptionalInt;
        @Deprecated public java.lang.Object dateAsObject;
        @Deprecated public java.time.LocalDate dateAsOptionalLocalDate;
      

       

      We would prefer to have the type as a LocalDate, so that case 3 and 4 give the same field definition.

       

      Is this a bug or should the schema definition be different (and how)?

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            marcel.stokman@keylane.com Marcel Stokman
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: