izveigor commented on code in PR #6805:
URL: https://github.com/apache/arrow-datafusion/pull/6805#discussion_r1250864123
##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -420,74 +496,58 @@ pub fn array_fill(args: &[ColumnarValue]) ->
Result<ColumnarValue> {
macro_rules! position {
($ARRAY:expr, $ELEMENT:expr, $INDEX:expr, $ARRAY_TYPE:ident) => {{
- let child_array =
- downcast_arg!(downcast_arg!($ARRAY, ListArray).values(),
$ARRAY_TYPE);
- let element = downcast_arg!($ELEMENT, $ARRAY_TYPE).value(0);
-
- match child_array
+ let element = downcast_arg!($ELEMENT, $ARRAY_TYPE);
+ $ARRAY
.iter()
- .skip($INDEX)
- .position(|x| x == Some(element))
- {
- Some(value) => Ok(ColumnarValue::Scalar(ScalarValue::UInt8(Some(
- (value + $INDEX + 1) as u8,
- )))),
- None => Ok(ColumnarValue::Scalar(ScalarValue::Null)),
- }
+ .zip(element.iter())
+ .zip($INDEX.iter())
+ .map(|((arr, el), i)| {
+ let index = match i {
+ Some(i) => {
+ if i <= 0 {
+ 0
+ } else {
+ i - 1
+ }
+ }
+ None => {
+ return Err(DataFusionError::Internal(
+ "initial position must not be null".to_string(),
Review Comment:
PostgreSQL does not support `NULL` like the start position. Should we do
that or is it better to translate `NULL` to`0`?
--
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]