You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2017/02/08 02:51:42 UTC

orc git commit: ORC-142. Fix TimestampColumnStatistics when reading from old files (pre ORC-135).

Repository: orc
Updated Branches:
  refs/heads/master e5237a3ec -> 27cacb599


ORC-142. Fix TimestampColumnStatistics when reading from old
files (pre ORC-135).

Fixes #91

Signed-off-by: Owen O'Malley <om...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/27cacb59
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/27cacb59
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/27cacb59

Branch: refs/heads/master
Commit: 27cacb59963396ce440de20c972e269aae213562
Parents: e5237a3
Author: Owen O'Malley <om...@apache.org>
Authored: Tue Feb 7 17:47:47 2017 -0800
Committer: Owen O'Malley <om...@apache.org>
Committed: Tue Feb 7 18:51:19 2017 -0800

----------------------------------------------------------------------
 .../apache/orc/impl/ColumnStatisticsImpl.java   |  2 +-
 .../orc/impl/TestColumnStatisticsImpl.java      | 20 ++++++++++++++++++++
 java/pom.xml                                    |  2 ++
 3 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/27cacb59/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java
----------------------------------------------------------------------
diff --git a/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java b/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java
index f1ed646..ec874d6 100644
--- a/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java
+++ b/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java
@@ -1123,7 +1123,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
             timestampStats.getMaximum());
       }
       if (timestampStats.hasMinimum()) {
-        maximum = SerializationUtils.convertToUtc(TimeZone.getDefault(),
+        minimum = SerializationUtils.convertToUtc(TimeZone.getDefault(),
             timestampStats.getMinimum());
       }
       if (timestampStats.hasMaximumUtc()) {

http://git-wip-us.apache.org/repos/asf/orc/blob/27cacb59/java/core/src/test/org/apache/orc/impl/TestColumnStatisticsImpl.java
----------------------------------------------------------------------
diff --git a/java/core/src/test/org/apache/orc/impl/TestColumnStatisticsImpl.java b/java/core/src/test/org/apache/orc/impl/TestColumnStatisticsImpl.java
index 6165526..6528e75 100644
--- a/java/core/src/test/org/apache/orc/impl/TestColumnStatisticsImpl.java
+++ b/java/core/src/test/org/apache/orc/impl/TestColumnStatisticsImpl.java
@@ -18,11 +18,19 @@
 
 package org.apache.orc.impl;
 
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.orc.ColumnStatistics;
+import org.apache.orc.OrcFile;
 import org.apache.orc.OrcProto;
+import org.apache.orc.Reader;
+import org.apache.orc.TimestampColumnStatistics;
 import org.apache.orc.TypeDescription;
 import org.junit.Test;
 
+import java.io.IOException;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -61,4 +69,16 @@ public class TestColumnStatisticsImpl {
     assertTrue(protoStat.hasMaximum());
     assertEquals(maximum, protoStat.getMaximum());
   }
+
+  @Test
+  public void testOldTimestamps() throws IOException {
+    Path exampleDir = new Path(System.getProperty("example.dir"));
+    Path file = new Path(exampleDir, "TestOrcFile.testTimestamp.orc");
+    Configuration conf = new Configuration();
+    Reader reader = OrcFile.createReader(file, OrcFile.readerOptions(conf));
+    TimestampColumnStatistics stats =
+        (TimestampColumnStatistics) reader.getStatistics()[0];
+    assertEquals("1995-01-01 00:00:00.688", stats.getMinimum().toString());
+    assertEquals("2037-01-01 00:00:00.0", stats.getMaximum().toString());
+  }
 }

http://git-wip-us.apache.org/repos/asf/orc/blob/27cacb59/java/pom.xml
----------------------------------------------------------------------
diff --git a/java/pom.xml b/java/pom.xml
index 2fd3008..98b1fb5 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -67,6 +67,7 @@
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <maven.compiler.useIncrementalCompilation>false</maven.compiler.useIncrementalCompilation>
     <test.tmp.dir>${project.build.directory}/testing-tmp</test.tmp.dir>
+    <example.dir>${project.basedir}/../../examples</example.dir>
 
     <hadoop.version>2.6.4</hadoop.version>
     <storage-api.version>2.2.0</storage-api.version>
@@ -137,6 +138,7 @@
           <failIfNoTests>false</failIfNoTests>
           <systemPropertyVariables>
             <test.tmp.dir>${test.tmp.dir}</test.tmp.dir>
+            <example.dir>${example.dir}</example.dir>
           </systemPropertyVariables>
         </configuration>
       </plugin>