orc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject [orc] branch master updated: ORC-528: Add unittest for timestamp off-by-one issues
Date Wed, 09 Oct 2019 19:38:11 GMT
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 7821893db222b9adf41eb6db25bf14d6095d7503
Author: Yukihiro Okada <callistoiv+git@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 <omalley@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());
+    }
+
 }


Mime
View raw message