[
https://issues.apache.org/jira/browse/AVRO-3374?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17541579#comment-17541579
]
Christophe Le Saec commented on AVRO-3374:
------------------------------------------
If Avro Project was at start, i would always write complete name (with
namespace), even for *ns.MyRecord*, it would easily allow to have
*ns1.MyRecord* & *ns.MyRecord* in same json (same name, different namespace),
and, as it's for schema, not for record, there are no great gain to skip
namespace in term of memory. This would automatically allow "ns.int" as record
schema name.
Currently, SDK doesn't failed to load Json schema with "ns.int", it just can't
rewrite it correctly with toString function, because it translate "ns.int" to
"int", so it fails to relaod it because misinterpret "int" type (it would be
the same with the fix, "int" can be misinterpreted). Fix will only fix toString
method, not the loading, so, there's no pb with compatibility (i think).
I think this fix is in good direction (allow "ns.int"), and we can even discuss
about the fact that to write namespace systematically ?
> [Java] Fully qualified type reference "ns.int" loses namespace.
> ---------------------------------------------------------------
>
> Key: AVRO-3374
> URL: https://issues.apache.org/jira/browse/AVRO-3374
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.11.0
> Reporter: Ryan Skraba
> Assignee: Christophe Le Saec
> Priority: Minor
> Labels: pull-requests-available
> Attachments: AVRO-3374.patch
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> While brainstorming for AVRO-3370, I came across this special case where a
> type-reference could be considered ambiguous if the SDK is not careful when
> simplifying inherited namespaces:
> {code:json}
> {
> "type" : "record",
> "name" : "ns.int",
> "fields" : [
> {"name" : "value", "type" : "int"},
> {"name" : "next", "type" : [ "null", "ns.int" ]}
> ]
> }
> {code}
> In Java, if this code is parsed, it works as expected (as a linked list).
> If the schema is turned to a String using toString(), the namespace is
> dropped off the last {*}{{ns.int}}{*}, turning it into the primitive. That
> string can still be parsed into a Schema, but the "round-trip" modifies the
> schema in an incompatible way.
> That namespace shouldn't be dropped when producing the JSON string
> representing the Schema in Java.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)