martin-g commented on code in PR #19598:
URL: https://github.com/apache/datafusion/pull/19598#discussion_r2657704606
##########
datafusion/functions/src/string/bit_length.rs:
##########
@@ -90,17 +95,44 @@ impl ScalarUDFImpl for BitLengthFunc {
let [array] = take_function_args(self.name(), &args.args)?;
match array {
- ColumnarValue::Array(v) =>
Ok(ColumnarValue::Array(bit_length(v.as_ref())?)),
+ ColumnarValue::Array(v) => {
+ if let Some(arr) = v.as_any().downcast_ref::<StringArray>() {
+ let mut builder = Int32Builder::with_capacity(arr.len());
+ for i in 0..arr.len() {
+ if arr.is_null(i) {
+ builder.append_null();
+ } else {
+ let byte_len = arr.value(i).as_bytes().len();
Review Comment:
Is `.as_bytes()` needed here ? `&str::len()` returns the same
##########
datafusion/functions/src/string/bit_length.rs:
##########
@@ -28,6 +28,11 @@ use datafusion_expr::{
TypeSignatureClass, Volatility,
};
use datafusion_macros::user_doc;
+use arrow::array::{
+ Array, StringArray, LargeStringArray, Int32Builder,
+};
+use std::sync::Arc;
+
Review Comment:
```suggestion
```
--
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]