viirya commented on code in PR #8411:
URL: https://github.com/apache/arrow-datafusion/pull/8411#discussion_r1414334754
##########
datafusion/common/src/scalar.rs:
##########
@@ -4645,6 +4651,16 @@ mod tests {
);
}
+ #[test]
+ fn test_scalar_value_from_string() {
+ let scalar = ScalarValue::from("foo");
+ assert_eq!(scalar, ScalarValue::Utf8(Some("foo".to_string())));
+ let scalar = ScalarValue::from("foo".to_string());
+ assert_eq!(scalar, ScalarValue::Utf8(Some("foo".to_string())));
Review Comment:
Hmm, as we already implement `From<&str>` for `ScalarValue`, we can simply
do this for a `String` if we want to have a `ScalarValue` for it:
```rust
let scalar = ScalarValue::from("foo".to_string().as_str());
assert_eq!(scalar, ScalarValue::Utf8(Some("foo".to_string())));
```
I think the only difference is `From<String>` avoids copying the string
content?
Do we have used `as_str()` for `String` in current code to create
`ScalarValue`? We probably can change to remove `as_str()`.
--
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]