[ 
https://issues.apache.org/jira/browse/HIVE-7049?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Dai updated HIVE-7049:
-----------------------------
    Attachment: HIVE-7049.2.patch
                Statistics10Min.avsc
                Statistic

Hit the same issue and here is the reproducible steps:
{code}
CREATE TABLE Statistics10Min 
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' 
STORED AS INPUTFORMAT 
'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' 
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' 
LOCATION '/user/daijy/data/Statistics10Min/' 
TBLPROPERTIES 
('avro.schema.url'='/user/daijy/Statistics10Min/Statistics10Min.avsc');
{code}
select * from Statistics10Min fail with the message:
{code}
Failed with exception java.io.IOException:org.apache.avro.AvroRuntimeException: 
Not a record: 
["null",{"type":"record","name":"Statistic","namespace":"SHARP","fields":[{"name":"WindFarm","type":["null","string"]},{"name":"WTG","type":["null","string"]},{"name":"LocalTS","type":["null","string"]},{"name":"TS","type":["null","string"]},{"name":"WindSpeedAvg","type":"string"},{"name":"WindSpeedMin","type":"string"},{"name":"WindSpeedMax","type":"string"},{"name":"WindSpeedStdDev","type":"string"},{"name":"ActPowAvg","type":"string"},{"name":"ActPowMin","type":"string"},{"name":"ActPowMax","type":"string"},{"name":"ActPowStdDev","type":"string"},{"name":"ReactPowAvg","type":"string"},{"name":"ReactPowMin","type":"string"},{"name":"ReactPowMax","type":"string"},{"name":"ReactPowStdDev","type":"string"},{"name":"GenSpeedAvg","type":"string"},{"name":"GenSpeedMin","type":"string"},{"name":"GenSpeedMax","type":"string"},{"name":"GenSpeedStdDev","type":"string"},{"name":"RotSpeedAvg","type":"string"},{"name":"RotSpeedMin","type":"string"},{"name":"RotSpeedMax","type":"string"},{"name":"RotSpeedStdDev","type":"string"},{"name":"YawDirAvg","type":"string"},{"name":"YawDirMin","type":"string"},{"name":"YawDirMax","type":"string"},{"name":"YawDirStdDev","type":"string"},{"name":"VibTowAvg","type":"string"},{"name":"VibTowMin","type":"string"},{"name":"VibTowMax","type":"string"},{"name":"VibTowStdDev","type":"string"},{"name":"PitchAvg","type":"string"},{"name":"PitchMin","type":"string"},{"name":"PitchMax","type":"string"},{"name":"PitchRateMin","type":"string"},{"name":"PitchRateMax","type":"string"},{"name":"PitchRateStdDev","type":"string"},{"name":"GridVoltAvg","type":"int"},{"name":"GridVoltMin","type":"int"},{"name":"GridVoltMax","type":"int"},{"name":"EnvTempAvg","type":"string"},{"name":"EnvTempMin","type":"string"},{"name":"EnvTempMax","type":"string"},{"name":"GbxTempAvg","type":"string"},{"name":"GbxTempMin","type":"string"},{"name":"GbxTempMax","type":"string"},{"name":"GenAccMin","type":"string"},{"name":"GenAccMax","type":"string"},{"name":"VibratAvg","type":"string"},{"name":"VibratMax","type":"string"},{"name":"GenU1TempAvg","type":"string"},{"name":"GenU1TempMin","type":"string"},{"name":"GenU1TempMax","type":"string"},{"name":"RotorSideLTempAvg","type":"string"},{"name":"RotorSideLTempMin","type":"string"},{"name":"RotorSideLTempMax","type":"string"},{"name":"WindBin","type":"int"},{"name":"FreqMean","type":"string"}]}]
{code}
Stack:
{code}
        at org.apache.avro.Schema.getField(Schema.java:184)
        at 
org.apache.hadoop.hive.serde2.avro.AvroDeserializer.workerBase(AvroDeserializer.java:191)
        at 
org.apache.hadoop.hive.serde2.avro.AvroDeserializer.deserialize(AvroDeserializer.java:178)
        at 
org.apache.hadoop.hive.serde2.avro.AvroSerDe.deserialize(AvroSerDe.java:199)
        at 
org.apache.hadoop.hive.ql.exec.FetchOperator.getNextRow(FetchOperator.java:488)
{code}

Note this is broken by HIVE-5823.

Attach HIVE-7049.2.patch. [~xuefuz], can you check if the new patch work with 
decimal?

> Unable to deserialize AVRO data when file schema and record schema are 
> different and nullable
> ---------------------------------------------------------------------------------------------
>
>                 Key: HIVE-7049
>                 URL: https://issues.apache.org/jira/browse/HIVE-7049
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Mohammad Kamrul Islam
>            Assignee: Mohammad Kamrul Islam
>         Attachments: HIVE-7049.1.patch, HIVE-7049.2.patch, Statistic, 
> Statistics10Min.avsc
>
>
> 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
>  
> {noformat}
>  if(AvroSerdeUtils.isNullableType(recordSchema)) {
>       return deserializeNullableUnion(datum, fileSchema, recordSchema, 
> columnType);
>     }
> {noformat}
> In the above code snippet, recordSchema is verified if it is nullable. But 
> the file schema is not checked.
> I tested with these values:
> {noformat}
> recordSchema= ["null","string"]
> fielSchema= "string"
> {noformat}
> And i got the following exception <line numbers might not be the same due to 
> mu debugged code version>.
> {noformat}
> 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)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to