title: Can Hive deserialize avro bytes to the schema provided?
body: <p>I have avro file to be loaded into Hive but my file is in binary.
  What deserializer should be used to get the binary avro to hive?</p>
  
  <p>I don't want binary data in hive but the decoded binary data.</p>
  
  <p>This is how I create my table.</p>
  
  <p>CREATE TABLE kst7
    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'
    TBLPROPERTIES (
      'avro.schema.url'='pathtoavsc.avsc');</p>
  
  <p>When I use the above command table gets created, data gets loaded but when I do a select * from table I get below error:</p>
  
  <p><strong>Failed with exception java.io.IOException:org.apache.avro.AvroTypeException: Found bytes, expecting union</strong></p>
  
  <p>avsc file:</p>
  
  <pre><code>{
  "namespace": "com.nimesh.tripod.avro.enrichment",
  "type": "record",
  "name": "EnrichmentData",
  "fields": [
      {"name": "rowKey", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
      {"name": "ownerGuid", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
      {"name": "autotagsEnrichment", "type": ["bytes", "null", {
                                                          "namespace": "com.nimesh.tripod.avro.enrichment",
                                                          "type": "record",
                                                          "name": "AutotagEnrichment",
                                                          "fields": [
                                                              {"name": "version", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
                                                              {"name": "autotags", "type": ["null", {"type": "array", "items": {
                                                                                                                                   "namespace": "com.nimesh.tripod.avro.enrichment",
                                                                                                                                   "type": "record",
                                                                                                                                   "name": "Autotag",
                                                                                                                                   "fields": [
                                                                                                                                       {"name": "tag", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
                                                                                                                                       {"name": "score", "type": ["null", "double"], "default": null}
                                                                                                                                   ]
                                                                                                                               }}], "default": null}
                                                          ]
                                                      }], "default": null},
      {"name": "colorEnrichment", "type": ["bytes","null", {
                                                       "namespace": "com.nimesh.tripod.avro.enrichment",
                                                       "type": "record",
                                                       "name": "ColorEnrichment",
                                                       "fields": [
                                                           {"name": "version", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
                                                           {"name": "color", "type": ["null", {"type": "array", "items": {
                                                                                                                             "namespace": "com.nimesh.tripod.avro.enrichment",
                                                                                                                             "type": "record",
                                                                                                                             "name": "Color",
                                                                                                                             "fields": [
                                                                                                                                 {"name": "color", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
                                                                                                                                 {"name": "score", "type": ["null", "double"], "default": null}
                                                                                                                             ]
                                                                                                                         }}], "default": null}
                                                       ]
                                                   }], "default": null}
  ]
  }
  </code></pre>