Uploaded image for project: 'Talend DI components'
  1. Talend DI components
  2. TDI-46439

Exception raised when trying to convert an avro record to tck record

Apply templateInsert Lucidchart Diagram
    XMLWordPrintable

Details

    Description

      I have an avro record with a field of type array of array (please see attached avro file).
      When i try to convert it to TCK record with AvroToRecord class, i get the following exception

      AvroRuntimeException: Not a record
      

      After investigation, i found the code which leads to this exception:

      case ARRAY:
                  builder.withType(Type.ARRAY);
                  extractedSchema = AvroHelper.getUnionSchema(AvroHelper.getUnionSchema(field.schema()).getElementType());
                  Type toType = translateToRecordType((extractedSchema.getType()));
                  subBuilder = recordBuilderFactory.newSchemaBuilder(toType);
                  switch (toType) {
                  case RECORD:
                  case ARRAY:
                      extractedSchema.getFields().stream().map(this::inferAvroField).forEach(subBuilder::withEntry);
                      builder.withElementSchema(subBuilder.build());
                      break;
      

      Here we call extractedSchema.getFields() while the extracted schema is an array.

      Attachments

        1. properties.avro
          0.5 kB
          Tony Imbault
        2. Screenshot_31.png
          170 kB
          Oleksandra Tkachenko
        3. screenshot-1.png
          55 kB
          Oleksandra Tkachenko
        4. screenshot-10.png
          132 kB
          Oleksandra Tkachenko
        5. screenshot-11.png
          132 kB
          Oleksandra Tkachenko
        6. screenshot-12.png
          129 kB
          Oleksandra Tkachenko
        7. screenshot-2.png
          88 kB
          Oleksandra Tkachenko
        8. screenshot-3.png
          87 kB
          Oleksandra Tkachenko
        9. screenshot-4.png
          91 kB
          Oleksandra Tkachenko
        10. screenshot-5.png
          166 kB
          Oleksandra Tkachenko
        11. screenshot-6.png
          111 kB
          Oleksandra Tkachenko
        12. screenshot-7.png
          189 kB
          Oleksandra Tkachenko
        13. screenshot-8.png
          131 kB
          Oleksandra Tkachenko
        14. screenshot-9.png
          163 kB
          Oleksandra Tkachenko

        Issue Links

          Activity

            People

              pteyssier pierre teyssier
              timbault Tony Imbault
              Christophe LeSaec, Oleksandra Tkachenko (Inactive), Wei Yuan
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: