Omega359 opened a new issue, #6713:
URL: https://github.com/apache/arrow-rs/issues/6713
**Is your feature request related to a problem or challenge? Please describe
what you are trying to do.**
While working on upgrading to DF 43 I discovered that casting support for
utf8view <-> bool has not been implemented
**Describe the solution you'd like**
Support casting to/from bool with utf8view's
**Additional context**
arrow-cast/src/cast/mod.rs
```
#[test]
fn test_cast_utf8view_to_bool() {
let strings = StringViewArray::from(vec!["true", "false", "invalid",
" Y ", ""]);
let casted = cast(&strings, &DataType::Boolean).unwrap();
let expected = BooleanArray::from(vec![Some(true), Some(false),
None, Some(true), None]);
assert_eq!(*as_boolean_array(&casted), expected);
}
#[test]
fn test_cast_with_options_utf8view_to_bool() {
let strings = StringViewArray::from(vec!["true", "false", "invalid",
" Y ", ""]);
let casted = cast_with_options(
&strings,
&DataType::Boolean,
&CastOptions {
safe: false,
format_options: FormatOptions::default(),
},
);
match casted {
Ok(_) => panic!("expected error"),
Err(e) => {
assert!(e
.to_string()
.contains("Cast error: Cannot cast value 'invalid' to
value of Boolean type"))
}
}
}
#[test]
fn test_cast_bool_to_utf8view() {
let array = BooleanArray::from(vec![Some(true), Some(false), None]);
let b = cast(&array, &DataType::Utf8View).unwrap();
let c = b.as_any().downcast_ref::<StringViewArray>().unwrap();
assert_eq!("true", c.value(0));
assert_eq!("false", c.value(1));
assert!(!c.is_valid(2));
}
```
--
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]