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

svn commit: r1669718 [29/29] - in /hive/branches/llap: ./ ant/src/org/apache/hadoop/hive/ant/ common/src/java/org/apache/hadoop/hive/common/ common/src/java/org/apache/hadoop/hive/common/type/ common/src/java/org/apache/hadoop/hive/conf/ common/src/jav...

Modified: hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java (original)
+++ hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java Sat Mar 28 00:22:15 2015
@@ -28,6 +28,8 @@ import org.apache.hadoop.hive.serde2.io.
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
 import org.apache.hadoop.hive.serde2.io.HiveCharWritable;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
@@ -85,6 +87,10 @@ public final class PrimitiveObjectInspec
       new WritableDateObjectInspector();
   public static final WritableTimestampObjectInspector writableTimestampObjectInspector =
       new WritableTimestampObjectInspector();
+  public static final WritableHiveIntervalYearMonthObjectInspector writableHiveIntervalYearMonthObjectInspector =
+      new WritableHiveIntervalYearMonthObjectInspector();
+  public static final WritableHiveIntervalDayTimeObjectInspector writableHiveIntervalDayTimeObjectInspector =
+      new WritableHiveIntervalDayTimeObjectInspector();
   public static final WritableBinaryObjectInspector writableBinaryObjectInspector =
       new WritableBinaryObjectInspector();
   public static final WritableHiveDecimalObjectInspector writableHiveDecimalObjectInspector =
@@ -118,6 +124,10 @@ public final class PrimitiveObjectInspec
         writableDateObjectInspector);
     cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TIMESTAMP_TYPE_NAME),
         writableTimestampObjectInspector);
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME),
+        writableHiveIntervalYearMonthObjectInspector);
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME),
+        writableHiveIntervalDayTimeObjectInspector);
     cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BINARY_TYPE_NAME),
         writableBinaryObjectInspector);
     cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.decimalTypeInfo, writableHiveDecimalObjectInspector);
@@ -139,6 +149,8 @@ public final class PrimitiveObjectInspec
     primitiveCategoryToWritableOI.put(PrimitiveCategory.VOID, writableVoidObjectInspector);
     primitiveCategoryToWritableOI.put(PrimitiveCategory.DATE, writableDateObjectInspector);
     primitiveCategoryToWritableOI.put(PrimitiveCategory.TIMESTAMP, writableTimestampObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.INTERVAL_YEAR_MONTH, writableHiveIntervalYearMonthObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.INTERVAL_DAY_TIME, writableHiveIntervalDayTimeObjectInspector);
     primitiveCategoryToWritableOI.put(PrimitiveCategory.BINARY, writableBinaryObjectInspector);
     primitiveCategoryToWritableOI.put(PrimitiveCategory.DECIMAL, writableHiveDecimalObjectInspector);
   }
@@ -169,6 +181,10 @@ public final class PrimitiveObjectInspec
       new JavaDateObjectInspector();
   public static final JavaTimestampObjectInspector javaTimestampObjectInspector =
       new JavaTimestampObjectInspector();
+  public static final JavaHiveIntervalYearMonthObjectInspector javaHiveIntervalYearMonthObjectInspector =
+      new JavaHiveIntervalYearMonthObjectInspector();
+  public static final JavaHiveIntervalDayTimeObjectInspector javaHiveIntervalDayTimeObjectInspector =
+      new JavaHiveIntervalDayTimeObjectInspector();
   public static final JavaBinaryObjectInspector javaByteArrayObjectInspector =
       new JavaBinaryObjectInspector();
   public static final JavaHiveDecimalObjectInspector javaHiveDecimalObjectInspector =
@@ -202,6 +218,10 @@ public final class PrimitiveObjectInspec
         javaDateObjectInspector);
     cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TIMESTAMP_TYPE_NAME),
         javaTimestampObjectInspector);
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME),
+        javaHiveIntervalYearMonthObjectInspector);
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME),
+        javaHiveIntervalDayTimeObjectInspector);
     cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BINARY_TYPE_NAME),
         javaByteArrayObjectInspector);
     cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.decimalTypeInfo, javaHiveDecimalObjectInspector);
@@ -223,6 +243,8 @@ public final class PrimitiveObjectInspec
     primitiveCategoryToJavaOI.put(PrimitiveCategory.VOID, javaVoidObjectInspector);
     primitiveCategoryToJavaOI.put(PrimitiveCategory.DATE, javaDateObjectInspector);
     primitiveCategoryToJavaOI.put(PrimitiveCategory.TIMESTAMP, javaTimestampObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.INTERVAL_YEAR_MONTH, javaHiveIntervalYearMonthObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.INTERVAL_DAY_TIME, javaHiveIntervalDayTimeObjectInspector);
     primitiveCategoryToJavaOI.put(PrimitiveCategory.BINARY, javaByteArrayObjectInspector);
     primitiveCategoryToJavaOI.put(PrimitiveCategory.DECIMAL, javaHiveDecimalObjectInspector);
   }
