You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by dk...@apache.org on 2018/12/03 20:13:39 UTC
[avro] branch master updated: Avro1363 C# union schema can now
contain multiple entries with the same name and different namespace (#131)
This is an automated email from the ASF dual-hosted git repository.
dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new b5bec5c Avro1363 C# union schema can now contain multiple entries with the same name and different namespace (#131)
b5bec5c is described below
commit b5bec5ca18901507f6fc01d635f10465fd3edcdf
Author: Simon24601 <si...@gmail.com>
AuthorDate: Mon Dec 3 20:13:34 2018 +0000
Avro1363 C# union schema can now contain multiple entries with the same 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
---
lang/csharp/src/apache/main/Schema/NamedSchema.cs | 2 +-
lang/csharp/src/apache/main/Schema/Schema.cs | 12 ++++++++++--
lang/csharp/src/apache/main/Schema/UnionSchema.cs | 2 +-
lang/csharp/src/apache/test/Schema/SchemaTests.cs | 3 ++-
4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/lang/csharp/src/apache/main/Schema/NamedSchema.cs b/lang/csharp/src/apache/main/Schema/NamedSchema.cs
index e0bfab0..6963238 100644
--- a/lang/csharp/src/apache/main/Schema/NamedSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/NamedSchema.cs
@@ -52,7 +52,7 @@ namespace Avro
/// <summary>
/// Namespace.Name of the schema
/// </summary>
- public string Fullname
+ public override string Fullname
{
get { return SchemaName.Fullname; }
}
diff --git a/lang/csharp/src/apache/main/Schema/Schema.cs b/lang/csharp/src/apache/main/Schema/Schema.cs
index a9de877..676cce9 100644
--- a/lang/csharp/src/apache/main/Schema/Schema.cs
+++ b/lang/csharp/src/apache/main/Schema/Schema.cs
@@ -71,11 +71,19 @@ namespace Avro
}
/// <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>
diff --git a/lang/csharp/src/apache/main/Schema/UnionSchema.cs b/lang/csharp/src/apache/main/Schema/UnionSchema.cs
index df2c37f..bc2ab5b 100644
--- a/lang/csharp/src/apache/main/Schema/UnionSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/UnionSchema.cs
@@ -56,7 +56,7 @@ namespace Avro
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);
diff --git a/lang/csharp/src/apache/test/Schema/SchemaTests.cs b/lang/csharp/src/apache/test/Schema/SchemaTests.cs
index 7931d40..a1c3f3c 100644
--- a/lang/csharp/src/apache/test/Schema/SchemaTests.cs
+++ b/lang/csharp/src/apache/test/Schema/SchemaTests.cs
@@ -69,7 +69,8 @@ namespace Avro.Test
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\"}",