Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2862

C# Primitive Schema losing metadata

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.9.2
    • 1.11.1, 1.12.0
    • csharp
    • None

    Description

      Using this ticket as a base reference: https://issues.apache.org/jira/browse/AVRO-1545
      The same problem is happening in the C# version as well.

      Given:

      {
          "type" : "record",
          "name" : "BrokenRecord",
          "namespace" : "whatever",
          "fields" : [
              {
                  "name" : "a_string",
                  "type" : {
                      "type" : "string",
                      "foobar" : "some example here"
                  }
              }
          ]
      }
      

      The property "foobar" will be lost when parsing the schema.

      The fix that my team has implemented is modifying this line (file used from release 1.9.2)
      https://github.com/apache/avro/blob/bf20128ca6138a830b2ea13e0490f3df6b035639/lang/csharp/src/apache/main/Schema/PrimitiveSchema.cs#L85

      And replacing it with the following:

      if(this.Props != null && this.Props.Count > 0)
      {
          w.WriteStartObject();
          w.WritePropertyName("type");
          w.WriteValue(Name);
          foreach(var prop in Props)
          {
              w.WritePropertyName(prop.Key);
              w.WriteRawValue(prop.Value);
          }
          w.WriteEndObject();
      }
      else w.WriteValue(Name);

       Another somewhat related ticket: https://issues.apache.org/jira/browse/AVRO-1346

      Attachments

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            csplugins Cody
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: