Kalle Niemitalo created AVRO-3566:
-------------------------------------
Summary: C# Field.Ordering defaults to "ignore", but spec says
"ascending"
Key: AVRO-3566
URL: https://issues.apache.org/jira/browse/AVRO-3566
Project: Apache Avro
Issue Type: Bug
Components: csharp
Affects Versions: 1.11.0
Environment: .NET SDK 6.0.301
Reporter: Kalle Niemitalo
When Schema.Parse in the Avro C# library parses a record schema in which a
field does not have the "order" property, the library defaults it to "ignore".
However, the Avro 1.11.0 specification says the default should be "ascending".
h2. To reproduce
Compile and run the following
{code:C#}
using Avro;
using System;
class Program
{
static void Main()
{
var schema = (RecordSchema)Schema.Parse(@"{
""type"": ""record"",
""name"": ""Demo"",
""fields"": [
{
""name"": ""field1"",
""type"": ""int""
}
]
}");
Field field = schema.Fields[0];
Console.WriteLine($"Ordering: {field.Ordering}");
}
}
{code}
h2. Expected result
Should output one of:
- "Ordering: ascending", if the library maps both "order":"ascending" and the
defaulted "order" property to Field.SortOrder.ascending.
- "Ordering: ", if the library maps "order":"ascending" to
Field.SortOrder.ascending and the defaulted "order" property to
(Field.SortOrder?)null.
h2. Actual result
Actually outputs "Ordering: ignore", i.e. maps the defaulted "order" property
to Field.SortOrder.ignore.
h2. References
Spec:
[https://github.com/apache/avro/blob/release-1.11.0/doc/src/content/xdocs/spec.xml#L134-L139]
{quote}
Valid values are "ascending" (the default), "descending", or "ignore".
{quote}
C# implementation RecordSchema.createField:
[https://github.com/apache/avro/blob/release-1.11.0/lang/csharp/src/apache/main/Schema/RecordSchema.cs#L149-L152]
C# implementation Field.Ordering:
[https://github.com/apache/avro/blob/release-1.11.0/lang/csharp/src/apache/main/Schema/Field.cs#L85-L88]
Customer impact is low because the library does not itself read Field.Ordering;
it does not provide methods for comparing record instances, and the avrogen
tool doesnot generate such methods either.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)