XiangpengHao commented on code in PR #11888:
URL: https://github.com/apache/datafusion/pull/11888#discussion_r1709551000
##########
datafusion/functions/src/string/initcap.rs:
##########
@@ -88,28 +91,40 @@ fn initcap<T: OffsetSizeTrait>(args: &[ArrayRef]) ->
Result<ArrayRef> {
// first map is the iterator, second is for the `Option<_>`
let result = string_array
.iter()
- .map(|string| {
- string.map(|string: &str| {
- let mut char_vector = Vec::<char>::new();
- let mut previous_character_letter_or_number = false;
- for c in string.chars() {
- if previous_character_letter_or_number {
- char_vector.push(c.to_ascii_lowercase());
- } else {
- char_vector.push(c.to_ascii_uppercase());
- }
- previous_character_letter_or_number =
c.is_ascii_uppercase()
- || c.is_ascii_lowercase()
- || c.is_ascii_digit();
- }
- char_vector.iter().collect::<String>()
- })
- })
+ .map(initcap_string)
.collect::<GenericStringArray<T>>();
Ok(Arc::new(result) as ArrayRef)
}
+fn initcap_utf8view<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef>
{
Review Comment:
Since we only do `i32` offset here, we probably can remove this `<T:
OffsetSizeTrait>`
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]