()
| 566 | |
| 567 | #[test] |
| 568 | fn test_cast_column_with_options() { |
| 569 | let source = Arc::new(Int64Array::from(vec![1, i64::MAX])) as ArrayRef; |
| 570 | let target_field = field("ints", DataType::Int32); |
| 571 | |
| 572 | let safe_opts = CastOptions { |
| 573 | // safe: false - return Err for failure |
| 574 | safe: false, |
| 575 | ..DEFAULT_CAST_OPTIONS |
| 576 | }; |
| 577 | assert!(cast_column(&source, target_field.data_type(), &safe_opts).is_err()); |
| 578 | |
| 579 | let unsafe_opts = CastOptions { |
| 580 | // safe: true - return Null for failure |
| 581 | safe: true, |
| 582 | ..DEFAULT_CAST_OPTIONS |
| 583 | }; |
| 584 | let result = |
| 585 | cast_column(&source, target_field.data_type(), &unsafe_opts).unwrap(); |
| 586 | let result = result.as_any().downcast_ref::<Int32Array>().unwrap(); |
| 587 | assert_eq!(result.value(0), 1); |
| 588 | assert!(result.is_null(1)); |
| 589 | } |
| 590 | |
| 591 | #[test] |
| 592 | fn test_cast_struct_with_missing_field() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…