alamb commented on code in PR #9730:
URL: https://github.com/apache/arrow-datafusion/pull/9730#discussion_r1535694427
##########
datafusion/functions/src/string/btrim.rs:
##########
@@ -16,27 +16,27 @@
// under the License.
use arrow::array::{ArrayRef, OffsetSizeTrait};
-use arrow::datatypes::DataType;
-use datafusion_common::exec_err;
-use datafusion_common::Result;
-use datafusion_expr::ColumnarValue;
-use datafusion_expr::TypeSignature::*;
-use datafusion_expr::{ScalarUDFImpl, Signature, Volatility};
use std::any::Any;
-use crate::string::{make_scalar_function, utf8_to_str_type};
+use arrow::datatypes::DataType;
-use super::{general_trim, TrimType};
+use datafusion_common::{exec_err, Result};
+use datafusion_expr::TypeSignature::*;
+use datafusion_expr::{ColumnarValue, Volatility};
+use datafusion_expr::{ScalarUDFImpl, Signature};
-/// Returns the longest string with leading and trailing characters removed.
If the characters are not specified, whitespace is removed.
+use crate::string::common::*;
+
+/// Returns the longest string with leading and trailing characters removed.
If the characters are not specified, whitespace is removed.
/// btrim('xyxtrimyyx', 'xyz') = 'trim'
-pub fn btrim<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
+fn btrim<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
general_trim::<T>(args, TrimType::Both)
}
#[derive(Debug)]
pub(super) struct TrimFunc {
Review Comment:
It isn't a huge deal, but I found it a little confusing that the function is
called `TrimFunc` but has a name of `"btrim"` and an alias of `"trim"`
I would expect either `BTrimFunc` or else the name of "trim" and an alias of
`"btrim"`
##########
datafusion/physical-expr/src/functions.rs:
##########
@@ -752,70 +725,6 @@ mod tests {
Int32Array
);
test_function!(BitLength, &[lit("")], Ok(Some(0)), i32, Int32,
Int32Array);
- test_function!(
Review Comment:
I double checked and the functions are already tested in expr.slt (e.g.
https://github.com/apache/arrow-datafusion/blob/47f4b5a67ac3b327764cbd4c0f42da7ac44854e5/datafusion/sqllogictest/test_files/expr.slt#L558-L574)
Thus removing these tests looks good to me 👍
##########
datafusion/functions/src/string/mod.rs:
##########
@@ -15,278 +15,63 @@
// specific language governing permissions and limitations
// under the License.
-use arrow::{
- array::{Array, ArrayRef, GenericStringArray, OffsetSizeTrait},
- datatypes::DataType,
-};
-use datafusion_common::{
- cast::as_generic_string_array, exec_err, plan_err, Result, ScalarValue,
-};
-use datafusion_expr::{ColumnarValue, ScalarFunctionImplementation};
-use datafusion_physical_expr::functions::Hint;
-use std::{
- fmt::{Display, Formatter},
- sync::Arc,
-};
+//! "string" DataFusion functions
-/// Creates a function to identify the optimal return type of a string
function given
-/// the type of its first argument.
-///
-/// If the input type is `LargeUtf8` or `LargeBinary` the return type is
-/// `$largeUtf8Type`,
-///
-/// If the input type is `Utf8` or `Binary` the return type is `$utf8Type`,
-macro_rules! get_optimal_return_type {
Review Comment:
thank you for cleaning this up
##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -919,26 +922,25 @@ lpad(str, n[, padding_str])
### `ltrim`
-Removes leading spaces from a string.
+Trims the specified trim string from the beginning of a string.
Review Comment:
Thank you for correcting and rationalizing the documentation
--
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]