Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions datafusion/functions-nested/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl ArraySlice {
ArrayFunctionArgument::Index,
ArrayFunctionArgument::Index,
],
array_coercion: None,
array_coercion: Some(ListCoercion::FixedSizedListToList),
}),
TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
arguments: vec![
Expand All @@ -346,7 +346,7 @@ impl ArraySlice {
ArrayFunctionArgument::Index,
ArrayFunctionArgument::Index,
],
array_coercion: None,
array_coercion: Some(ListCoercion::FixedSizedListToList),
}),
],
Volatility::Immutable,
Expand Down Expand Up @@ -672,15 +672,7 @@ pub(super) struct ArrayPopFront {
impl ArrayPopFront {
pub fn new() -> Self {
Self {
signature: Signature {
type_signature: TypeSignature::ArraySignature(
ArrayFunctionSignature::Array {
arguments: vec![ArrayFunctionArgument::Array],
array_coercion: Some(ListCoercion::FixedSizedListToList),
},
),
volatility: Volatility::Immutable,
},
signature: Signature::array(Volatility::Immutable),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to array_slice, just refactoring to make use of equivalent Signature::array function

aliases: vec![String::from("list_pop_front")],
}
}
Expand Down Expand Up @@ -776,15 +768,7 @@ pub(super) struct ArrayPopBack {
impl ArrayPopBack {
pub fn new() -> Self {
Self {
signature: Signature {
type_signature: TypeSignature::ArraySignature(
ArrayFunctionSignature::Array {
arguments: vec![ArrayFunctionArgument::Array],
array_coercion: Some(ListCoercion::FixedSizedListToList),
},
),
volatility: Volatility::Immutable,
},
signature: Signature::array(Volatility::Immutable),
Comment on lines -779 to +771
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

aliases: vec![String::from("list_pop_back")],
}
}
Expand Down
12 changes: 12 additions & 0 deletions datafusion/sqllogictest/test_files/array.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,12 @@ select array_slice(arrow_cast(make_array(1, 2, 3, 4, 5), 'LargeList(Int64)'), 2,
----
[2, 3, 4] [h, e]

query ??
select array_slice(arrow_cast(make_array(1, 2, 3, 4, 5), 'FixedSizeList(5, Int64)'), 2, 4),
array_slice(arrow_cast(make_array('h', 'e', 'l', 'l', 'o'), 'FixedSizeList(5, Utf8)'), 1, 2);
----
[2, 3, 4] [h, e]

# array_slice scalar function #2 (with positive indexes; full array)
query ??
select array_slice(make_array(1, 2, 3, 4, 5), 0, 6), array_slice(make_array('h', 'e', 'l', 'l', 'o'), 0, 5);
Expand All @@ -1959,6 +1965,12 @@ select array_slice(arrow_cast(make_array(1, 2, 3, 4, 5), 'LargeList(Int64)'), 0,
----
[1, 2, 3, 4, 5] [h, e, l, l, o]

query ??
select array_slice(arrow_cast(make_array(1, 2, 3, 4, 5), 'FixedSizeList(5, Int64)'), 0, 6),
array_slice(arrow_cast(make_array('h', 'e', 'l', 'l', 'o'), 'FixedSizeList(5, Utf8)'), 0, 5);
----
[1, 2, 3, 4, 5] [h, e, l, l, o]

# array_slice scalar function #3 (with positive indexes; first index = second index)
query ??
select array_slice(make_array(1, 2, 3, 4, 5), 4, 4), array_slice(make_array('h', 'e', 'l', 'l', 'o'), 3, 3);
Expand Down
Loading