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

Function array_lower

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

Source from the content-addressed store, hash-verified

2741// TODO(benesch): remove potentially dangerous usage of `as`.
2742#[allow(clippy::as_conversions)]
2743fn array_lower<'a>(a: Array<'a>, i: i64) -> Result<Option<i32>, EvalError> {
2744 if i < 1 {
2745 return Ok(None);
2746 }
2747 a.dims()
2748 .into_iter()
2749 .nth(i as usize - 1)
2750 .map(|dim| {
2751 let (lower, _upper) = dim.dimension_bounds();
2752 lower
2753 .try_into()
2754 .map_err(|_| EvalError::Int32OutOfRange(lower.to_string().into()))
2755 })
2756 .transpose()
2757}
2758
2759#[sqlfunc(
2760 output_type_expr = "input_types[0].scalar_type.without_modifiers().nullable(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