@@ -310,6 +332,10 @@ public final class PrimitiveObjectInspec
       return new WritableConstantDateObjectInspector((DateWritable)value);
     case TIMESTAMP:
       return new WritableConstantTimestampObjectInspector((TimestampWritable)value);
+    case INTERVAL_YEAR_MONTH:
+      return new WritableConstantHiveIntervalYearMonthObjectInspector((HiveIntervalYearMonthWritable) value);
+    case INTERVAL_DAY_TIME:
+      return new WritableConstantHiveIntervalDayTimeObjectInspector((HiveIntervalDayTimeWritable) value);
     case DECIMAL:
       return new WritableConstantHiveDecimalObjectInspector((DecimalTypeInfo)typeInfo, (HiveDecimalWritable)value);
     case BINARY:

Modified: hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java (original)
+++ hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java Sat Mar 28 00:22:15 2015
@@ -31,6 +31,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.common.type.HiveChar;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
 import org.apache.hadoop.hive.serde.serdeConstants;
 import org.apache.hadoop.hive.serde2.io.ByteWritable;
@@ -38,6 +40,8 @@ import org.apache.hadoop.hive.serde2.io.
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
 import org.apache.hadoop.hive.serde2.io.HiveCharWritable;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
@@ -221,6 +225,12 @@ public final class PrimitiveObjectInspec
   public static final PrimitiveTypeEntry timestampTypeEntry = new PrimitiveTypeEntry(
       PrimitiveCategory.TIMESTAMP, serdeConstants.TIMESTAMP_TYPE_NAME, null,
       Timestamp.class, TimestampWritable.class);
+  public static final PrimitiveTypeEntry intervalYearMonthTypeEntry = new PrimitiveTypeEntry(
+      PrimitiveCategory.INTERVAL_YEAR_MONTH, serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME, null,
+      HiveIntervalYearMonth.class, HiveIntervalYearMonthWritable.class);
+  public static final PrimitiveTypeEntry intervalDayTimeTypeEntry = new PrimitiveTypeEntry(
+      PrimitiveCategory.INTERVAL_DAY_TIME, serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME, null,
+      HiveIntervalDayTime.class, HiveIntervalDayTimeWritable.class);
   public static final PrimitiveTypeEntry decimalTypeEntry = new PrimitiveTypeEntry(
       PrimitiveCategory.DECIMAL, serdeConstants.DECIMAL_TYPE_NAME, null,
       HiveDecimal.class, HiveDecimalWritable.class);
@@ -250,6 +260,8 @@ public final class PrimitiveObjectInspec
     registerType(shortTypeEntry);
     registerType(dateTypeEntry);
     registerType(timestampTypeEntry);
+    registerType(intervalYearMonthTypeEntry);
+    registerType(intervalDayTimeTypeEntry);
     registerType(decimalTypeEntry);
     registerType(unknownTypeEntry);
   }
@@ -426,6 +438,14 @@ public final class PrimitiveObjectInspec
       return ((TimestampObjectInspector) oi1).getPrimitiveWritableObject(o1)
           .equals(((TimestampObjectInspector) oi2).getPrimitiveWritableObject(o2));
     }
+    case INTERVAL_YEAR_MONTH: {
+      return ((HiveIntervalYearMonthObjectInspector) oi1).getPrimitiveWritableObject(o1)
+          .equals(((HiveIntervalYearMonthObjectInspector) oi2).getPrimitiveWritableObject(o2));
+    }
+    case INTERVAL_DAY_TIME: {
+      return ((HiveIntervalDayTimeObjectInspector) oi1).getPrimitiveWritableObject(o1)
+          .equals(((HiveIntervalDayTimeObjectInspector) oi2).getPrimitiveWritableObject(o2));
+    }
     case BINARY: {
       return ((BinaryObjectInspector) oi1).getPrimitiveWritableObject(o1).
           equals(((BinaryObjectInspector) oi2).getPrimitiveWritableObject(o2));
@@ -836,6 +856,12 @@ public final class PrimitiveObjectInspec
     case TIMESTAMP:
       result = ((TimestampObjectInspector) oi).getPrimitiveWritableObject(o).toString();
       break;
+    case INTERVAL_YEAR_MONTH:
+      result = ((HiveIntervalYearMonthObjectInspector) oi).getPrimitiveWritableObject(o).toString();
+      break;
+    case INTERVAL_DAY_TIME:
+      result = ((HiveIntervalDayTimeObjectInspector) oi).getPrimitiveWritableObject(o).toString();
+      break;
     case DECIMAL:
       result = ((HiveDecimalObjectInspector) oi)
           .getPrimitiveJavaObject(o).toString();
@@ -1032,27 +1058,33 @@ public final class PrimitiveObjectInspec
     }
 
     Timestamp result = null;
