You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Ramana Suvarapu (JIRA)" <ji...@apache.org> on 2013/08/20 15:12:51 UTC

[jira] [Created] (AVRO-1363) C# UnionSchema fails to parse the the unions with same type names with different namespaces

Ramana Suvarapu created AVRO-1363:
-------------------------------------

             Summary: C# UnionSchema fails to parse the the unions with same type names with different namespaces
                 Key: AVRO-1363
                 URL: https://issues.apache.org/jira/browse/AVRO-1363
             Project: Avro
          Issue Type: Bug
          Components: csharp
    Affects Versions: 1.7.4
            Reporter: Ramana Suvarapu
         Attachments: reader.avpr

C# Union schema is unable to handle same type names with different namespaces. It's throwing "SchemaParseException("Duplicate type in union: "...) exception.

In the below code, key of uniqueSchemas should be FullName of the type which is similar to Java implementation. 

internal static UnionSchema NewInstance(JArray jarr, PropertyMap props, SchemaNames names, string encspace)
        {
            List<Schema> schemas = new List<Schema>();
            IDictionary<string, string> uniqueSchemas = new Dictionary<string, string>();

            foreach (JToken jvalue in jarr)
            {
                Schema unionType = Schema.ParseJson(jvalue, names, encspace);
                if (null == unionType)
                    throw new SchemaParseException("Invalid JSON in union" + jvalue.ToString());

                string name = unionType.Name;
                if (uniqueSchemas.ContainsKey(name))
                    throw new SchemaParseException("Duplicate type in union: " + name);

                uniqueSchemas.Add(name, name);
                schemas.Add(unionType);
            }

            return new UnionSchema(schemas, props);
        }

See the attachement to recreate the issue

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira