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

Method ToUtc

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

Source from the content-addressed store, hash-verified

142}
143
144TimestampVal TimestampFunctions::ToUtc(FunctionContext* context,
145 const TimestampVal& ts_val, const StringVal& tz_string_val) {
146 if (ts_val.is_null || tz_string_val.is_null) return TimestampVal::null();
147 const TimestampValue& ts_value = TimestampValue::FromTimestampVal(ts_val);
148 if (!ts_value.HasDateAndTime()) return TimestampVal::null();
149
150 const StringValue& tz_string_value = StringValue::FromStringVal(tz_string_val);
151 const Timezone* timezone = GetTimezone(context, tz_string_value);
152 if (UNLIKELY(timezone == nullptr)) return ts_val;
153
154 TimestampValue ts_value_ret = ts_value;
155 ts_value_ret.LocalToUtc(*timezone);
156 if (UNLIKELY(!ts_value_ret.HasDateAndTime())) {
157 const string& msg =
158 Substitute("Timestamp '$0' in timezone '$1' could not be converted to UTC",
159 ts_value.ToString(), tz_string_value.DebugString());
160 context->AddWarning(msg.c_str());
161 return TimestampVal::null();
162 }
163
164 TimestampVal ts_val_ret;
165 ts_value_ret.ToTimestampVal(&ts_val_ret);
166 return ts_val_ret;
167}
168
169void TimestampFunctions::FromUtcAndToUtcClose(FunctionContext* context,
170 FunctionContext::FunctionStateScope scope) {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected