You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Eddy ALBERT (JIRA)" <ji...@apache.org> on 2017/10/26 12:12:00 UTC

[jira] [Created] (AVRO-2101) Issue with null default value

Eddy ALBERT created AVRO-2101:
---------------------------------

             Summary: Issue with null default value
                 Key: AVRO-2101
                 URL: https://issues.apache.org/jira/browse/AVRO-2101
             Project: Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.8.2
         Environment: Java/IntelliJ/Maven
            Reporter: Eddy ALBERT
            Priority: Blocker


Hi,

It seems there is a bug in the Avro library when generating the Avro source files from the Avro schema.
As you could see in appendice, my schema is based on a main record and several sub-records.  
I work with "unions" for the type definition to allow setting fields to null when the value is not present.

*The issue is the following*:
First of all, this behavior isn't deterministic!
When the library generates the source file, most of the sub-records are well generated (with null as the default value), but sometime, a single sub-record has its default value set to "null" (String).
If I change the default value of the issued sub-record to "foo" and I re-generate the source file, I can see "foo" as the default value. If I rollback that change (back the default value to null) and I re-generate, I finally get null as default value (but not everytime ...).

I think this issue is the source bug of the one I publish on Stackoverflow: 
https://stackoverflow.com/questions/46775649/handle-nested-avro-record-when-the-one-is-null/46786313#46786313

Any suggestions?

Best regards,
EddyA.

Ps: its is always the same sub-record that is issued:

        {
            "name": "mobile_web_event",
            "type": {
                "type": "record",
                "name": "MobtabAvroMobileWebEvent",
                "fields": [
                    {
                        "name": "url",
                        "type": ["null", "string"],
                        "default": null
                    },
                    {
                        "name": "user_agent",
                        "type": ["null", "string"],
                        "default": null
                    }
                ]
            }
        },



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)