Repository: incubator-impala
Updated Branches:
refs/heads/master 0bddf0fb6 -> 9ba923948
IMPALA-5983: Fix crash in to/from_utc_timestamp("10:00:00", 'MSK')
Moscow timezone is handled differrently than other timezones,
and it was possible to cause unhandled boost exception by
trying to convert "dateless" timestamps like "10:00:00".
These timestamps cannot be handled by timestamp conversion
generally, because daylight saving time logic needs month
and day to work correctly. The condition HasDateOrTime()
incorrectly suggested that these timestamps can be handled,
so I made the condition stricter.
Change-Id: I592389333a16a15a680beed389e2702dfc16fe1d
Reviewed-on: http://gerrit.cloudera.org:8080/8139
Tested-by: Impala Public Jenkins
Reviewed-by: Lars Volker <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/f2357a22
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/f2357a22
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/f2357a22
Branch: refs/heads/master
Commit: f2357a227e8e95742caebab4e7e6c27cbf4cafeb
Parents: 0bddf0f
Author: Csaba Ringhofer <[email protected]>
Authored: Tue Sep 26 17:37:14 2017 +0200
Committer: Lars Volker <[email protected]>
Committed: Thu Oct 12 16:39:26 2017 +0000
----------------------------------------------------------------------
be/src/exprs/expr-test.cc | 5 +++++
be/src/exprs/timestamp-functions.cc | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/f2357a22/be/src/exprs/expr-test.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/expr-test.cc b/be/src/exprs/expr-test.cc
index a460f5f..c45f4a8 100644
--- a/be/src/exprs/expr-test.cc
+++ b/be/src/exprs/expr-test.cc
@@ -5002,6 +5002,11 @@ TEST_F(ExprTest, MoscowTimezoneConversion) {
TestStringValue(MSC_TO_UTC("2015-06-20 12:00:00"), "2015-06-20 09:00:00");
TestStringValue(MSC_TO_UTC("2015-12-20 12:00:00"), "2015-12-20 09:00:00");
+ // Timestamp conversions of "dateless" times should return null (and not
crash,
+ // see IMPALA-5983).
+ TestIsNull(UTC_TO_MSC("10:00:00"), TYPE_STRING);
+ TestIsNull(MSC_TO_UTC("10:00:00"), TYPE_STRING);
+
#pragma pop_macro("MSC_TO_UTC")
#pragma pop_macro("UTC_TO_MSC")
}
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/f2357a22/be/src/exprs/timestamp-functions.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/timestamp-functions.cc
b/be/src/exprs/timestamp-functions.cc
index 9cb5430..d9372fb 100644
--- a/be/src/exprs/timestamp-functions.cc
+++ b/be/src/exprs/timestamp-functions.cc
@@ -81,7 +81,7 @@ TimestampVal TimestampFunctions::FromUtc(FunctionContext*
context,
const TimestampVal& ts_val, const StringVal& tz_string_val) {
if (ts_val.is_null || tz_string_val.is_null) return TimestampVal::null();
const TimestampValue& ts_value = TimestampValue::FromTimestampVal(ts_val);
- if (!ts_value.HasDateOrTime()) return TimestampVal::null();
+ if (!ts_value.HasDateAndTime()) return TimestampVal::null();
const StringValue& tz_string_value =
StringValue::FromStringVal(tz_string_val);
time_zone_ptr timezone = TimezoneDatabase::FindTimezone(
@@ -119,7 +119,7 @@ TimestampVal TimestampFunctions::ToUtc(FunctionContext*
context,
const TimestampVal& ts_val, const StringVal& tz_string_val) {
if (ts_val.is_null || tz_string_val.is_null) return TimestampVal::null();
const TimestampValue& ts_value = TimestampValue::FromTimestampVal(ts_val);
- if (!ts_value.HasDateOrTime()) return TimestampVal::null();
+ if (!ts_value.HasDateAndTime()) return TimestampVal::null();
const StringValue& tz_string_value =
StringValue::FromStringVal(tz_string_val);
time_zone_ptr timezone = TimezoneDatabase::FindTimezone(