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 2018/03/26 20:28:41 UTC
orc git commit: ORC-327. Fix java unit test cases to pass when
-Duser.timezone is set.
Repository: orc
Updated Branches:
refs/heads/master c1348d069 -> a5e564f39
ORC-327. Fix java unit test cases to pass when -Duser.timezone is set.
Fixes #246
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/a5e564f3
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/a5e564f3
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/a5e564f3
Branch: refs/heads/master
Commit: a5e564f390f0fa37651c2dc333b7eef215a49e50
Parents: c1348d0
Author: Owen O'Malley <om...@apache.org>
Authored: Mon Mar 26 11:32:48 2018 -0700
Committer: Owen O'Malley <om...@apache.org>
Committed: Mon Mar 26 13:28:02 2018 -0700
----------------------------------------------------------------------
.../test/org/apache/orc/TestColumnStatistics.java | 16 ++++++++--------
.../apache/orc/impl/TestColumnStatisticsImpl.java | 4 ++++
.../src/test/org/apache/orc/tools/TestFileDump.java | 13 +++++++++----
3 files changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/orc/blob/a5e564f3/java/core/src/test/org/apache/orc/TestColumnStatistics.java
----------------------------------------------------------------------
diff --git a/java/core/src/test/org/apache/orc/TestColumnStatistics.java b/java/core/src/test/org/apache/orc/TestColumnStatistics.java
index fd87b4c..bbc85ea 100644
--- a/java/core/src/test/org/apache/orc/TestColumnStatistics.java
+++ b/java/core/src/test/org/apache/orc/TestColumnStatistics.java
@@ -169,9 +169,8 @@ public class TestColumnStatistics {
}
private static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
- private final SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT);
- private Timestamp parseTime(String value) {
+ private static Timestamp parseTime(SimpleDateFormat format, String value) {
try {
return new Timestamp(format.parse(value).getTime());
} catch (ParseException e) {
@@ -185,13 +184,14 @@ public class TestColumnStatistics {
TimeZone original = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
+ SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT);
ColumnStatisticsImpl stats1 = ColumnStatisticsImpl.create(schema);
ColumnStatisticsImpl stats2 = ColumnStatisticsImpl.create(schema);
- stats1.updateTimestamp(parseTime("2000-04-02 03:30:00"));
- stats1.updateTimestamp(parseTime("2000-04-02 01:30:00"));
+ stats1.updateTimestamp(parseTime(format, "2000-04-02 03:30:00"));
+ stats1.updateTimestamp(parseTime(format, "2000-04-02 01:30:00"));
stats1.increment(2);
- stats2.updateTimestamp(parseTime("2000-10-29 01:30:00"));
- stats2.updateTimestamp(parseTime("2000-10-29 03:30:00"));
+ stats2.updateTimestamp(parseTime(format, "2000-10-29 01:30:00"));
+ stats2.updateTimestamp(parseTime(format, "2000-10-29 03:30:00"));
stats2.increment(2);
TimestampColumnStatistics typed = (TimestampColumnStatistics) stats1;
assertEquals("2000-04-02 01:30:00.0", typed.getMinimum().toString());
@@ -200,8 +200,8 @@ public class TestColumnStatistics {
assertEquals("2000-04-02 01:30:00.0", typed.getMinimum().toString());
assertEquals("2000-10-29 03:30:00.0", typed.getMaximum().toString());
stats1.reset();
- stats1.updateTimestamp(parseTime("1999-04-04 00:00:00"));
- stats1.updateTimestamp(parseTime("2009-03-08 12:00:00"));
+ stats1.updateTimestamp(parseTime(format, "1999-04-04 00:00:00"));
+ stats1.updateTimestamp(parseTime(format, "2009-03-08 12:00:00"));
stats1.merge(stats2);
assertEquals("1999-04-04 00:00:00.0", typed.getMinimum().toString());
assertEquals("2009-03-08 12:00:00.0", typed.getMaximum().toString());
http://git-wip-us.apache.org/repos/asf/orc/blob/a5e564f3/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 6528e75..e53cdda 100644
--- a/java/core/src/test/org/apache/orc/impl/TestColumnStatisticsImpl.java
+++ b/java/core/src/test/org/apache/orc/impl/TestColumnStatisticsImpl.java
@@ -30,6 +30,7 @@ import org.apache.orc.TypeDescription;
import org.junit.Test;
import java.io.IOException;
+import java.util.TimeZone;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -72,6 +73,8 @@ public class TestColumnStatisticsImpl {
@Test
public void testOldTimestamps() throws IOException {
+ TimeZone original = TimeZone.getDefault();
+ TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
Path exampleDir = new Path(System.getProperty("example.dir"));
Path file = new Path(exampleDir, "TestOrcFile.testTimestamp.orc");
Configuration conf = new Configuration();
@@ -80,5 +83,6 @@ public class TestColumnStatisticsImpl {
(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());
+ TimeZone.setDefault(original);
}
}
http://git-wip-us.apache.org/repos/asf/orc/blob/a5e564f3/java/tools/src/test/org/apache/orc/tools/TestFileDump.java
----------------------------------------------------------------------
diff --git a/java/tools/src/test/org/apache/orc/tools/TestFileDump.java b/java/tools/src/test/org/apache/orc/tools/TestFileDump.java
index d69d080..9e21fad 100644
--- a/java/tools/src/test/org/apache/orc/tools/TestFileDump.java
+++ b/java/tools/src/test/org/apache/orc/tools/TestFileDump.java
@@ -31,11 +31,13 @@ import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.TimeZone;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -262,6 +264,7 @@ public class TestFileDump {
@Test
public void testDataDump() throws Exception {
TypeDescription schema = getAllTypesType();
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Writer writer = OrcFile.createWriter(testFilePath,
OrcFile.writerOptions(conf)
.fileSystem(fs)
@@ -282,8 +285,9 @@ public class TestFileDump {
4.0f,
20.0,
new HiveDecimalWritable("4.2222"),
- new Timestamp(1416967764000L),
- new DateWritable(new Date(1416967764000L)),
+ new Timestamp(format.parse("2014-11-25 18:09:24").getTime()),
+ new DateWritable(DateWritable.millisToDays(
+ format.parse("2014-11-25 00:00:00").getTime())),
"string",
"hello",
"hello",
@@ -302,8 +306,9 @@ public class TestFileDump {
8.0f,
40.0,
new HiveDecimalWritable("2.2222"),
- new Timestamp(1416967364000L),
- new DateWritable(new Date(1411967764000L)),
+ new Timestamp(format.parse("2014-11-25 18:02:44").getTime()),
+ new DateWritable(DateWritable.millisToDays(
+ format.parse("2014-09-28 00:00:00").getTime())),
"abcd",
"world",
"world",