+    long longValue = 0;
     switch (oi.getPrimitiveCategory()) {
     case VOID:
       result = null;
       break;
     case BOOLEAN:
-      result = new Timestamp(((BooleanObjectInspector) oi).get(o) ? 1 : 0);
+      longValue = ((BooleanObjectInspector) oi).get(o) ? 1 : 0;
+      result = TimestampWritable.longToTimestamp(longValue); 
       break;
     case BYTE:
-      result = new Timestamp(((ByteObjectInspector) oi).get(o));
+      longValue = ((ByteObjectInspector) oi).get(o);
+      result = TimestampWritable.longToTimestamp(longValue);
       break;
     case SHORT:
-      result = new Timestamp(((ShortObjectInspector) oi).get(o));
+      longValue = ((ShortObjectInspector) oi).get(o);
+      result = TimestampWritable.longToTimestamp(longValue);
       break;
     case INT:
-      result = new Timestamp(((IntObjectInspector) oi).get(o));
+      longValue = ((IntObjectInspector) oi).get(o);
+      result = TimestampWritable.longToTimestamp(longValue);
       break;
     case LONG:
-      result = new Timestamp(((LongObjectInspector) oi).get(o));
+      longValue = ((LongObjectInspector) oi).get(o);
+      result = TimestampWritable.longToTimestamp(longValue);
       break;
     case FLOAT:
-      result = TimestampWritable.floatToTimestamp(((FloatObjectInspector) oi).get(o));
+      result = TimestampWritable.doubleToTimestamp(((FloatObjectInspector) oi).get(o));
       break;
     case DOUBLE:
       result = TimestampWritable.doubleToTimestamp(((DoubleObjectInspector) oi).get(o));
@@ -1103,6 +1135,71 @@ public final class PrimitiveObjectInspec
     return result;
   }
 
+  public static HiveIntervalYearMonth getHiveIntervalYearMonth(Object o, PrimitiveObjectInspector oi) {
+    if (o == null) {
+      return null;
+    }
+
+    HiveIntervalYearMonth result = null;
+    switch (oi.getPrimitiveCategory()) {
+      case VOID:
+        result = null;
+        break;
+      case STRING:
+      case CHAR:
+      case VARCHAR: {
+        try {
+          String val = getString(o, oi).trim();
+          result = HiveIntervalYearMonth.valueOf(val);
+        } catch (IllegalArgumentException e) {
+          result = null;
+        }
+        break;
+      }
+      case INTERVAL_YEAR_MONTH:
+        result = ((HiveIntervalYearMonthObjectInspector) oi).getPrimitiveJavaObject(o);
+        break;
+
+      default:
+        throw new RuntimeException("Cannot convert to IntervalYearMonth from: " + oi.getTypeName());
+    }
+
+    return result;
+  }
+
+
+  public static HiveIntervalDayTime getHiveIntervalDayTime(Object o, PrimitiveObjectInspector oi) {
+    if (o == null) {
+      return null;
+    }
+
+    HiveIntervalDayTime result = null;
+    switch (oi.getPrimitiveCategory()) {
+      case VOID:
+        result = null;
+        break;
+      case STRING:
+      case CHAR:
+      case VARCHAR: {
+        try {
+          String val = getString(o, oi).trim();
+          result = HiveIntervalDayTime.valueOf(val);
+        } catch (IllegalArgumentException e) {
+          result = null;
+        }
+        break;
+      }
+      case INTERVAL_DAY_TIME:
+        result = ((HiveIntervalDayTimeObjectInspector) oi).getPrimitiveJavaObject(o);
+        break;
+
+      default:
+        throw new RuntimeException("Cannot convert to IntervalDayTime from: " + oi.getTypeName());
+    }
+
+    return result;
+  }
+
   public static Class<?> getJavaPrimitiveClassFromObjectInspector(ObjectInspector oi) {
     if (oi.getCategory() != Category.PRIMITIVE) {
       return null;
@@ -1117,7 +1214,7 @@ public final class PrimitiveObjectInspec
    * Provide a general grouping for each primitive data type.
    */
   public static enum PrimitiveGrouping {
-    NUMERIC_GROUP, STRING_GROUP, BOOLEAN_GROUP, DATE_GROUP, BINARY_GROUP,
+    NUMERIC_GROUP, STRING_GROUP, BOOLEAN_GROUP, DATE_GROUP, INTERVAL_GROUP, BINARY_GROUP,
     VOID_GROUP, UNKNOWN_GROUP
   };
 
@@ -1147,6 +1244,9 @@ public final class PrimitiveObjectInspec
       case TIMESTAMP:
       case DATE:
         return PrimitiveGrouping.DATE_GROUP;
+      case INTERVAL_YEAR_MONTH:
+      case INTERVAL_DAY_TIME:
+        return PrimitiveGrouping.INTERVAL_GROUP;
       case BINARY:
         return PrimitiveGrouping.BINARY_GROUP;
       case VOID:

Added: hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalDayTimeObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalDayTimeObjectInspector.java?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalDayTimeObjectInspector.java (added)
+++ hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalDayTimeObjectInspector.java Sat Mar 28 00:22:15 2015
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+
+
+/**
+ * A SettableHiveIntervalDayTimeObjectInspector can set a IntervalDayTime value to an object.
+ */
+public interface SettableHiveIntervalDayTimeObjectInspector
+    extends HiveIntervalDayTimeObjectInspector {
+  Object set(Object o, HiveIntervalDayTime i);
+
+  Object set(Object o, HiveIntervalDayTimeWritable i);
+
+  Object create(HiveIntervalDayTime i);
+}

Added: hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalYearMonthObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalYearMonthObjectInspector.java?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalYearMonthObjectInspector.java (added)
+++ hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalYearMonthObjectInspector.java Sat Mar 28 00:22:15 2015
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
+
+
+/**
+ * A SettableHiveIntervalYearMonthObjectInspector can set a IntervalYearMonth value to an object.
+ */
+public interface SettableHiveIntervalYearMonthObjectInspector
+    extends HiveIntervalYearMonthObjectInspector {
+  Object set(Object o, HiveIntervalYearMonth i);
+
+  Object set(Object o, HiveIntervalYearMonthWritable i);
+
+  Object create(HiveIntervalYearMonth i);
+}

Added: hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalDayTimeObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalDayTimeObjectInspector.java?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalDayTimeObjectInspector.java (added)
+++ hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalDayTimeObjectInspector.java Sat Mar 28 00:22:15 2015
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
+
+public class WritableConstantHiveIntervalDayTimeObjectInspector
+    extends WritableHiveIntervalDayTimeObjectInspector
+    implements ConstantObjectInspector {
+
+  private HiveIntervalDayTimeWritable value;
+
+  protected WritableConstantHiveIntervalDayTimeObjectInspector() {
+    super();
+  }
+
+  WritableConstantHiveIntervalDayTimeObjectInspector(HiveIntervalDayTimeWritable value) {
+    super();
+    this.value = value;
+  }
+
+  @Override
+  public Object getWritableConstantValue() {
+    return value;
+  }
+}

Added: hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalYearMonthObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalYearMonthObjectInspector.java?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalYearMonthObjectInspector.java (added)
+++ hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalYearMonthObjectInspector.java Sat Mar 28 00:22:15 2015
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
+
+public class WritableConstantHiveIntervalYearMonthObjectInspector
+    extends WritableHiveIntervalYearMonthObjectInspector
+    implements ConstantObjectInspector {
+
+  private HiveIntervalYearMonthWritable value;
+
+  protected WritableConstantHiveIntervalYearMonthObjectInspector() {
+    super();
+  }
+
+  WritableConstantHiveIntervalYearMonthObjectInspector(HiveIntervalYearMonthWritable value) {
+    super();
+    this.value = value;
+  }
+
+  @Override
+  public Object getWritableConstantValue() {
+    return value;
+  }
+}

Added: hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalDayTimeObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalDayTimeObjectInspector.java?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalDayTimeObjectInspector.java (added)
+++ hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalDayTimeObjectInspector.java Sat Mar 28 00:22:15 2015
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+
+public class WritableHiveIntervalDayTimeObjectInspector
+    extends AbstractPrimitiveWritableObjectInspector
+    implements SettableHiveIntervalDayTimeObjectInspector{
+
+  public WritableHiveIntervalDayTimeObjectInspector() {
+    super(TypeInfoFactory.intervalDayTimeTypeInfo);
+  }
+
+  @Override
+  public HiveIntervalDayTime getPrimitiveJavaObject(Object o) {
+    return o == null ? null : ((HiveIntervalDayTimeWritable) o).getHiveIntervalDayTime();
+  }
+
+  @Override
+  public HiveIntervalDayTimeWritable getPrimitiveWritableObject(Object o) {
+    return o == null ? null : (HiveIntervalDayTimeWritable) o;
+  }
+
+  @Override
+  public Object copyObject(Object o) {
+    return o == null ? null : new HiveIntervalDayTimeWritable((HiveIntervalDayTimeWritable) o);
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalDayTime i) {
+    if (i == null) {
+      return null;
+    }
+    ((HiveIntervalDayTimeWritable) o).set(i);
+    return o;
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalDayTimeWritable i) {
+    if (i == null) {
+      return null;
+    }
+    ((HiveIntervalDayTimeWritable) o).set(i);
+    return o;
+  }
+
+  @Override
+  public Object create(HiveIntervalDayTime i) {
+    return i == null ? null : new HiveIntervalDayTimeWritable(i);
+  }
+}

Added: hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalYearMonthObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalYearMonthObjectInspector.java?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalYearMonthObjectInspector.java (added)
+++ hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalYearMonthObjectInspector.java Sat Mar 28 00:22:15 2015
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+
+public class WritableHiveIntervalYearMonthObjectInspector
+    extends AbstractPrimitiveWritableObjectInspector
+    implements SettableHiveIntervalYearMonthObjectInspector{
+
+  public WritableHiveIntervalYearMonthObjectInspector() {
+    super(TypeInfoFactory.intervalYearMonthTypeInfo);
+  }
+
+  @Override
+  public HiveIntervalYearMonth getPrimitiveJavaObject(Object o) {
+    return o == null ? null : ((HiveIntervalYearMonthWritable) o).getHiveIntervalYearMonth();
+  }
+
+  @Override
+  public HiveIntervalYearMonthWritable getPrimitiveWritableObject(Object o) {
+    return o == null ? null : (HiveIntervalYearMonthWritable) o;
+  }
+
+  @Override
+  public Object copyObject(Object o) {
+    return o == null ? null : new HiveIntervalYearMonthWritable((HiveIntervalYearMonthWritable) o);
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalYearMonth i) {
+    if (i == null) {
+      return null;
+    }
+    ((HiveIntervalYearMonthWritable) o).set(i);
+    return o;
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalYearMonthWritable i) {
+    if (i == null) {
+      return null;
+    }
+    ((HiveIntervalYearMonthWritable) o).set(i);
+    return o;
+  }
+
+  @Override
+  public Object create(HiveIntervalYearMonth i) {
+    return i == null ? null : new HiveIntervalYearMonthWritable(i);
+  }
+}

Modified: hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/TypeInfoFactory.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/TypeInfoFactory.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/TypeInfoFactory.java (original)
+++ hive/branches/llap/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/TypeInfoFactory.java Sat Mar 28 00:22:15 2015
@@ -59,6 +59,8 @@ public final class TypeInfoFactory {
   public static final PrimitiveTypeInfo shortTypeInfo = new PrimitiveTypeInfo(serdeConstants.SMALLINT_TYPE_NAME);
   public static final PrimitiveTypeInfo dateTypeInfo = new PrimitiveTypeInfo(serdeConstants.DATE_TYPE_NAME);
   public static final PrimitiveTypeInfo timestampTypeInfo = new PrimitiveTypeInfo(serdeConstants.TIMESTAMP_TYPE_NAME);
+  public static final PrimitiveTypeInfo intervalYearMonthTypeInfo = new PrimitiveTypeInfo(serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME);
+  public static final PrimitiveTypeInfo intervalDayTimeTypeInfo = new PrimitiveTypeInfo(serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME);
   public static final PrimitiveTypeInfo binaryTypeInfo = new PrimitiveTypeInfo(serdeConstants.BINARY_TYPE_NAME);
 
   /**
@@ -87,6 +89,8 @@ public final class TypeInfoFactory {
     cachedPrimitiveTypeInfo.put(serdeConstants.SMALLINT_TYPE_NAME, shortTypeInfo);
     cachedPrimitiveTypeInfo.put(serdeConstants.DATE_TYPE_NAME, dateTypeInfo);
     cachedPrimitiveTypeInfo.put(serdeConstants.TIMESTAMP_TYPE_NAME, timestampTypeInfo);
+    cachedPrimitiveTypeInfo.put(serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME, intervalYearMonthTypeInfo);
+    cachedPrimitiveTypeInfo.put(serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME, intervalDayTimeTypeInfo);
     cachedPrimitiveTypeInfo.put(serdeConstants.BINARY_TYPE_NAME, binaryTypeInfo);
     cachedPrimitiveTypeInfo.put(decimalTypeInfo.getQualifiedName(), decimalTypeInfo);
     cachedPrimitiveTypeInfo.put("unknown", unknownTypeInfo);

Added: hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalDayTimeWritable.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalDayTimeWritable.java?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalDayTimeWritable.java (added)
+++ hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalDayTimeWritable.java Sat Mar 28 00:22:15 2015
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+
+import com.google.code.tempusfugit.concurrency.annotations.*;
+import com.google.code.tempusfugit.concurrency.*;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.junit.*;
+
+import static org.junit.Assert.*;
+
+public class TestHiveIntervalDayTimeWritable {
+  @Rule public ConcurrentRule concurrentRule = new ConcurrentRule();
+  @Rule public RepeatingRule repeatingRule = new RepeatingRule();
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testConstructor() throws Exception {
+    HiveIntervalDayTime hi1 = HiveIntervalDayTime.valueOf("3 4:5:6.12345");
+    HiveIntervalDayTimeWritable hiw1 = new HiveIntervalDayTimeWritable(hi1);
+    HiveIntervalDayTimeWritable hiw2 = new HiveIntervalDayTimeWritable(hiw1);
+    assertEquals(hiw1, hiw2);
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testComparison() throws Exception {
+    HiveIntervalDayTimeWritable hiw0 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:2.22222"));
+    HiveIntervalDayTimeWritable hiw1 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:2.22222"));
+    HiveIntervalDayTimeWritable hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("3 2:2:2.22222"));
+
+    assertTrue(hiw1 + " equals " + hiw1, hiw1.equals(hiw1));
+    assertTrue(hiw1 + " equals " + hiw0, hiw1.equals(hiw0));
+    assertFalse(hiw1 + " equals " + hiw2, hiw1.equals(hiw2));
+
+    assertTrue(hiw1 + " compare " + hiw1, 0 ==  hiw1.compareTo(hiw1));
+    assertTrue(hiw1 + " compare " + hiw0, 0 ==  hiw1.compareTo(hiw0));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("3 2:2:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("1 2:2:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 3:2:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 1:2:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:3:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:1:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:3.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:1.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:2.33333"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:2.11111"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    // Also check hashCode()
+    assertEquals(hiw0.hashCode(), hiw1.hashCode());
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testGettersSetters() throws Exception {
+    HiveIntervalDayTimeWritable hiw1 = new HiveIntervalDayTimeWritable();
+
+    hiw1.set(3, 4, 5, 6, 7);
+
+    HiveIntervalDayTime hi1 = hiw1.getHiveIntervalDayTime();
+    assertEquals(3, hi1.getDays());
+    assertEquals(4, hi1.getHours());
+    assertEquals(5, hi1.getMinutes());
+    assertEquals(6, hi1.getSeconds());
+    assertEquals(7, hi1.getNanos());
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testWritableMethods() throws Exception {
+    HiveIntervalDayTimeWritable hiw1 = new HiveIntervalDayTimeWritable();
+    HiveIntervalDayTimeWritable hiw2 = new HiveIntervalDayTimeWritable();
+
+    hiw1.set(3, 4, 5, 6, 7);
+    hiw2.set(5, 4, 3, 2, 1);
+    assertFalse(hiw1.equals(hiw2));
+
+    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+    DataOutput out = new DataOutputStream(byteStream);
+
+    hiw1.write(out);
+    hiw2.readFields(new DataInputStream(new ByteArrayInputStream(byteStream.toByteArray())));
+    assertEquals(hiw1, hiw2);
+  }
+}

Added: hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalYearMonthWritable.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalYearMonthWritable.java?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalYearMonthWritable.java (added)
+++ hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalYearMonthWritable.java Sat Mar 28 00:22:15 2015
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+
+import com.google.code.tempusfugit.concurrency.annotations.*;
+import com.google.code.tempusfugit.concurrency.*;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.junit.*;
+
+import static org.junit.Assert.*;
+
+public class TestHiveIntervalYearMonthWritable {
+  @Rule public ConcurrentRule concurrentRule = new ConcurrentRule();
+  @Rule public RepeatingRule repeatingRule = new RepeatingRule();
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testConstructor() throws Exception {
+    HiveIntervalYearMonth hi1 = HiveIntervalYearMonth.valueOf("1-2");
+    HiveIntervalYearMonthWritable hiw1 = new HiveIntervalYearMonthWritable(hi1);
+    HiveIntervalYearMonthWritable hiw2 = new HiveIntervalYearMonthWritable(hiw1);
+    assertEquals(hiw1, hiw2);
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testComparison() throws Exception {
+    HiveIntervalYearMonthWritable hiw0 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("2-2"));
+    HiveIntervalYearMonthWritable hiw1 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("2-2"));
+    HiveIntervalYearMonthWritable hiw2 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("3-2"));
+
+    assertTrue(hiw1 + " equals " + hiw1, hiw1.equals(hiw1));
+    assertTrue(hiw1 + " equals " + hiw0, hiw1.equals(hiw0));
+    assertFalse(hiw1 + " equals " + hiw2, hiw1.equals(hiw2));
+
+    assertTrue(hiw1 + " compare " + hiw1, 0 ==  hiw1.compareTo(hiw1));
+    assertTrue(hiw1 + " compare " + hiw0, 0 ==  hiw1.compareTo(hiw0));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("1-2"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("2-3"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("2-1"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    // Also check hashCode()
+    assertEquals(hiw0.hashCode(), hiw1.hashCode());
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testGettersSetters() throws Exception {
+    HiveIntervalYearMonthWritable hiw1 = new HiveIntervalYearMonthWritable();
+
+    hiw1.set(1, 2);
+    HiveIntervalYearMonth hi1 = hiw1.getHiveIntervalYearMonth();
+    assertEquals(1, hi1.getYears());
+    assertEquals(2, hi1.getMonths());
+
+    hiw1.set(new HiveIntervalYearMonth(3,4));
+    hi1 = hiw1.getHiveIntervalYearMonth();
+    assertEquals(3, hi1.getYears());
+    assertEquals(4, hi1.getMonths());
+
+    hiw1.set(new HiveIntervalYearMonthWritable(new HiveIntervalYearMonth(5,6)));
+    hi1 = hiw1.getHiveIntervalYearMonth();
+    assertEquals(5, hi1.getYears());
+    assertEquals(6, hi1.getMonths());
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testWritableMethods() throws Exception {
+    HiveIntervalYearMonthWritable hiw1 = new HiveIntervalYearMonthWritable();
+    HiveIntervalYearMonthWritable hiw2 = new HiveIntervalYearMonthWritable();
+
+    hiw1.set(1, 2);
+    hiw2.set(7, 6);
+    assertFalse(hiw1.equals(hiw2));
+
+    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+    DataOutput out = new DataOutputStream(byteStream);
+
+    hiw1.write(out);
+    hiw2.readFields(new DataInputStream(new ByteArrayInputStream(byteStream.toByteArray())));
+    assertEquals(hiw1, hiw2);
+  }
+}

Modified: hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/primitive/TestPrimitiveObjectInspectorUtils.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/primitive/TestPrimitiveObjectInspectorUtils.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/primitive/TestPrimitiveObjectInspectorUtils.java (original)
+++ hive/branches/llap/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/primitive/TestPrimitiveObjectInspectorUtils.java Sat Mar 28 00:22:15 2015
@@ -18,13 +18,25 @@
 
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+import org.apache.hadoop.hive.common.type.HiveChar;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
+import org.apache.hadoop.hive.common.type.HiveVarchar;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveGrouping;
+import org.junit.Test;
 
 import junit.framework.TestCase;
 
 public class TestPrimitiveObjectInspectorUtils extends TestCase {
 
+  @Test
   public void testGetPrimitiveGrouping() {
     assertEquals(PrimitiveGrouping.NUMERIC_GROUP,
         PrimitiveObjectInspectorUtils.getPrimitiveGrouping(PrimitiveCategory.BYTE));
@@ -60,4 +72,76 @@ public class TestPrimitiveObjectInspecto
     assertEquals(PrimitiveGrouping.VOID_GROUP,
         PrimitiveObjectInspectorUtils.getPrimitiveGrouping(PrimitiveCategory.VOID));
   }
+  
+  @Test
+  public void testgetTimestamp() {
+    DateFormat localDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+    DateFormat gmtDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+    gmtDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+    PrimitiveObjectInspector voidOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.VOID);
+    assertEquals(null, PrimitiveObjectInspectorUtils.getTimestamp(new Object(), voidOI));
+
+    PrimitiveObjectInspector booleanOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.BOOLEAN);
+    assertEquals("1970-01-01 00:00:01.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(true, booleanOI)));
+    assertEquals("1970-01-01 00:00:00.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(false, booleanOI)));
+
+    PrimitiveObjectInspector byteOI = PrimitiveObjectInspectorFactory
+      .getPrimitiveJavaObjectInspector(PrimitiveCategory.BYTE);
+    assertEquals("1970-01-01 00:00:01.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp((byte)1, byteOI)));
+    assertEquals("1969-12-31 23:59:59.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp((byte)-1, byteOI)));
+
+    PrimitiveObjectInspector shortOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.SHORT);
+    assertEquals("1970-01-01 00:00:01.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp((short)1, shortOI)));
+    assertEquals("1969-12-31 23:59:59.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp((short)-1, shortOI)));
+
+    PrimitiveObjectInspector intOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.INT);
+    assertEquals("2015-02-07 15:01:22.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp((int)1423321282, intOI)));
+    assertEquals("1969-12-31 23:59:59.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp((int)-1, intOI)));
+
+    PrimitiveObjectInspector longOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.LONG);
+    assertEquals("2015-02-07 15:01:22.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(1423321282L, longOI)));
+    assertEquals("1969-12-31 23:59:59.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(-1L, longOI)));
+
+      // Float loses some precisions
+    PrimitiveObjectInspector floatOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.FLOAT);
+    assertEquals("2015-02-07 15:02:24.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(1423321282.123f, floatOI)));
+    assertEquals("1969-12-31 23:59:58.876", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(-1.123f, floatOI)));
+
+    PrimitiveObjectInspector doubleOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.DOUBLE);
+    assertEquals("2015-02-07 15:01:22.123", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp((double)1423321282.123, doubleOI)));
+    assertEquals("1969-12-31 23:59:58.877", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp((double)-1.123, doubleOI)));
+
+    PrimitiveObjectInspector decimalOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.DECIMAL);
+    assertEquals("2015-02-07 15:01:22.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(HiveDecimal.create(1423321282L), decimalOI)));
+    assertEquals("1969-12-31 23:59:59.000", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(HiveDecimal.create(-1), decimalOI)));
+
+    PrimitiveObjectInspector stringOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.STRING);
+    assertEquals("2015-02-07 15:01:22.123", localDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp("2015-02-07 15:01:22.123", stringOI)));
+
+    PrimitiveObjectInspector charOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.CHAR);
+    assertEquals("2015-02-07 15:01:22.123", localDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(new HiveChar("2015-02-07 15:01:22.123", 30), charOI)));
+
+    PrimitiveObjectInspector varcharOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.VARCHAR);
+    assertEquals("2015-02-07 15:01:22.123", localDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(new HiveVarchar("2015-02-07 15:01:22.123",30), varcharOI)));
+
+    PrimitiveObjectInspector dateOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.DATE);
+    assertEquals("2015-02-07 00:00:00.000", localDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(new Date(1423321282123L), dateOI)));
+
+    PrimitiveObjectInspector timestampOI = PrimitiveObjectInspectorFactory
+        .getPrimitiveJavaObjectInspector(PrimitiveCategory.TIMESTAMP);
+    assertEquals("2015-02-07 15:01:22.123", gmtDateFormat.format(PrimitiveObjectInspectorUtils.getTimestamp(new Timestamp(1423321282123L), timestampOI)));
+  }
 }

Modified: hive/branches/llap/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java (original)
+++ hive/branches/llap/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java Sat Mar 28 00:22:15 2015
@@ -382,11 +382,10 @@ public class HiveSessionImpl implements
       opHandleSet.add(opHandle);
       return opHandle;
     } catch (HiveSQLException e) {
-      // Cleanup opHandle in case the query is synchronous
-      // Async query needs to retain and pass back the opHandle for error reporting
-      if (!runAsync) {
-        operationManager.closeOperation(opHandle);
-      }
+      // Refering to SQLOperation.java,there is no chance that a HiveSQLException throws and the asyn
+      // background operation submits to thread pool successfully at the same time. So, Cleanup
+      // opHandle directly when got HiveSQLException
+      operationManager.closeOperation(opHandle);
       throw e;
     } finally {
       release(true);

Modified: hive/branches/llap/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java (original)
+++ hive/branches/llap/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java Sat Mar 28 00:22:15 2015
@@ -40,7 +40,6 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.crypto.key.KeyProvider;
 import org.apache.hadoop.crypto.key.KeyProvider.Options;
 import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension;
-import org.apache.hadoop.crypto.key.KeyProviderFactory;
 import org.apache.hadoop.fs.BlockLocation;
 import org.apache.hadoop.fs.DefaultFileAccess;
 import org.apache.hadoop.fs.FSDataInputStream;
@@ -1206,6 +1205,25 @@ public class Hadoop23Shims extends Hadoo
     return (0 == rc);
   }
 
+  private static Boolean hdfsEncryptionSupport;
+
+  public static boolean isHdfsEncryptionSupported() {
+    if (hdfsEncryptionSupport == null) {
+      Method m = null;
+
+      try {
+        m = HdfsAdmin.class.getMethod("getEncryptionZoneForPath", Path.class);
+      } catch (NoSuchMethodException e) {
+        // This version of Hadoop does not support HdfsAdmin.getEncryptionZoneForPath().
+        // Hadoop 2.6.0 introduces this new method.
+      }
+
+      hdfsEncryptionSupport = (m != null);
+    }
+
+    return hdfsEncryptionSupport;
+  }
+
   public class HdfsEncryptionShim implements HadoopShims.HdfsEncryptionShim {
     private final String HDFS_SECURITY_DEFAULT_CIPHER = "AES/CTR/NoPadding";
 
@@ -1350,15 +1368,13 @@ public class Hadoop23Shims extends Hadoo
 
   @Override
   public HadoopShims.HdfsEncryptionShim createHdfsEncryptionShim(FileSystem fs, Configuration conf) throws IOException {
-    URI uri = fs.getUri();
-    if ("hdfs".equals(uri.getScheme())) {
-      try {
+    if (isHdfsEncryptionSupported()) {
+      URI uri = fs.getUri();
+      if ("hdfs".equals(uri.getScheme())) {
         return new HdfsEncryptionShim(uri, conf);
-      } catch (NoSuchMethodError e) {
-        // ignore error as encryption is not supported.
-        // let this method return the unsupported encryption shim instead
       }
     }
+
     return new HadoopShims.NoopHdfsEncryptionShim();
   }
 

Modified: hive/branches/llap/testutils/metastore/metastore-upgrade-test.sh
URL: http://svn.apache.org/viewvc/hive/branches/llap/testutils/metastore/metastore-upgrade-test.sh?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/testutils/metastore/metastore-upgrade-test.sh (original)
+++ hive/branches/llap/testutils/metastore/metastore-upgrade-test.sh Sat Mar 28 00:22:15 2015
@@ -94,6 +94,7 @@ log "Server prepared."
 #
 
 execute_test() {
+	log "Executing sql test: $DB_SERVER/$(basename $1)"
 	if ! bash -x -e $SCRIPT_EXECUTE $1; then
 		log "Test failed: $DB_SERVER/$(basename $1)"
 		return 1