Skip to content

Commit

Permalink
Avro1363 C# union schema can now contain multiple entries with the sa…
Browse files Browse the repository at this point in the history
…me name and different namespace (#131)

* AVRO-1849 Fix the issue where converting the schema of a record with no fields produced an invalid JSON

* Fix style issues in the code.

* Fix the build scripts; build.sh requires the :z addition to work on SELinux (see Jira 1925). lang/c++/build.sh refers to the lang/c++/build directory which is empty. These are now fixed.

* Update to use BOOST_TEST_CHECKPOINT

* AVRO-1926 Revert changes to the lang/c++/build.sh script and add the SchemaTests to the list of tests. Also revert SELinux changes to build.sh as these should be committed separately

* AVRO-1363 Fix the parsing of a union schema with duplicate names but different namespaces. In Java, this works, but not in C#

* Remove c++ changes from the AVRO1363 branch
  • Loading branch information
Simon24601 authored and dkulp committed Dec 3, 2018
1 parent d9d9587 commit b5bec5c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lang/csharp/src/apache/main/Schema/NamedSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public string Namespace
/// <summary>
/// Namespace.Name of the schema
/// </summary>
public string Fullname
public override string Fullname
{
get { return SchemaName.Fullname; }
}
Expand Down
12 changes: 10 additions & 2 deletions lang/csharp/src/apache/main/Schema/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,20 @@ protected Schema(Type type, PropertyMap props)
this.Props = props;
}

/// <summary>
/// If this is a record, enum or fixed, returns its name, otherwise the name the primitive type.
/// </summary>
public abstract string Name { get; }

/// <summary>
/// The name of this schema. If this is a named schema such as an enum, it returns the fully qualified
/// name for the schema. For other schemas, it returns the type of the schema.
/// </summary>
public abstract string Name { get; }

public virtual string Fullname
{
get { return Name; }
}

/// <summary>
/// Static class to return new instance of schema object
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion lang/csharp/src/apache/main/Schema/UnionSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal static UnionSchema NewInstance(JArray jarr, PropertyMap props, SchemaNa
if (null == unionType)
throw new SchemaParseException("Invalid JSON in union" + jvalue.ToString());

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

Expand Down
3 changes: 2 additions & 1 deletion lang/csharp/src/apache/test/Schema/SchemaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public class SchemaTests
Description = "No fields", ExpectedException = typeof(SchemaParseException))]
[TestCase("{\"type\":\"record\",\"name\":\"LongList\", \"fields\": \"hi\"}",
Description = "Fields not an array", ExpectedException = typeof(SchemaParseException))]

[TestCase("[{\"type\": \"record\",\"name\": \"Test\",\"namespace\":\"ns1\",\"fields\": [{\"name\": \"f\",\"type\": \"long\"}]}," +
"{\"type\": \"record\",\"name\": \"Test\",\"namespace\":\"ns2\",\"fields\": [{\"name\": \"f\",\"type\": \"long\"}]}]")]
// Enum
[TestCase("{\"type\": \"enum\", \"name\": \"Test\", \"symbols\": [\"A\", \"B\"]}")]
[TestCase("{\"type\": \"enum\", \"name\": \"Status\", \"symbols\": \"Normal Caution Critical\"}",
Expand Down

0 comments on commit b5bec5c

Please sign in to comment.