Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 6243c3e05 -> ad462863d
PHOENIX-1769 Exception thrown when TO_DATE function used as LHS in WHERE-clause Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ad462863 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ad462863 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ad462863 Branch: refs/heads/4.x-HBase-0.98 Commit: ad462863dc88f4d1dae77f3c655aa7fe437b25ef Parents: 6243c3e Author: Thomas D'Silva <[email protected]> Authored: Tue Feb 2 12:26:48 2016 -0800 Committer: Thomas D'Silva <[email protected]> Committed: Tue Feb 2 15:04:52 2016 -0800 ---------------------------------------------------------------------- .../java/org/apache/phoenix/util/DateUtil.java | 2 +- .../org/apache/phoenix/pherf/PherfConstants.java | 2 +- .../apache/phoenix/pherf/rules/RulesApplier.java | 17 ++++++----------- .../apache/phoenix/pherf/RuleGeneratorTest.java | 5 +++-- .../src/test/resources/scenario/test_scenario.xml | 6 +++--- pom.xml | 3 ++- 6 files changed, 16 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/ad462863/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java index 45c3cef..4d7c27c 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java @@ -285,7 +285,7 @@ public class DateUtil { return INSTANCE; } - private final DateTimeFormatter formatter = ISO_DATE_TIME_FORMATTER.withZoneUTC(); + private final DateTimeFormatter formatter = ISO_DATE_TIME_FORMATTER.withZone(DateTimeZone.UTC); private ISODateFormatParser() {} http://git-wip-us.apache.org/repos/asf/phoenix/blob/ad462863/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java index bbae6ea..e7ba056 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java @@ -40,7 +40,7 @@ public class PherfConstants { public static final int DEFAULT_THREAD_POOL_SIZE = 10; public static final int DEFAULT_BATCH_SIZE = 1000; - public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS z"; + public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS"; public static final DateTimeZone DEFAULT_TIME_ZONE = DateTimeZone.UTC; public static final String RESOURCE_SCENARIO = "/scenario"; public static final String http://git-wip-us.apache.org/repos/asf/phoenix/blob/ad462863/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/rules/RulesApplier.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/rules/RulesApplier.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/rules/RulesApplier.java index d270df6..454050b 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/rules/RulesApplier.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/rules/RulesApplier.java @@ -19,6 +19,7 @@ package org.apache.phoenix.pherf.rules; import com.google.common.base.Preconditions; + import org.apache.commons.lang.StringUtils; import org.apache.commons.math3.random.RandomDataGenerator; import org.apache.phoenix.pherf.PherfConstants; @@ -26,6 +27,7 @@ import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.phoenix.pherf.configuration.*; import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.slf4j.Logger; @@ -228,7 +230,7 @@ public class RulesApplier { } public String generateRandomDate(String min, String max) throws Exception { - DateTimeFormatter fmtr = DateTimeFormat.forPattern(PherfConstants.DEFAULT_DATE_PATTERN); + DateTimeFormatter fmtr = DateTimeFormat.forPattern(PherfConstants.DEFAULT_DATE_PATTERN).withZone(DateTimeZone.UTC); DateTime minDt; DateTime maxDt; DateTime dt; @@ -247,7 +249,7 @@ public class RulesApplier { } public String getCurrentDate() { - DateTimeFormatter fmtr = DateTimeFormat.forPattern(PherfConstants.DEFAULT_DATE_PATTERN); + DateTimeFormatter fmtr = DateTimeFormat.forPattern(PherfConstants.DEFAULT_DATE_PATTERN).withZone(DateTimeZone.UTC);; DateTime dt = new DateTime(PherfConstants.DEFAULT_TIME_ZONE); return fmtr.print(dt); } @@ -325,15 +327,8 @@ public class RulesApplier { // Checks if date is in defult pattern public String checkDatePattern(String date) { - DateTimeFormatter fmtr = DateTimeFormat.forPattern(PherfConstants.DEFAULT_DATE_PATTERN); - DateTime parsedDate; - try { - parsedDate = fmtr.parseDateTime(date); - } catch (IllegalArgumentException e) { - /* Trying add default time zone if no time zone appended to date */ - date = date + " " + PherfConstants.DEFAULT_TIME_ZONE.toString(); - parsedDate = fmtr.parseDateTime(date); - } + DateTimeFormatter fmtr = DateTimeFormat.forPattern(PherfConstants.DEFAULT_DATE_PATTERN).withZone(DateTimeZone.UTC);; + DateTime parsedDate = fmtr.parseDateTime(date); return fmtr.print(parsedDate); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/ad462863/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/RuleGeneratorTest.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/RuleGeneratorTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/RuleGeneratorTest.java index b26b2f7..228cd58 100644 --- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/RuleGeneratorTest.java +++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/RuleGeneratorTest.java @@ -41,6 +41,7 @@ import org.apache.phoenix.pherf.rules.DataValue; import org.apache.phoenix.pherf.rules.RulesApplier; import org.apache.phoenix.pherf.workload.WriteWorkload; import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.junit.Ignore; @@ -75,7 +76,7 @@ public class RuleGeneratorTest { } } } - + //Test to check the current date is generated correctly between the timestamps at column level and datavalue level @Test public void testCurrentDateGenerator() throws Exception { @@ -313,7 +314,7 @@ public class RuleGeneratorTest { * @param value */ private void assertDateBetween(DataValue value) { - DateTimeFormatter fmtr = DateTimeFormat.forPattern(PherfConstants.DEFAULT_DATE_PATTERN); + DateTimeFormatter fmtr = DateTimeFormat.forPattern(PherfConstants.DEFAULT_DATE_PATTERN).withZone(DateTimeZone.UTC); DateTime dt = fmtr.parseDateTime(value.getValue()); DateTime min = fmtr.parseDateTime(value.getMinValue()); http://git-wip-us.apache.org/repos/asf/phoenix/blob/ad462863/phoenix-pherf/src/test/resources/scenario/test_scenario.xml ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/test/resources/scenario/test_scenario.xml b/phoenix-pherf/src/test/resources/scenario/test_scenario.xml index 47aa4a5..34bf31a 100644 --- a/phoenix-pherf/src/test/resources/scenario/test_scenario.xml +++ b/phoenix-pherf/src/test/resources/scenario/test_scenario.xml @@ -96,8 +96,8 @@ <value>2019-09-19 00:01:00.000</value> </datavalue> <datavalue distribution="10"> - <minValue>2019-09-22 00:01:00.000 UTC</minValue> - <maxValue>2019-09-22 00:01:00.300 UTC</maxValue> + <minValue>2019-09-22 00:01:00.000</minValue> + <maxValue>2019-09-22 00:01:00.300</maxValue> </datavalue> </valuelist> </column> @@ -280,4 +280,4 @@ </scenario> </scenarios> -</datamodel> \ No newline at end of file +</datamodel> http://git-wip-us.apache.org/repos/asf/phoenix/blob/ad462863/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 2f1af08..6f9f9ca 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,8 @@ <commons-codec.version>1.7</commons-codec.version> <htrace.version>2.04</htrace.version> <collections.version>3.2.1</collections.version> - <jodatime.version>2.7</jodatime.version> + <!-- Do not change jodatime.version until HBASE-15199 is fixed --> + <jodatime.version>1.6</jodatime.version> <joni.version>2.1.2</joni.version> <calcite.version>1.6.0</calcite.version> <jettyVersion>8.1.7.v20120910</jettyVersion>
