You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Ivan Greene (JIRA)" <ji...@apache.org> on 2019/04/05 17:08:00 UTC

[jira] [Commented] (AVRO-2369) Provide external way to construct Schema.Field with default value of 'null'

    [ https://issues.apache.org/jira/browse/AVRO-2369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16811052#comment-16811052 ] 

Ivan Greene commented on AVRO-2369:
-----------------------------------

[~dkulp] regarding this and the last issue I posted; do you think the difference between a field with default 'null' and no default at all needs to be significant? When dealing in generated SpecificRecords, there is essentially no difference, except in the schema text; i.e a field with type {{["null", "string"]}} that doesn't have an explicit default will build and serialize correctly without setting the field. Is there a strong reason we need to distinguish between implicit and explicit defaults of null, other than to provide a more meaningful exception message when a Union does not contain null?

> Provide external way to construct Schema.Field with default value of 'null'
> ---------------------------------------------------------------------------
>
>                 Key: AVRO-2369
>                 URL: https://issues.apache.org/jira/browse/AVRO-2369
>             Project: Apache Avro
>          Issue Type: Task
>          Components: java
>            Reporter: Ivan Greene
>            Priority: Blocker
>             Fix For: 1.9.0
>
>
> After making the Schema.Field constructor which takes the default value as a JsonNode was made package private, there is no external way to construct a field that has a default value of 'null'. Internally that constructor will call {{JacksonUtils.toJsonNode(defaultValue)}}, which will return 'null' when passed null, and the resulting Field will not have a default value (the json node would need to be NullNode instead of simply null itself). This will affect projects that need a way to dynamically build schemas and their fields.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)