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

Method AddSubWeeks

be/src/exprs/date-functions-ir.cc:248–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246
247template <bool is_add, typename AnyIntVal>
248DateVal DateFunctions::AddSubWeeks(FunctionContext* context, const DateVal& d_val,
249 const AnyIntVal& num_weeks) {
250 if (d_val.is_null || num_weeks.is_null) return DateVal::null();
251
252 // Sanity check: make sure that the number of weeks converted to days fits into 64-bits.
253 int64_t weeks = is_add ? num_weeks.val : -num_weeks.val;
254 if (weeks > numeric_limits<int64_t>::max() / 7
255 || weeks < numeric_limits<int64_t>::min() / 7) {
256 return DateVal::null();
257 }
258
259 const DateValue dv = DateValue::FromDateVal(d_val).AddDays(weeks * 7);
260 return dv.ToDateVal();
261}
262
263// Explicit template instantiation is required for proper linking. These functions
264// are only indirectly called via a function pointer provided by the opcode registry

Callers

nothing calls this directly

Calls 4

maxFunction · 0.85
minFunction · 0.85
AddDaysMethod · 0.80
ToDateValMethod · 0.80

Tested by

no test coverage detected