You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Andrew Benedek (Jira)" <ji...@apache.org> on 2023/03/21 07:54:00 UTC

[jira] [Created] (AVRO-3724) C# JsonEncoder can't handle nested array of records

Andrew Benedek created AVRO-3724:
------------------------------------

             Summary: C# JsonEncoder can't handle nested array of records
                 Key: AVRO-3724
                 URL: https://issues.apache.org/jira/browse/AVRO-3724
             Project: Apache Avro
          Issue Type: Bug
          Components: csharp
    Affects Versions: 1.11.2
            Reporter: Andrew Benedek
         Attachments: Program.cs, sample2.avsc

The exception is:

Avro.AvroTypeException
  HResult=0x80131500
  Message=Incorrect number of items written. 1 more required.
  Source=Avro
  StackTrace:
   at Avro.IO.ParsingEncoder.Pop() in C:\code\avro\lang\csharp\src\apache\main\IO\ParsingEncoder.cs:line 135
   at Avro.IO.JsonEncoder.WriteArrayEnd() in C:\code\avro\lang\csharp\src\apache\main\IO\JsonEncoder.cs:line 259
   at Avro.Generic.PreresolvingDatumWriter`1.WriteArray(WriteItem itemWriter, Object array, Encoder encoder) in C:\code\avro\lang\csharp\src\apache\main\Generic\PreresolvingDatumWriter.cs:line 235
   at Avro.Generic.PreresolvingDatumWriter`1.<>c__DisplayClass20_0.<ResolveArray>b__0(Object d, Encoder e) in C:\code\avro\lang\csharp\src\apache\main\Generic\PreresolvingDatumWriter.cs:line 225
   at Avro.Specific.SpecificDatumWriter`1.WriteRecordFields(Object recordObj, RecordFieldWriter[] writers, Encoder encoder) in C:\code\avro\lang\csharp\src\apache\main\Specific\SpecificDatumWriter.cs:line 46
   at Avro.Generic.PreresolvingDatumWriter`1.<>c__DisplayClass14_0.<ResolveRecord>b__0(Object v, Encoder e) in C:\code\avro\lang\csharp\src\apache\main\Generic\PreresolvingDatumWriter.cs:line 147
   at Avro.Generic.PreresolvingDatumWriter`1.Write(T datum, Encoder encoder) in C:\code\avro\lang\csharp\src\apache\main\Generic\PreresolvingDatumWriter.cs:line 52
   at Program.<Main>$(String[] args) in C:\code\ips-sales-replication\producer\AvroConsoleApp\Program.cs:line 210

 

I have cloned the GitHub repo and built the C# solution (Avro.dll) since 1.11.2 with the JsonEncoder has not yet been released as a Nuget package.

A schema with a nested record works fine.
A schema with a nested array of record throws the above exception.

The BinaryEncoder however is able to produce the binary Avro with the same schema.

I have attached the schema.

My code is a simple C# .NET console application.

Program.cs is also attached.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)