Jefffrey commented on code in PR #22291:
URL: https://github.com/apache/datafusion/pull/22291#discussion_r3315400427
##########
datafusion/functions-nested/src/position.rs:
##########
@@ -207,17 +207,23 @@ fn resolve_start_from(
match third_arg {
None => Ok(vec![0i64; num_rows]),
Some(ColumnarValue::Scalar(ScalarValue::Int64(Some(v)))) => {
- Ok(vec![v - 1; num_rows])
+ Ok(vec![normalize_start_from(*v)?; num_rows])
}
Some(ColumnarValue::Scalar(s)) => {
exec_err!("array_position expected Int64 for start_from, got {s}")
}
- Some(ColumnarValue::Array(a)) => {
- Ok(as_int64_array(a)?.values().iter().map(|&x| x - 1).collect())
- }
+ Some(ColumnarValue::Array(a)) => as_int64_array(a)?
+ .values()
+ .iter()
+ .map(|&x| normalize_start_from(x))
+ .collect(),
}
}
+fn normalize_start_from(start_from: i64) -> Result<i64> {
Review Comment:
we can just inline this
##########
datafusion/functions-nested/src/position.rs:
##########
@@ -592,9 +598,29 @@ fn array_positions_scalar<O: OffsetSizeTrait>(
mod tests {
use super::*;
use arrow::array::AsArray;
- use arrow::datatypes::Int32Type;
+ use arrow::array::Int64Array;
+ use arrow::datatypes::{Int32Type, Int64Type};
use datafusion_common::config::ConfigOptions;
+ #[test]
+ fn test_array_position_start_from_min_value() -> Result<()> {
Review Comment:
we can remove this test since we already have an SLT
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]