From 61489fceda5d1159e23bf62111cd1bc267694c90 Mon Sep 17 00:00:00 2001 From: Ben Watson Date: Wed, 5 May 2021 07:15:35 +0100 Subject: [PATCH] Updating logical date millis logic (#71) --- .../intellij/viewer/fileformat/ParquetFileReader.java | 2 +- .../intellij/viewer/fileformat/ParquetFileReaderTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/co/hadoopathome/intellij/viewer/fileformat/ParquetFileReader.java b/src/main/java/uk/co/hadoopathome/intellij/viewer/fileformat/ParquetFileReader.java index 13647c4..41bf3ae 100644 --- a/src/main/java/uk/co/hadoopathome/intellij/viewer/fileformat/ParquetFileReader.java +++ b/src/main/java/uk/co/hadoopathome/intellij/viewer/fileformat/ParquetFileReader.java @@ -111,7 +111,7 @@ public String getLogicalTypeName() { } public String fromLong(Long millisFromEpoch, Schema schema, LogicalType type) { - return Instant.ofEpochSecond(millisFromEpoch).toString(); + return Instant.ofEpochMilli(millisFromEpoch).toString(); } public Long toLong(String timestamp, Schema schema, LogicalType type) { diff --git a/src/test/java/uk/co/hadoopathome/intellij/viewer/fileformat/ParquetFileReaderTest.java b/src/test/java/uk/co/hadoopathome/intellij/viewer/fileformat/ParquetFileReaderTest.java index 5ca928e..d28e0dc 100644 --- a/src/test/java/uk/co/hadoopathome/intellij/viewer/fileformat/ParquetFileReaderTest.java +++ b/src/test/java/uk/co/hadoopathome/intellij/viewer/fileformat/ParquetFileReaderTest.java @@ -76,7 +76,7 @@ public void testDateLogicalType() throws IOException { assertThat(records).hasSize(5); String firstRecord = records.get(0); assertThat(firstRecord) - .contains("{\"received_at\": \"2020-08-27T19:41:44Z\", \"name___string\": \"Tressa\""); + .contains("{\"received_at\": \"1970-01-19T12:02:37.304Z\", \"name___string\": \"Tressa\""); } private List readRecords(String fileName, int numRecords) throws IOException {