You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2015/01/28 23:39:23 UTC

svn commit: r1655489 - in /hive/branches/branch-1.1: ./ data/files/ ql/src/test/queries/clientpositive/ ql/src/test/results/clientpositive/ serde/src/java/org/apache/hadoop/hive/serde2/avro/

Author: brock
Date: Wed Jan 28 22:39:22 2015
New Revision: 1655489

URL: http://svn.apache.org/r1655489
Log:
Merge HIVE-9462 - HIVE-8577 - breaks type evolution

Added:
    hive/branches/branch-1.1/data/files/type_evolution.avro
      - copied unchanged from r1655210, hive/trunk/data/files/type_evolution.avro
    hive/branches/branch-1.1/ql/src/test/queries/clientpositive/avro_type_evolution.q
      - copied unchanged from r1655210, hive/trunk/ql/src/test/queries/clientpositive/avro_type_evolution.q
    hive/branches/branch-1.1/ql/src/test/results/clientpositive/avro_type_evolution.q.out
      - copied unchanged from r1655210, hive/trunk/ql/src/test/results/clientpositive/avro_type_evolution.q.out
Modified:
    hive/branches/branch-1.1/   (props changed)
    hive/branches/branch-1.1/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java

Propchange: hive/branches/branch-1.1/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 28 22:39:22 2015
@@ -3,4 +3,4 @@
 /hive/branches/spark:1608589-1654414
 /hive/branches/tez:1494760-1622766
 /hive/branches/vectorization:1466908-1527856
-/hive/trunk:1655202
+/hive/trunk:1655202,1655210

Modified: hive/branches/branch-1.1/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-1.1/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java?rev=1655489&r1=1655488&r2=1655489&view=diff
==============================================================================
--- hive/branches/branch-1.1/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java (original)
+++ hive/branches/branch-1.1/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java Wed Jan 28 22:39:22 2015
@@ -41,6 +41,7 @@ import org.apache.avro.io.BinaryDecoder;
 import org.apache.avro.io.BinaryEncoder;
 import org.apache.avro.io.DecoderFactory;
 import org.apache.avro.io.EncoderFactory;
+import org.apache.avro.UnresolvedUnionException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.common.type.HiveChar;
@@ -316,8 +317,27 @@ class AvroDeserializer {
       if (fileSchema.getType() == Type.UNION) {
         // The fileSchema may have the null value in a different position, so
         // we need to get the correct tag
-        tag = GenericData.get().resolveUnion(fileSchema, datum);
-        currentFileSchema = fileSchema.getTypes().get(tag);
+        try {
+          tag = GenericData.get().resolveUnion(fileSchema, datum);
+          currentFileSchema = fileSchema.getTypes().get(tag);
+        } catch (UnresolvedUnionException e) {
+          if (LOG.isDebugEnabled()) {
+            String datumClazz = null;
+            if (datum != null) {
+              datumClazz = datum.getClass().getName();
+            }
+            String msg = "File schema union could not resolve union. fileSchema = " + fileSchema +
+              ", recordSchema = " + recordSchema + ", datum class = " + datumClazz + ": " + e;
+            LOG.debug(msg, e);
+          }
+          // This occurs when the datum type is different between
+          // the file and record schema. For example if datum is long
+          // and the field in the file schema is int. See HIVE-9462.
+          // in this case we will re-use the record schema as the file
+          // schema, Ultimately we need to clean this code up and will
+          // do as a follow-on to HIVE-9462.
+          currentFileSchema = schema;
+        }
       } else {
         currentFileSchema = fileSchema;
       }