[
https://issues.apache.org/jira/browse/AVRO-4094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17901310#comment-17901310
]
Shaw Young edited comment on AVRO-4094 at 11/26/24 9:52 PM:
------------------------------------------------------------
It actually doesn't matter if they're in the same namespace or not- if you have
just one namespace but fully qualified the type names to include their
namespace, that will still fail in the same way when type mapping is enabled as
it will convert the namespace attributes but then leave the type's with
orphaned references to the old pre-mapping values.
was (Author: JIRAUSER307863):
It actually doesn't matter if they're in the same namespace or not- if you have
just one namespace but use the fully qualified version of the type name,
including that type, that will still fail in the same way when type mapping is
enabled as it will convert the namespace and then the type's will be left with
orphaned references.
> Namespaces not mapped in type references
> ----------------------------------------
>
> Key: AVRO-4094
> URL: https://issues.apache.org/jira/browse/AVRO-4094
> Project: Apache Avro
> Issue Type: Bug
> Components: csharp
> Affects Versions: 1.11.4
> Environment: Avrogen is being run against dotnet 8 c# code from the
> linux command line.
> Reporter: Shaw Young
> Priority: Major
>
> Given this avsc schema file
> {code:java}
> [
> {
> "type": "enum",
> "name": "Planets",
> "namespace": "myapp.account",
> "symbols": [
> "EARTH",
> "MARS",
> "VENUS",
> "MERCURY"
> ],
> "doc": "Planets of the solar system"
> },
> {
> "type": "record",
> "name": "AccountCreation",
> "namespace": "myapp.account",
> "doc": "A individual user of the system.",
> "fields": [
> {
> "name": "id",
> "type": "string",
> "doc": "The unique identifier for the user."
> },
> {
> "name": "name",
> "type": [
> "null",
> "string"
> ],
> "default": null,
> "doc": ""
> },
> {
> "name": "homePlanet",
> "type": "Planets",
> "doc": ""
> },
> {
> "name": "favouritePlanet",
> "type": [
> "null",
> "Planets"
> ],
> "default": null,
> "doc": ""
> }
> ]
> }
> ] {code}
> and the avrogen with the following parameters;
> {code:java}
> avrogen -s ./simple.avsc ./out --namespace myapp.account:MyApp.Account{code}
> Everything is generated as expected;
> {code:java}
> out
> └── App
> └── Account
> ├── AccountCreation.cs
> └── Planets.cs {code}
> Now consider a minor alteration of moving Planets into its own common
> namespace so it can reused- we still wish to reference it from the
> AccountCreation entity by simply adding the namespace to the type;
> {code:java}
> [
> {
> "type": "enum",
> "name": "Planets",
> "namespace": "myapp.common",
> "symbols": [
> "EARTH",
> "MARS",
> "VENUS",
> "MERCURY"
> ],
> "doc": "Planets of the solar system"
> },
> {
> "type": "record",
> "name": "AccountCreation",
> "namespace": "myapp.account",
> "doc": "A individual user of the system.",
> "fields": [
> {
> "name": "id",
> "type": "string",
> "doc": "The unique identifier for the user."
> },
> {
> "name": "name",
> "type": [
> "null",
> "string"
> ],
> "default": null,
> "doc": ""
> },
> {
> "name": "homePlanet",
> "type": "myapp.common.Planets",
> "doc": ""
> },
> {
> "name": "favouritePlanet",
> "type": [
> "null",
> "myapp.common.Planets"
> ],
> "default": null,
> "doc": ""
> }
> ]
> }
> ] {code}
> Including the extra namespace mapping when running avrogen;
> {code:java}
> avrogen -s ./demo.avsc ./out --namespace myapp.common:App.Common --namespace
> myapp.account:MyApp.Account{code}
> This run fails
> {code:java}
> Exception occurred. Undefined name: myapp.common.Planets at
> '[1].fields[2].type'{code}
> Looking at the code it looks like the preparse step will substitute namespace
> attributes using the collection of namespace mapping, but doesn't substitute
> any of the type mappings, if they include one of the mapped namespaces.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)