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

AVRO: AvroStorage give NPE on reading file with union as top level schema

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.11.2
    • 0.12.0
    • piggybank
    • AvroStorage

    Description

      I am getting NPE when loading a file with AvroStorage a file that has schema like:

      ["null",{"type":"record","name":"TUPLE_0","fields":[{"name":"name","type":["null","string"],"doc":"autogenerated from Pig Field Schema"},{"name":"age","type":["null","int"],"doc":"autogenerated from Pig Field Schema"},{"name":"gpa","type":["null","double"],"doc":"autogenerated from Pig Field Schema"}]}]
      

      E.g. see the e2e style test, which fails on this:

                              {
                              'num' => 4,
                              # storing file with Pig type tuple relying on conversion to record
                              # loading using stored schemas 
                              'notmq' => 1,
                              'pig' => q\
      a = load ':INPATH:/singlefile/studentcomplextab10k' using PigStorage() as (m:[], t:(name:chararray, age:int, gpa:double), b:{t:(name:chararray, age:int, gpa:double)});
      b = foreach a generate t;
      describe b;
      store b into ':OUTPATH:.intermediate' USING org.apache.pig.piggybank.storage.avro.AvroStorage();
      
      exec;
      
      -- Read back what was stored with Avro
      u = load ':OUTPATH:.intermediate' USING org.apache.pig.piggybank.storage.avro.AvroStorage();
      describe u;
      store u into ':OUTPATH:';
      \,
                              'verify_pig_script' => q\
      a = load ':INPATH:/singlefile/studentcomplextab10k' using PigStorage() as (m:[], t:(name:chararray, age:int, gpa:double), b:{t:(name:chararray, age:int, gpa:double)});
      b = foreach a generate t;
      describe b;
      store b into ':OUTPATH:';
      \,
                              },
      

      Attachments

        1. test_loadavrowithnulls.avro
          0.4 kB
          Viraj Bhat
        2. PIG-3322_3.patch
          5 kB
          Viraj Bhat

        Issue Links

          Activity

            People

              viraj Viraj Bhat
              esoren Egil Sorensen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: