You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2021/12/22 17:17:00 UTC

[jira] [Commented] (AVRO-3257) IDL: add syntax to create optional fields

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

ASF subversion and git services commented on AVRO-3257:
-------------------------------------------------------

Commit 7c5d8df3fb282b1dffa6d11169756ed5593de838 in avro's branch refs/heads/master from Oscar Westra van Holthe - Kind
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=7c5d8df ]

AVRO-3257: IDL support for nullable types (#1411)

* AVRO-3256: IDL type reference with annotation throws error

Previous versions would alter the referenced type when encountering an
annotation on (for example) a field type. This change makes references
read-only.

* AVRO-3256: Document new behavior of annotations

Documented that references to named types cannot be annotated. Also
described where annotations for named types should go.

Lastly, the example has been fixed to match this change, and now also
 contains various types of documentation.

* AVRO-3257: Add syntax for unions of null with a type

Added Kotlin-style syntax for optional types. `MyType?` compiles to the
same result as `union { null, MyType }`.

This commit includes the documentation update.

* AVRO-3257: Remove unused variable from JavaCC grammar

* AVRO-3257: Fluid unions for optional types

The syntax for optional types now put the null type in the unions based
on the default value (if any).

This commit includes the documentation update.

* AVRO-3257: Add comments explaining features

* Fix typo in HTML

Co-authored-by: Ryan Skraba <ry...@skraba.com>

Co-authored-by: Ryan Skraba <ry...@skraba.com>

> IDL: add syntax to create optional fields
> -----------------------------------------
>
>                 Key: AVRO-3257
>                 URL: https://issues.apache.org/jira/browse/AVRO-3257
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: java, spec
>            Reporter: Oscar Westra van Holthe - Kind
>            Assignee: Oscar Westra van Holthe - Kind
>            Priority: Minor
>              Labels: javacc, pull-request-available
>             Fix For: 1.11.1
>
>          Time Spent: 3.5h
>  Remaining Estimate: 0h
>
> To define optional values, Avro has the "union with the null type" construction.
> In IDL, this is a rather verbose construct:
> {code}
> union {null, string} optionalName = null;
> {code}
> Wish: add Kotlin style optional types like this:
> {code}
> string? optionalName = null;
> {code}
> The resulting schema should be identical; it's only a syntax change.
> Note: it would be nice (but not required) if the syntax would also work if the default value is not null:
> {code}
> string? optionalName = "Jane Doe";
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)