You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2022/12/13 19:14:44 UTC

[GitHub] [avro] kmcclellan commented on pull request #1610: AVRO-2883: Fix namespace mapping

kmcclellan commented on PR #1610:
URL: https://github.com/apache/avro/pull/1610#issuecomment-1349551326

   Hi. This might not be the best place, but I wanted to point out that this implementation does not render the expected output in the description of [AVRO-2506](https://issues.apache.org/jira/browse/AVRO-3506).
   
   ### INITIAL BUG (excerpt)
   
   ```c#
   public static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"TestModel\",\"namespace\":\"my.avro.ns\",\"fields\":[{\"name\":\"e" +
           "ventType\",\"type\":{\"type\":\"enum\",\"name\":\"EventType\",\"namespace\":\"my.avro.ns\",\"sym" +
           "bols\":[\"CREATE\",\"UPDATE\",\"DELETE\"]}}]}");
   private my.avro.ns.EventType _eventType;
   ```
   
   Note that "my.avro.ns" is the namespace for _both_ the **schema string** and the **field declaration** for `EventType`. This code doesn't compile since `EventType`'s actual namespace is `my.csharp.ns`.
   
   ### EXPECTED 
   
   ```c#
   public static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"TestModel\",\"namespace\":\"my.avro.ns\",\"fields\":[{\"name\":\"e" +
           "ventType\",\"type\":{\"type\":\"enum\",\"name\":\"EventType\",\"namespace\":\"my.avro.ns\",\"sym" +
           "bols\":[\"CREATE\",\"UPDATE\",\"DELETE\"]}}]}");
   private my.csharp.ns.EventType _eventType;
   ```
   
   Note that "my.avro.ns" is the namespace used by the **schema string**, whereas "my.csharp.ns" is used for the **field declaration**. The code compiles as we effectively "map an Avro schema/protocol namespace to a C# namespace" (from the help).
   
   ### IMPLEMENTED (v1.11.1)
   
   ```c#
   public static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"TestModel\",\"namespace\":\"my.csharp.ns\",\"fields\":[{\"name\":\"e" +
           "ventType\",\"type\":{\"type\":\"enum\",\"name\":\"EventType\",\"namespace\":\"my.csharp.ns\",\"sym" +
           "bols\":[\"CREATE\",\"UPDATE\",\"DELETE\"]}}]}");
   private my.csharp.ns.EventType _eventType;
   ```
   
   Note that "my.csharp.ns" is used for _both_ the **schema string** and the **field declaration** for `EventType` . Though it compiles, it no longer matches the source schema and isn't able to deserialize data generated using that schema.


-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org