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

Method ConvertToTimestampVal

be/src/exprs/decimal-operators-ir.cc:638–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636
637template <typename T>
638TimestampVal DecimalOperators::ConvertToTimestampVal(
639 const T& decimal_value, int scale, bool round, const Timezone* local_tz) {
640 typename T::StorageType seconds = decimal_value.whole_part(scale);
641 if (seconds < numeric_limits<int64_t>::min() ||
642 seconds > numeric_limits<int64_t>::max()) {
643 // TimeStampVal() takes int64_t.
644 return TimestampVal::null();
645 }
646 int32_t nanoseconds =
647 ConvertToNanoseconds(decimal_value.fractional_part(scale), scale, round);
648 if (decimal_value.is_negative()) nanoseconds *= -1;
649 TimestampVal result;
650 TimestampValue::FromUnixTimeNanos(
651 seconds, nanoseconds, local_tz).ToTimestampVal(&result);
652 return result;
653}
654
655
656TimestampVal DecimalOperators::CastToTimestampVal(

Callers

nothing calls this directly

Calls 6

minFunction · 0.85
maxFunction · 0.85
whole_partMethod · 0.80
fractional_partMethod · 0.80
is_negativeMethod · 0.80
ToTimestampValMethod · 0.80

Tested by

no test coverage detected