You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Marcel Stokman (Jira)" <ji...@apache.org> on 2020/01/03 10:27:00 UTC

[jira] [Created] (AVRO-2670) Inconsistent data types for logicalType = date

Marcel Stokman created AVRO-2670:
------------------------------------

             Summary: Inconsistent data types for logicalType = date
                 Key: AVRO-2670
                 URL: https://issues.apache.org/jira/browse/AVRO-2670
             Project: Apache Avro
          Issue Type: Bug
          Components: java, logical types
    Affects Versions: 1.9.1
            Reporter: Marcel Stokman


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.
{code:java}
{
    "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"
                }
            ]
        }
    ]
}
{code}
 

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

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

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)?

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)