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 2019/10/09 19:42:12 UTC

[orc] branch branch-1.5 updated: ORC-528: Add unittest for timestamp off-by-one issues

This is an automated email from the ASF dual-hosted git repository.

omalley pushed a commit to branch branch-1.5
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-1.5 by this push:
     new a1ef707  ORC-528: Add unittest for timestamp off-by-one issues
a1ef707 is described below

commit a1ef707783a0b44111a2a09477862cf88e2994ba
Author: Yukihiro Okada <ca...@gmail.com>
AuthorDate: Thu Oct 10 01:43:57 2019 +0900

    ORC-528: Add unittest for timestamp off-by-one issues
    
    Fixes #434
    
    Signed-off-by: Owen O'Malley <om...@apache.org>
---
 .../apache/orc/tools/convert/TestJsonReader.java   | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/java/tools/src/test/org/apache/orc/tools/convert/TestJsonReader.java b/java/tools/src/test/org/apache/orc/tools/convert/TestJsonReader.java
index 02fc4dc..f839513 100644
--- a/java/tools/src/test/org/apache/orc/tools/convert/TestJsonReader.java
+++ b/java/tools/src/test/org/apache/orc/tools/convert/TestJsonReader.java
@@ -45,4 +45,31 @@ public class TestJsonReader {
         assertEquals("2018-03-21 12:23:34.123456", cv.asScratchTimestamp(0).toString());
         assertEquals("2018-02-03 18:04:51.456789", cv.asScratchTimestamp(1).toString());
     }
+
+    @Test
+    public void testTimestampOffByOne() throws Exception {
+        String tsFormat = "yyyy-MM-dd HH:mm:ss.SSSS";
+
+        String s = "{\"a\": \"1970-01-01 00:00:00.0001\"}\n" +
+                "{\"a\": \"1970-01-01 00:00:00.0000\"}\n" +
+                "{\"a\": \"1969-12-31 23:59:59.9999\"}\n" +
+                "{\"a\": \"1969-12-31 23:59:59.0001\"}\n" +
+                "{\"a\": \"1969-12-31 23:59:59.0000\"}\n" +
+                "{\"a\": \"1969-12-31 23:59:58.9999\"}";
+        StringReader input = new StringReader(s);
+        TypeDescription schema = TypeDescription.fromString(
+                "struct<a:timestamp>");
+        JsonReader reader = new JsonReader(input, null, 1, schema, tsFormat);
+        VectorizedRowBatch batch = schema.createRowBatch(6);
+        assertEquals(true, reader.nextBatch(batch));
+        assertEquals(6, batch.size);
+        TimestampColumnVector cv = (TimestampColumnVector) batch.cols[0];
+        assertEquals("1970-01-01 00:00:00.0001", cv.asScratchTimestamp(0).toString());
+        assertEquals("1970-01-01 00:00:00.0", cv.asScratchTimestamp(1).toString());
+        assertEquals("1969-12-31 23:59:59.9999", cv.asScratchTimestamp(2).toString());
+        assertEquals("1969-12-31 23:59:59.0001", cv.asScratchTimestamp(3).toString());
+        assertEquals("1969-12-31 23:59:59.0", cv.asScratchTimestamp(4).toString());
+        assertEquals("1969-12-31 23:59:58.9999", cv.asScratchTimestamp(5).toString());
+    }
+
 }