hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sze...@apache.org
Subject svn commit: r1669724 [2/2] - in /hive/trunk: ql/src/test/queries/clientpositive/ ql/src/test/results/clientpositive/ ql/src/test/results/clientpositive/spark/ serde/src/java/org/apache/hadoop/hive/serde2/avro/
Date Sat, 28 Mar 2015 01:25:02 GMT
Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroObjectInspectorGenerator.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroObjectInspectorGenerator.java?rev=1669724&r1=1669723&r2=1669724&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroObjectInspectorGenerator.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroObjectInspectorGenerator.java
Sat Mar 28 01:25:02 2015
@@ -43,13 +43,15 @@ import org.apache.hadoop.hive.serde2.typ
 public class AvroObjectInspectorGenerator {
   final private List<String> columnNames;
   final private List<TypeInfo> columnTypes;
+  final private List<String> columnComments;
   final private ObjectInspector oi;
 
   public AvroObjectInspectorGenerator(Schema schema) throws SerDeException {
     verifySchemaIsARecord(schema);
 
-    this.columnNames = generateColumnNames(schema);
+    this.columnNames = AvroObjectInspectorGenerator.generateColumnNames(schema);
     this.columnTypes = SchemaToTypeInfo.generateColumnTypes(schema);
+    this.columnComments = AvroObjectInspectorGenerator.generateColumnComments(schema);
     assert columnNames.size() == columnTypes.size();
     this.oi = createObjectInspector();
   }
@@ -80,7 +82,7 @@ public class AvroObjectInspectorGenerato
     for(int i = 0; i < columnNames.size(); i++) {
       columnOIs.add(i, createObjectInspectorWorker(columnTypes.get(i)));
     }
-    return ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, columnOIs);
+    return ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, columnOIs,
columnComments);
   }
 
   private ObjectInspector createObjectInspectorWorker(TypeInfo ti) throws SerDeException
{
@@ -145,7 +147,7 @@ public class AvroObjectInspectorGenerato
            c.equals(ObjectInspector.Category.UNION);
   }
 
-  private List<String> generateColumnNames(Schema schema) {
+  public static List<String> generateColumnNames(Schema schema) {
     List<Schema.Field> fields = schema.getFields();
     List<String> fieldsList = new ArrayList<String>(fields.size());
 
@@ -156,4 +158,15 @@ public class AvroObjectInspectorGenerato
     return fieldsList;
   }
 
+  public static List<String> generateColumnComments(Schema schema) {
+    List<Schema.Field> fields = schema.getFields();
+    List<String> fieldComments = new ArrayList<String>(fields.size());
+
+    for (Schema.Field field : fields) {
+      String fieldComment = field.doc() == null ? "" : field.doc();
+      fieldComments.add(fieldComment);
+    }
+
+    return fieldComments;
+  }
 }

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerDe.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerDe.java?rev=1669724&r1=1669723&r2=1669724&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerDe.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerDe.java Sat Mar 28
01:25:02 2015
@@ -133,7 +133,9 @@ public class AvroSerDe extends AbstractS
     if (columnCommentProperty == null || columnCommentProperty.isEmpty()) {
       columnComments = new ArrayList<String>();
     } else {
-      columnComments = Arrays.asList(columnCommentProperty.split(","));
+      //Comments are separated by "\0" in columnCommentProperty, see method getSchema
+      //in MetaStoreUtils where this string columns.comments is generated
+      columnComments = Arrays.asList(columnCommentProperty.split("\0"));
       LOG.info("columnComments is " + columnCommentProperty);
     }
     if (columnNames.size() != columnTypes.size()) {



Mime
View raw message