MCPcopy Create free account
hub / github.com/apache/datafusion / resolve_start_from

Function resolve_start_from

datafusion/functions-nested/src/position.rs:203–219  ·  view source on GitHub ↗

Resolves the optional `start_from` argument into a `Vec ` of 0-indexed starting positions.

(
    third_arg: Option<&ColumnarValue>,
    num_rows: usize,
)

Source from the content-addressed store, hash-verified

201/// Resolves the optional `start_from` argument into a `Vec<i64>` of
202/// 0-indexed starting positions.
203fn resolve_start_from(
204 third_arg: Option<&ColumnarValue>,
205 num_rows: usize,
206) -> Result<Vec<i64>> {
207 match third_arg {
208 None => Ok(vec![0i64; num_rows]),
209 Some(ColumnarValue::Scalar(ScalarValue::Int64(Some(v)))) => {
210 Ok(vec![v - 1; num_rows])
211 }
212 Some(ColumnarValue::Scalar(s)) => {
213 exec_err!("array_position expected Int64 for start_from, got {s}")
214 }
215 Some(ColumnarValue::Array(a)) => {
216 Ok(as_int64_array(a)?.values().iter().map(|&x| x - 1).collect())
217 }
218 }
219}
220
221/// Fast path for `array_position` when the needle is scalar.
222///

Callers 1

Calls 5

as_int64_arrayFunction · 0.85
collectMethod · 0.80
mapMethod · 0.45
iterMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…