MCPcopy Create free account
hub / github.com/apache/datafusion / test_cast_column_with_options

Function test_cast_column_with_options

datafusion/common/src/nested_struct.rs:568–589  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
cast_columnFunction · 0.85
fieldFunction · 0.70
data_typeMethod · 0.45
as_anyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…