Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3724

C# JsonEncoder can't handle nested array of records

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      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.

      Attachments

        1. sample2.avsc
          0.7 kB
          Andrew Benedek
        2. Program.cs
          1 kB
          Andrew Benedek
        3. PAYMENT.cs
          2 kB
          Andrew Benedek
        4. Transaction.cs
          2 kB
          Andrew Benedek

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rayokota Robert Yokota
            abenedek Andrew Benedek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 2h
                2h

                Slack

                  Issue deployment