MCPcopy Create free account
hub / github.com/apache/impala / FromUtc

Method FromUtc

be/src/exprs/timestamp-functions.cc:119–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119TimestampVal TimestampFunctions::FromUtc(FunctionContext* context,
120 const TimestampVal& ts_val, const StringVal& tz_string_val) {
121 if (ts_val.is_null || tz_string_val.is_null) return TimestampVal::null();
122 const TimestampValue ts_value = TimestampValue::FromTimestampVal(ts_val);
123 if (UNLIKELY(!ts_value.HasDateAndTime())) return TimestampVal::null();
124
125 const StringValue& tz_string_value = StringValue::FromStringVal(tz_string_val);
126 const Timezone* timezone = GetTimezone(context, tz_string_value);
127 if (UNLIKELY(timezone == nullptr)) return ts_val;
128
129 TimestampValue ts_value_ret = ts_value;
130 ts_value_ret.UtcToLocal(*timezone);
131 if (UNLIKELY(!ts_value_ret.HasDateAndTime())) {
132 const string msg = Substitute(
133 "Timestamp '$0' did not convert to a valid local time in timezone '$1'",
134 ts_value.ToString(), tz_string_value.DebugString());
135 context->AddWarning(msg.c_str());
136 return TimestampVal::null();
137 }
138
139 TimestampVal ts_val_ret;
140 ts_value_ret.ToTimestampVal(&ts_val_ret);
141 return ts_val_ret;
142}
143
144TimestampVal TimestampFunctions::ToUtc(FunctionContext* context,
145 const TimestampVal& ts_val, const StringVal& tz_string_val) {

Callers

nothing calls this directly

Calls 8

GetTimezoneFunction · 0.85
SubstituteFunction · 0.85
HasDateAndTimeMethod · 0.80
UtcToLocalMethod · 0.80
AddWarningMethod · 0.80
ToTimestampValMethod · 0.80
ToStringMethod · 0.45
DebugStringMethod · 0.45

Tested by

no test coverage detected