You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "Robert Yokota (Jira)" <ji...@apache.org> on 2023/03/22 23:17:00 UTC

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

    [ https://issues.apache.org/jira/browse/AVRO-3724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17703811#comment-17703811 ] 

Robert Yokota edited comment on AVRO-3724 at 3/22/23 11:16 PM:
---------------------------------------------------------------

It seems `SpecificDatumWriter` is missing a call to `encoder.StartItem` in `WriteArrayValues` (similar to the same call in `GenericDatumWriter`).  I'll work on a PR.


was (Author: rayokota):
It seems `SpecificDatumWriter` is missing a call to `encoder.StartItem` in `WriteArrayValues` (similar to the same call in `GenericDatumWriter`.  I'll work on a PR.

> 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
>            Priority: Major
>         Attachments: PAYMENT.cs, Program.cs, Transaction.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 along with the schema data model that was generated using CodeGen.



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