You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Kalle Niemitalo (Jira)" <ji...@apache.org> on 2022/07/03 10:19:00 UTC

[jira] [Created] (AVRO-3568) C# ToParsingForm normalizes logical type to "logical" rather than base type

Kalle Niemitalo created AVRO-3568:
-------------------------------------

             Summary: C# ToParsingForm normalizes logical type to "logical" rather than base type
                 Key: AVRO-3568
                 URL: https://issues.apache.org/jira/browse/AVRO-3568
             Project: Apache Avro
          Issue Type: Bug
          Components: csharp
    Affects Versions: 1.11.0
            Reporter: Kalle Niemitalo


In the Avro C# library, if Avro.SchemaNormalization.ToParsingForm(Schema) is given a schema that includes a logical type, then it normalizes that just to "logical" and not to the base type. The resulting JSON cannot even be parsed by Avro.Schema.Parse(string). This also makes SchemaNormalization.ParsingFingerprint return an incorrect fingerprint for schemas that include logical types.

h2. To reproduce

{code:C#}
using System;

class Program
{
    static void Main()
    {
        var schema = Avro.Schema.Parse(
            @"[""int"", {""type"": ""string"", ""logicalType"": ""uuid""}]");

        string pcf = Avro.SchemaNormalization.ToParsingForm(schema);
        Console.WriteLine(pcf);

        Avro.Schema.Parse(pcf);
    }
}
{code}

h2. Expected result

{noformat}
["int","string"]
{noformat}

h2. Actual result

{noformat}
["int","logical"]
Unhandled exception. Avro.SchemaParseException: Undefined name: logical at '[1]'
   at Avro.Schema.ParseJson(JToken jtok, SchemaNames names, String encspace)
   at Avro.UnionSchema.NewInstance(JArray jarr, PropertyMap props, SchemaNames names, String encspace)
   at Avro.Schema.ParseJson(JToken jtok, SchemaNames names, String encspace)
   at Avro.Schema.Parse(String json, SchemaNames names, String encspace)
   at Avro.Schema.Parse(String json)
   at Program.Main()
{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)