Uploaded image for project: 'Pig'
  1. Pig
  2. PIG-3377

New AvroStorage throws NPE when storing untyped map/array/bag

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.13.0
    • internal-udfs
    • None

    Description

      The following example demonstrates the issue:

      a = LOAD 'foo' AS (m:map[]);
      STORE a INTO 'bar' USING AvroStorage();
      

      This fails with the following error:

      java.lang.NullPointerException
          at org.apache.pig.impl.util.avro.AvroStorageSchemaConversionUtilities.resourceFieldSchemaToAvroSchema(AvroStorageSchemaConversionUtilities.java:462)
          at org.apache.pig.impl.util.avro.AvroStorageSchemaConversionUtilities.resourceSchemaToAvroSchema(AvroStorageSchemaConversionUtilities.java:335)
          at org.apache.pig.builtin.AvroStorage.checkSchema(AvroStorage.java:472)
      

      Similarly, untyped bag causes the following error:

      Caused by: java.lang.NullPointerException
          at org.apache.avro.Schema$ArraySchema.toJson(Schema.java:722)
          ...
          at org.apache.avro.Schema.getElementType(Schema.java:256)
          at org.apache.pig.builtin.AvroStorage.setOutputAvroSchema(AvroStorage.java:491)
      

      The problem is that AvroStorage cannot derive the output schema from untyped map/bag/tuple. When type is not defined, it should be assumed as bytearray.

      Attachments

        1. PIG-3377-2.patch
          2 kB
          Cheolsoo Park
        2. PIG-3377.patch
          1 kB
          Joseph Adler

        Activity

          People

            jadler Joseph Adler
            cheolsoo Cheolsoo Park
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: