This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 112f01f195 test(arrow-cast): move test_first_none and
test_first_last_none to cast integration suite (#12264)
112f01f195 is described below
commit 112f01f195e080af7625b6420772240c8a9f9215
Author: Arnab Mondal <[email protected]>
AuthorDate: Sun Nov 15 07:01:45 2026 +0000
test(arrow-cast): move test_first_none and test_first_last_none to cast
integration suite (#12264)
# Which issue does this PR close?
Part of [#11033](https://github.com/apache/arrow-rs/issues/11033).
# Rationale for this change
Continues moving public-behavior cast tests out of the inline test
module in `arrow-cast/src/cast/mod.rs` into the crate-level `cast`
integration suite. `test_first_none` and `test_first_last_none` exercise
`List` -> `FixedSizeList` casts, so they belong in `tests/cast/list.rs`.
# What changes are included in this PR?
- Moves `test_first_none` and `test_first_last_none` into
`arrow-cast/tests/cast/list.rs` (bodies unchanged).
- Adds the `FieldRef` import there and drops the now-unused `Field`
import from the inline test module.
# Are these changes tested?
- `cargo test -p arrow-cast`
- `cargo clippy -p arrow-cast --all-targets --all-features -- -D
warnings`
- `cargo fmt --all -- --check`
# Are there any user-facing changes?
No. Test-organization-only change.
# AI usage disclosure
Claude Code assisted with the mechanical test move. I reviewed the
change and verified the tests and lints locally.
---
arrow-cast/src/cast/mod.rs | 38 +-------------------------------------
arrow-cast/tests/cast/list.rs | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 38 deletions(-)
diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs
index 8bdeabd835..62f396b8fa 100644
--- a/arrow-cast/src/cast/mod.rs
+++ b/arrow-cast/src/cast/mod.rs
@@ -2067,7 +2067,7 @@ mod tests {
use DataType::*;
use arrow_array::{Int64Array, StringArray};
use arrow_buffer::{NullBuffer, i256};
- use arrow_schema::{DataType, Field};
+ use arrow_schema::DataType;
use chrono::{FixedOffset, NaiveDate, NaiveTime};
use half::f16;
use std::sync::Arc;
@@ -4048,42 +4048,6 @@ mod tests {
);
}
}
- #[test]
- fn test_first_none() {
- let array = Arc::new(ListArray::from_iter_primitive::<Int64Type, _,
_>(vec![
- None,
- Some(vec![Some(1), Some(2)]),
- ])) as ArrayRef;
- let data_type =
- DataType::FixedSizeList(FieldRef::new(Field::new("item",
DataType::Int64, true)), 2);
- let opt = CastOptions::default();
- let r = cast_with_options(&array, &data_type, &opt).unwrap();
-
- let fixed_array =
Arc::new(FixedSizeListArray::from_iter_primitive::<Int64Type, _, _>(
- vec![None, Some(vec![Some(1), Some(2)])],
- 2,
- )) as ArrayRef;
- assert_eq!(*fixed_array, *r);
- }
-
- #[test]
- fn test_first_last_none() {
- let array = Arc::new(ListArray::from_iter_primitive::<Int64Type, _,
_>(vec![
- None,
- Some(vec![Some(1), Some(2)]),
- None,
- ])) as ArrayRef;
- let data_type =
- DataType::FixedSizeList(FieldRef::new(Field::new("item",
DataType::Int64, true)), 2);
- let opt = CastOptions::default();
- let r = cast_with_options(&array, &data_type, &opt).unwrap();
-
- let fixed_array =
Arc::new(FixedSizeListArray::from_iter_primitive::<Int64Type, _, _>(
- vec![None, Some(vec![Some(1), Some(2)]), None],
- 2,
- )) as ArrayRef;
- assert_eq!(*fixed_array, *r);
- }
fn assert_temporal_overflow_is_safe(array: &dyn Array, to_type: &DataType)
{
let result = cast(array, to_type).unwrap();
diff --git a/arrow-cast/tests/cast/list.rs b/arrow-cast/tests/cast/list.rs
index a26f97f63a..c27c43618b 100644
--- a/arrow-cast/tests/cast/list.rs
+++ b/arrow-cast/tests/cast/list.rs
@@ -18,7 +18,7 @@ use arrow_buffer::{Buffer, NullBuffer, OffsetBuffer,
ScalarBuffer};
use arrow_cast::display::{ArrayFormatter, FormatOptions};
use arrow_cast::{CastOptions, can_cast_types, cast, cast_with_options};
use arrow_data::ArrayData;
-use arrow_schema::{DataType, Field, TimeUnit};
+use arrow_schema::{DataType, Field, FieldRef, TimeUnit};
use half::f16;
#[test]
fn test_cast_i32_to_list_i32() {
@@ -1764,3 +1764,40 @@ fn test_cast_large_list_view_to_list_view() {
let expected = ListViewArray::from_iter_primitive::<Int32Type, _,
_>(int32_list_values());
assert_eq!(got, &expected);
}
+
+#[test]
+fn test_first_none() {
+ let array = Arc::new(ListArray::from_iter_primitive::<Int64Type, _,
_>(vec![
+ None,
+ Some(vec![Some(1), Some(2)]),
+ ])) as ArrayRef;
+ let data_type =
+ DataType::FixedSizeList(FieldRef::new(Field::new("item",
DataType::Int64, true)), 2);
+ let opt = CastOptions::default();
+ let r = cast_with_options(&array, &data_type, &opt).unwrap();
+
+ let fixed_array =
Arc::new(FixedSizeListArray::from_iter_primitive::<Int64Type, _, _>(
+ vec![None, Some(vec![Some(1), Some(2)])],
+ 2,
+ )) as ArrayRef;
+ assert_eq!(*fixed_array, *r);
+}
+
+#[test]
+fn test_first_last_none() {
+ let array = Arc::new(ListArray::from_iter_primitive::<Int64Type, _,
_>(vec![
+ None,
+ Some(vec![Some(1), Some(2)]),
+ None,
+ ])) as ArrayRef;
+ let data_type =
+ DataType::FixedSizeList(FieldRef::new(Field::new("item",
DataType::Int64, true)), 2);
+ let opt = CastOptions::default();
+ let r = cast_with_options(&array, &data_type, &opt).unwrap();
+
+ let fixed_array =
Arc::new(FixedSizeListArray::from_iter_primitive::<Int64Type, _, _>(
+ vec![None, Some(vec![Some(1), Some(2)]), None],
+ 2,
+ )) as ArrayRef;
+ assert_eq!(*fixed_array, *r);
+}