[
https://issues.apache.org/jira/browse/AVRO-3257?focusedWorklogId=693447&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-693447
]
ASF GitHub Bot logged work on AVRO-3257:
----------------------------------------
Author: ASF GitHub Bot
Created on: 09/Dec/21 18:12
Start Date: 09/Dec/21 18:12
Worklog Time Spent: 10m
Work Description: RyanSkraba commented on a change in pull request #1411:
URL: https://github.com/apache/avro/pull/1411#discussion_r766035699
##########
File path:
lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
##########
@@ -182,6 +183,32 @@ public class Idl implements Closeable {
return result;
}
+ /**
+ * For "optional schemas" (recognized by the marker property the NullableType
+ * production adds), ensure the null schema is in the right place.
+ *
+ * @param schema a schema
+ * @param defaultValue the intended default value
+ * @return the schema, or an optional schema with null in the right place
+ */
+ private static Schema fixOptionalSchema(Schema schema, JsonNode
defaultValue) {
Review comment:
I like this so much! This is a compelling feature... I'm tempted to say
that nobody really **_wants_**
```
union { null, double } value = NaN
```
to fail either... What would you think about auto-correcting all `union {
null, notNull }` or `union { notNull, null } ` types that have a default?
I guess this might be too magical, and i suspect that the `?` syntax will be
happily adopted in any case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 693447)
Time Spent: 1.5h (was: 1h 20m)
> 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: 1.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)