Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-7049

Unable to deserialize AVRO data when file schema and record schema are different and nullable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.0
    • Component/s: None
    • Labels:
      None

      Description

      It mainly happens when
      1 )file schema and record schema are not same
      2 ) Record schema is nullable but file schema is not.

      The potential code location is at class AvroDeserialize

       if(AvroSerdeUtils.isNullableType(recordSchema)) {
            return deserializeNullableUnion(datum, fileSchema, recordSchema, columnType);
          }
      

      In the above code snippet, recordSchema is verified if it is nullable. But the file schema is not checked.

      I tested with these values:

      recordSchema= ["null","string"]
      fielSchema= "string"
      

      And i got the following exception <line numbers might not be the same due to mu debugged code version>.

      org.apache.avro.AvroRuntimeException: Not a union: "string" 
              at org.apache.avro.Schema.getTypes(Schema.java:272)
              at org.apache.hadoop.hive.serde2.avro.AvroDeserializer.deserializeNullableUnion(AvroDeserializer.java:275)
              at org.apache.hadoop.hive.serde2.avro.AvroDeserializer.worker(AvroDeserializer.java:205)
              at org.apache.hadoop.hive.serde2.avro.AvroDeserializer.workerBase(AvroDeserializer.java:188)
              at org.apache.hadoop.hive.serde2.avro.AvroDeserializer.deserialize(AvroDeserializer.java:174)
              at org.apache.hadoop.hive.serde2.avro.TestAvroDeserializer.verifyNullableType(TestAvroDeserializer.java:487)
              at org.apache.hadoop.hive.serde2.avro.TestAvroDeserializer.canDeserializeNullableTypes(TestAvroDeserializer.java:407)
      
      

        Attachments

        1. HIVE-7049.1.patch
          4 kB
          Mohammad Kamrul Islam
        2. Statistic
          2 kB
          Daniel Dai
        3. Statistics10Min.avsc
          2 kB
          Daniel Dai
        4. HIVE-7049.2.patch
          5 kB
          Daniel Dai

          Issue Links

            Activity

              People

              • Assignee:
                daijy Daniel Dai
                Reporter:
                kamrul Mohammad Kamrul Islam
              • Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: