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

Pig Cannot handle nullable values (arrays and records) in avro records

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.13.0
    • 0.15.0
    • None
    • None
    • Patch Available
    • Reviewed

    Description

      Here's an example of an avro schema containing nullable values in a map

      {
          "name" : "nullableRecordInMap",
          "namespace" : "org.apache.pig.test.builtin",
          "type" : "record",
          "fields" : [
              {"name" : "key", "type" : "string"},
              {"name" : "value", "type" : "int"},
              {
                  "name" : "parameters",
                  "type": [
                      "null",
                      {
                          "type": "map",
                          "values": [
                              "null",
                              {
                                  "type": "record",
                                  "name": "nullable_record",
                                  "fields": [
                                      {
                                          "name": "id",
                                          "type": [
                                              "null",
                                              "string"
                                          ]
                                      }
                                  ]
                              }
                          ]
                      }
                  ]
              }
          ]
      }
      

      Here's the corresponding Pig resource schema on running it through org.apache.pig.impl.util.avro.AvroStorageSchemaConversionUtilities

      key:chararray,value:int,parameters:[nullable_record:(union:(id:chararray))]
      

      Note that Pig should unpack the underlying schema from the nullable union and the Pig schema should be

      key:chararray,value:int,parameters:[nullable_record:(id:chararray)]
      

      There's similar behavior if the nullal map value is of type array

      I've created a patch with a few testcases written.

      Attachments

        1. pig.patch
          5 kB
          Ratandeep Ratti

        Issue Links

          Activity

            People

              rdsr Ratandeep Ratti
              rdsr Ratandeep Ratti
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: