hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gunt...@apache.org
Subject svn commit: r1634975 - in /hive/branches/branch-0.14/common/src: java/org/apache/hadoop/hive/conf/HiveConf.java test/org/apache/hadoop/hive/conf/TestHiveConf.java
Date Tue, 28 Oct 2014 20:42:55 GMT
Author: gunther
Date: Tue Oct 28 20:42:55 2014
New Revision: 1634975

URL: http://svn.apache.org/r1634975
Log:
HIVE-8605: HIVE-5799 breaks backward compatibility for time values in config (Alan Gates via
Gunther Hagleitner)

Modified:
    hive/branches/branch-0.14/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
    hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java

Modified: hive/branches/branch-0.14/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1634975&r1=1634974&r2=1634975&view=diff
==============================================================================
--- hive/branches/branch-0.14/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hive/branches/branch-0.14/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Tue
Oct 28 20:42:55 2014
@@ -2119,7 +2119,7 @@ public class HiveConf extends Configurat
 
   public static TimeUnit unitFor(String unit, TimeUnit defaultUnit) {
     unit = unit.trim().toLowerCase();
-    if (unit.isEmpty()) {
+    if (unit.isEmpty() || unit.equals("l")) {
       if (defaultUnit == null) {
         throw new IllegalArgumentException("Time unit is not specified");
       }

Modified: hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java?rev=1634975&r1=1634974&r2=1634975&view=diff
==============================================================================
--- hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java
(original)
+++ hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java
Tue Oct 28 20:42:55 2014
@@ -24,6 +24,8 @@ import org.apache.hive.common.util.HiveT
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.concurrent.TimeUnit;
+
 
 /**
  * TestHiveConf
@@ -95,4 +97,24 @@ public class TestHiveConf {
       Assert.assertTrue(i == HiveConf.getPositionFromInternalName(HiveConf.getColumnInternalName(i)));
     }
   }
+
+  @Test
+  public void testUnitFor() throws Exception {
+    Assert.assertEquals(TimeUnit.SECONDS, HiveConf.unitFor("L", TimeUnit.SECONDS));
+    Assert.assertEquals(TimeUnit.MICROSECONDS, HiveConf.unitFor("", TimeUnit.MICROSECONDS));
+    Assert.assertEquals(TimeUnit.DAYS, HiveConf.unitFor("d", null));
+    Assert.assertEquals(TimeUnit.DAYS, HiveConf.unitFor("days", null));
+    Assert.assertEquals(TimeUnit.HOURS, HiveConf.unitFor("h", null));
+    Assert.assertEquals(TimeUnit.HOURS, HiveConf.unitFor("hours", null));
+    Assert.assertEquals(TimeUnit.MINUTES, HiveConf.unitFor("m", null));
+    Assert.assertEquals(TimeUnit.MINUTES, HiveConf.unitFor("minutes", null));
+    Assert.assertEquals(TimeUnit.SECONDS, HiveConf.unitFor("s", null));
+    Assert.assertEquals(TimeUnit.SECONDS, HiveConf.unitFor("seconds", null));
+    Assert.assertEquals(TimeUnit.MILLISECONDS, HiveConf.unitFor("ms", null));
+    Assert.assertEquals(TimeUnit.MILLISECONDS, HiveConf.unitFor("msecs", null));
+    Assert.assertEquals(TimeUnit.MICROSECONDS, HiveConf.unitFor("us", null));
+    Assert.assertEquals(TimeUnit.MICROSECONDS, HiveConf.unitFor("useconds", null));
+    Assert.assertEquals(TimeUnit.NANOSECONDS, HiveConf.unitFor("ns", null));
+    Assert.assertEquals(TimeUnit.NANOSECONDS, HiveConf.unitFor("nsecs", null));
+  }
 }



Mime
View raw message