MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / array_upper

Function array_upper

src/expr/src/scalar/func.rs:2794–2808  ·  view source on GitHub ↗
(a: Array<'a>, i: i64)

Source from the content-addressed store, hash-verified

2792// TODO(benesch): remove potentially dangerous usage of `as`.
2793#[allow(clippy::as_conversions)]
2794fn array_upper<'a>(a: Array<'a>, i: i64) -> Result<Option<i32>, EvalError> {
2795 if i < 1 {
2796 return Ok(None);
2797 }
2798 a.dims()
2799 .into_iter()
2800 .nth(i as usize - 1)
2801 .map(|dim| {
2802 let (_lower, upper) = dim.dimension_bounds();
2803 upper
2804 .try_into()
2805 .map_err(|_| EvalError::Int32OutOfRange(upper.to_string().into()))
2806 })
2807 .transpose()
2808}
2809
2810#[sqlfunc(
2811 is_infix_op = true,

Callers 1

Calls 6

dimsMethod · 0.80
dimension_boundsMethod · 0.80
mapMethod · 0.45
into_iterMethod · 0.45
try_intoMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected