diff --git a/datafusion/expr/src/built_in_function.rs b/datafusion/expr/src/built_in_function.rs index 7649c27b392f..d0ec1326c49e 100644 --- a/datafusion/expr/src/built_in_function.rs +++ b/datafusion/expr/src/built_in_function.rs @@ -121,10 +121,6 @@ pub enum BuiltinScalarFunction { Left, /// lpad Lpad, - /// lower - Lower, - /// octet_length - OctetLength, /// random Random, /// repeat @@ -247,8 +243,6 @@ impl BuiltinScalarFunction { BuiltinScalarFunction::InitCap => Volatility::Immutable, BuiltinScalarFunction::Left => Volatility::Immutable, BuiltinScalarFunction::Lpad => Volatility::Immutable, - BuiltinScalarFunction::Lower => Volatility::Immutable, - BuiltinScalarFunction::OctetLength => Volatility::Immutable, BuiltinScalarFunction::Radians => Volatility::Immutable, BuiltinScalarFunction::Repeat => Volatility::Immutable, BuiltinScalarFunction::Replace => Volatility::Immutable, @@ -305,13 +299,7 @@ impl BuiltinScalarFunction { utf8_to_str_type(&input_expr_types[0], "initcap") } BuiltinScalarFunction::Left => utf8_to_str_type(&input_expr_types[0], "left"), - BuiltinScalarFunction::Lower => { - utf8_to_str_type(&input_expr_types[0], "lower") - } BuiltinScalarFunction::Lpad => utf8_to_str_type(&input_expr_types[0], "lpad"), - BuiltinScalarFunction::OctetLength => { - utf8_to_int_type(&input_expr_types[0], "octet_length") - } BuiltinScalarFunction::Pi => Ok(Float64), BuiltinScalarFunction::Random => Ok(Float64), BuiltinScalarFunction::Uuid => Ok(Utf8), @@ -428,8 +416,6 @@ impl BuiltinScalarFunction { BuiltinScalarFunction::BitLength | BuiltinScalarFunction::CharacterLength | BuiltinScalarFunction::InitCap - | BuiltinScalarFunction::Lower - | BuiltinScalarFunction::OctetLength | BuiltinScalarFunction::Reverse => { Signature::uniform(1, vec![Utf8, LargeUtf8], self.volatility()) } @@ -682,9 +668,7 @@ impl BuiltinScalarFunction { BuiltinScalarFunction::EndsWith => &["ends_with"], BuiltinScalarFunction::InitCap => &["initcap"], BuiltinScalarFunction::Left => &["left"], - BuiltinScalarFunction::Lower => &["lower"], BuiltinScalarFunction::Lpad => &["lpad"], - BuiltinScalarFunction::OctetLength => &["octet_length"], BuiltinScalarFunction::Repeat => &["repeat"], BuiltinScalarFunction::Replace => &["replace"], BuiltinScalarFunction::Reverse => &["reverse"], diff --git a/datafusion/expr/src/expr_fn.rs b/datafusion/expr/src/expr_fn.rs index 061b16562e82..e1ab11c5b778 100644 --- a/datafusion/expr/src/expr_fn.rs +++ b/datafusion/expr/src/expr_fn.rs @@ -599,13 +599,6 @@ scalar_expr!( ); scalar_expr!(InitCap, initcap, string, "converts the first letter of each word in `string` in uppercase and the remaining characters in lowercase"); scalar_expr!(Left, left, string n, "returns the first `n` characters in the `string`"); -scalar_expr!(Lower, lower, string, "convert the string to lower case"); -scalar_expr!( - OctetLength, - octet_length, - string, - "returns the number of bytes of a string" -); scalar_expr!(Replace, replace, string from to, "replaces all occurrences of `from` with `to` in the `string`"); scalar_expr!(Repeat, repeat, string n, "repeats the `string` to `n` times"); scalar_expr!(Reverse, reverse, string, "reverses the `string`"); @@ -1069,10 +1062,8 @@ mod test { test_scalar_expr!(Lcm, lcm, arg_1, arg_2); test_scalar_expr!(InitCap, initcap, string); test_scalar_expr!(Left, left, string, count); - test_scalar_expr!(Lower, lower, string); test_nary_scalar_expr!(Lpad, lpad, string, count); test_nary_scalar_expr!(Lpad, lpad, string, count, characters); - test_scalar_expr!(OctetLength, octet_length, string); test_scalar_expr!(Replace, replace, string, from, to); test_scalar_expr!(Repeat, repeat, string, count); test_scalar_expr!(Reverse, reverse, string); diff --git a/datafusion/functions/src/string/common.rs b/datafusion/functions/src/string/common.rs index 97465420fb99..339f4e6c1a23 100644 --- a/datafusion/functions/src/string/common.rs +++ b/datafusion/functions/src/string/common.rs @@ -141,6 +141,9 @@ macro_rules! get_optimal_return_type { // `utf8_to_str_type`: returns either a Utf8 or LargeUtf8 based on the input type size. get_optimal_return_type!(utf8_to_str_type, DataType::LargeUtf8, DataType::Utf8); +// `utf8_to_int_type`: returns either a Int32 or Int64 based on the input type size. +get_optimal_return_type!(utf8_to_int_type, DataType::Int64, DataType::Int32); + /// applies a unary expression to `args[0]` that is expected to be downcastable to /// a `GenericStringArray` and returns a `GenericStringArray` (which may have a different offset) /// # Errors @@ -263,3 +266,67 @@ where } }) } + +#[cfg(test)] +pub mod test { + /// $FUNC ScalarUDFImpl to test + /// $ARGS arguments (vec) to pass to function + /// $EXPECTED a Result + /// $EXPECTED_TYPE is the expected value type + /// $EXPECTED_DATA_TYPE is the expected result type + /// $ARRAY_TYPE is the column type after function applied + macro_rules! test_function { + ($FUNC:expr, $ARGS:expr, $EXPECTED:expr, $EXPECTED_TYPE:ty, $EXPECTED_DATA_TYPE:expr, $ARRAY_TYPE:ident) => { + let expected: Result> = $EXPECTED; + let func = $FUNC; + + let type_array = $ARGS.iter().map(|arg| arg.data_type()).collect::>(); + let return_type = func.return_type(&type_array); + + match expected { + Ok(expected) => { + assert_eq!(return_type.is_ok(), true); + assert_eq!(return_type.unwrap(), $EXPECTED_DATA_TYPE); + + let result = func.invoke($ARGS); + assert_eq!(result.is_ok(), true); + + let len = $ARGS + .iter() + .fold(Option::::None, |acc, arg| match arg { + ColumnarValue::Scalar(_) => acc, + ColumnarValue::Array(a) => Some(a.len()), + }); + let inferred_length = len.unwrap_or(1); + let result = result.unwrap().clone().into_array(inferred_length).expect("Failed to convert to array"); + let result = result.as_any().downcast_ref::<$ARRAY_TYPE>().expect("Failed to convert to type"); + + // value is correct + match expected { + Some(v) => assert_eq!(result.value(0), v), + None => assert!(result.is_null(0)), + }; + } + Err(expected_error) => { + if return_type.is_err() { + match return_type { + Ok(_) => assert!(false, "expected error"), + Err(error) => { datafusion_common::assert_contains!(expected_error.strip_backtrace(), error.strip_backtrace()); } + } + } + else { + // invoke is expected error - cannot use .expect_err() due to Debug not being implemented + match func.invoke($ARGS) { + Ok(_) => assert!(false, "expected error"), + Err(error) => { + assert!(expected_error.strip_backtrace().starts_with(&error.strip_backtrace())); + } + } + } + } + }; + }; + } + + pub(crate) use test_function; +} diff --git a/datafusion/functions/src/string/lower.rs b/datafusion/functions/src/string/lower.rs new file mode 100644 index 000000000000..42bda0470067 --- /dev/null +++ b/datafusion/functions/src/string/lower.rs @@ -0,0 +1,63 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use crate::string::common::{handle, utf8_to_str_type}; +use arrow::datatypes::DataType; +use datafusion_common::Result; +use datafusion_expr::ColumnarValue; +use datafusion_expr::{ScalarUDFImpl, Signature, Volatility}; +use std::any::Any; + +#[derive(Debug)] +pub(super) struct LowerFunc { + signature: Signature, +} + +impl LowerFunc { + pub fn new() -> Self { + use DataType::*; + Self { + signature: Signature::uniform( + 1, + vec![Utf8, LargeUtf8], + Volatility::Immutable, + ), + } + } +} + +impl ScalarUDFImpl for LowerFunc { + fn as_any(&self) -> &dyn Any { + self + } + + fn name(&self) -> &str { + "lower" + } + + fn signature(&self) -> &Signature { + &self.signature + } + + fn return_type(&self, arg_types: &[DataType]) -> Result { + utf8_to_str_type(&arg_types[0], "lower") + } + + fn invoke(&self, args: &[ColumnarValue]) -> Result { + handle(args, |string| string.to_lowercase(), "lower") + } +} diff --git a/datafusion/functions/src/string/mod.rs b/datafusion/functions/src/string/mod.rs index 63026092f39a..a70a695e935b 100644 --- a/datafusion/functions/src/string/mod.rs +++ b/datafusion/functions/src/string/mod.rs @@ -24,7 +24,9 @@ use datafusion_expr::ScalarUDF; mod ascii; mod btrim; mod common; +mod lower; mod ltrim; +mod octet_length; mod rtrim; mod starts_with; mod to_hex; @@ -34,6 +36,8 @@ mod upper; make_udf_function!(ascii::AsciiFunc, ASCII, ascii); make_udf_function!(btrim::BTrimFunc, BTRIM, btrim); make_udf_function!(ltrim::LtrimFunc, LTRIM, ltrim); +make_udf_function!(lower::LowerFunc, LOWER, lower); +make_udf_function!(octet_length::OctetLengthFunc, OCTET_LENGTH, octet_length); make_udf_function!(rtrim::RtrimFunc, RTRIM, rtrim); make_udf_function!(starts_with::StartsWithFunc, STARTS_WITH, starts_with); make_udf_function!(to_hex::ToHexFunc, TO_HEX, to_hex); @@ -52,11 +56,21 @@ pub mod expr_fn { super::btrim().call(args) } + #[doc = "Converts a string to lowercase."] + pub fn lower(arg1: Expr) -> Expr { + super::lower().call(vec![arg1]) + } + #[doc = "Removes all characters, spaces by default, from the beginning of a string"] pub fn ltrim(args: Vec) -> Expr { super::ltrim().call(args) } + #[doc = "returns the number of bytes of a string"] + pub fn octet_length(args: Vec) -> Expr { + super::octet_length().call(args) + } + #[doc = "Removes all characters, spaces by default, from the end of a string"] pub fn rtrim(args: Vec) -> Expr { super::rtrim().call(args) @@ -83,7 +97,9 @@ pub fn functions() -> Vec> { vec![ ascii(), btrim(), + lower(), ltrim(), + octet_length(), rtrim(), starts_with(), to_hex(), diff --git a/datafusion/functions/src/string/octet_length.rs b/datafusion/functions/src/string/octet_length.rs new file mode 100644 index 000000000000..36a62fbe4e38 --- /dev/null +++ b/datafusion/functions/src/string/octet_length.rs @@ -0,0 +1,173 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use arrow::compute::kernels::length::length; +use std::any::Any; + +use arrow::datatypes::DataType; + +use datafusion_common::{exec_err, Result, ScalarValue}; +use datafusion_expr::{ColumnarValue, Volatility}; +use datafusion_expr::{ScalarUDFImpl, Signature}; + +use crate::string::common::*; + +#[derive(Debug)] +pub(super) struct OctetLengthFunc { + signature: Signature, +} + +impl OctetLengthFunc { + pub fn new() -> Self { + use DataType::*; + Self { + signature: Signature::uniform( + 1, + vec![Utf8, LargeUtf8], + Volatility::Immutable, + ), + } + } +} + +impl ScalarUDFImpl for OctetLengthFunc { + fn as_any(&self) -> &dyn Any { + self + } + + fn name(&self) -> &str { + "octet_length" + } + + fn signature(&self) -> &Signature { + &self.signature + } + + fn return_type(&self, arg_types: &[DataType]) -> Result { + utf8_to_int_type(&arg_types[0], "octet_length") + } + + fn invoke(&self, args: &[ColumnarValue]) -> Result { + if args.len() != 1 { + return exec_err!( + "octet_length function requires 1 argument, got {}", + args.len() + ); + } + + match &args[0] { + ColumnarValue::Array(v) => Ok(ColumnarValue::Array(length(v.as_ref())?)), + ColumnarValue::Scalar(v) => match v { + ScalarValue::Utf8(v) => Ok(ColumnarValue::Scalar(ScalarValue::Int32( + v.as_ref().map(|x| x.len() as i32), + ))), + ScalarValue::LargeUtf8(v) => Ok(ColumnarValue::Scalar( + ScalarValue::Int64(v.as_ref().map(|x| x.len() as i64)), + )), + _ => unreachable!(), + }, + } + } +} + +#[cfg(test)] +mod tests { + use crate::string::common::test::test_function; + use crate::string::octet_length::OctetLengthFunc; + use arrow::array::{Array, Int32Array, StringArray}; + use arrow::datatypes::DataType::Int32; + use datafusion_common::ScalarValue; + use datafusion_common::{exec_err, Result}; + use datafusion_expr::{ColumnarValue, ScalarUDFImpl}; + use std::sync::Arc; + + #[test] + fn test_functions() -> Result<()> { + test_function!( + OctetLengthFunc::new(), + &[ColumnarValue::Scalar(ScalarValue::Int32(Some(12)))], + exec_err!( + "The OCTET_LENGTH function can only accept strings, but got Int32." + ), + i32, + Int32, + Int32Array + ); + test_function!( + OctetLengthFunc::new(), + &[ColumnarValue::Array(Arc::new(StringArray::from(vec![ + String::from("chars"), + String::from("chars2"), + ])))], + Ok(Some(5)), + i32, + Int32, + Int32Array + ); + test_function!( + OctetLengthFunc::new(), + &[ + ColumnarValue::Scalar(ScalarValue::Utf8(Some(String::from("chars")))), + ColumnarValue::Scalar(ScalarValue::Utf8(Some(String::from("chars")))) + ], + exec_err!("octet_length function requires 1 argument, got 2"), + i32, + Int32, + Int32Array + ); + test_function!( + OctetLengthFunc::new(), + &[ColumnarValue::Scalar(ScalarValue::Utf8(Some( + String::from("chars") + )))], + Ok(Some(5)), + i32, + Int32, + Int32Array + ); + test_function!( + OctetLengthFunc::new(), + &[ColumnarValue::Scalar(ScalarValue::Utf8(Some( + String::from("josé") + )))], + Ok(Some(5)), + i32, + Int32, + Int32Array + ); + test_function!( + OctetLengthFunc::new(), + &[ColumnarValue::Scalar(ScalarValue::Utf8(Some( + String::from("") + )))], + Ok(Some(0)), + i32, + Int32, + Int32Array + ); + test_function!( + OctetLengthFunc::new(), + &[ColumnarValue::Scalar(ScalarValue::Utf8(None))], + Ok(None), + i32, + Int32, + Int32Array + ); + + Ok(()) + } +} diff --git a/datafusion/physical-expr/src/functions.rs b/datafusion/physical-expr/src/functions.rs index d66af3d22a40..2436fa24d4ef 100644 --- a/datafusion/physical-expr/src/functions.rs +++ b/datafusion/physical-expr/src/functions.rs @@ -37,7 +37,7 @@ use crate::{ }; use arrow::{ array::ArrayRef, - compute::kernels::length::{bit_length, length}, + compute::kernels::length::bit_length, datatypes::{DataType, Int32Type, Int64Type, Schema}, }; use arrow_array::Array; @@ -317,7 +317,6 @@ pub fn create_physical_fun( } other => exec_err!("Unsupported data type {other:?} for function left"), }), - BuiltinScalarFunction::Lower => Arc::new(string_expressions::lower), BuiltinScalarFunction::Lpad => Arc::new(|args| match args[0].data_type() { DataType::Utf8 => { let func = invoke_if_unicode_expressions_feature_flag!(lpad, i32, "lpad"); @@ -329,18 +328,6 @@ pub fn create_physical_fun( } other => exec_err!("Unsupported data type {other:?} for function lpad"), }), - BuiltinScalarFunction::OctetLength => Arc::new(|args| match &args[0] { - ColumnarValue::Array(v) => Ok(ColumnarValue::Array(length(v.as_ref())?)), - ColumnarValue::Scalar(v) => match v { - ScalarValue::Utf8(v) => Ok(ColumnarValue::Scalar(ScalarValue::Int32( - v.as_ref().map(|x| x.len() as i32), - ))), - ScalarValue::LargeUtf8(v) => Ok(ColumnarValue::Scalar( - ScalarValue::Int64(v.as_ref().map(|x| x.len() as i64)), - )), - _ => unreachable!(), - }, - }), BuiltinScalarFunction::Repeat => Arc::new(|args| match args[0].data_type() { DataType::Utf8 => { make_scalar_function_inner(string_expressions::repeat::)(args) @@ -1160,31 +1147,6 @@ mod tests { Utf8, StringArray ); - test_function!( - OctetLength, - &[lit("chars")], - Ok(Some(5)), - i32, - Int32, - Int32Array - ); - test_function!( - OctetLength, - &[lit("josé")], - Ok(Some(5)), - i32, - Int32, - Int32Array - ); - test_function!(OctetLength, &[lit("")], Ok(Some(0)), i32, Int32, Int32Array); - test_function!( - OctetLength, - &[lit(ScalarValue::Utf8(None))], - Ok(None), - i32, - Int32, - Int32Array - ); test_function!( Repeat, &[lit("Pg"), lit(ScalarValue::Int64(Some(4))),], diff --git a/datafusion/physical-expr/src/string_expressions.rs b/datafusion/physical-expr/src/string_expressions.rs index 6877fb18ad4f..13e4ce77e0ac 100644 --- a/datafusion/physical-expr/src/string_expressions.rs +++ b/datafusion/physical-expr/src/string_expressions.rs @@ -41,80 +41,6 @@ use datafusion_common::{ }; use datafusion_expr::ColumnarValue; -/// applies a unary expression to `args[0]` that is expected to be downcastable to -/// a `GenericStringArray` and returns a `GenericStringArray` (which may have a different offset) -/// # Errors -/// This function errors when: -/// * the number of arguments is not 1 -/// * the first argument is not castable to a `GenericStringArray` -pub(crate) fn unary_string_function<'a, T, O, F, R>( - args: &[&'a dyn Array], - op: F, - name: &str, -) -> Result> -where - R: AsRef, - O: OffsetSizeTrait, - T: OffsetSizeTrait, - F: Fn(&'a str) -> R, -{ - if args.len() != 1 { - return exec_err!( - "{:?} args were supplied but {} takes exactly one argument", - args.len(), - name - ); - } - - let string_array = as_generic_string_array::(args[0])?; - - // first map is the iterator, second is for the `Option<_>` - Ok(string_array.iter().map(|string| string.map(&op)).collect()) -} - -fn handle<'a, F, R>(args: &'a [ColumnarValue], op: F, name: &str) -> Result -where - R: AsRef, - F: Fn(&'a str) -> R, -{ - match &args[0] { - ColumnarValue::Array(a) => match a.data_type() { - DataType::Utf8 => { - Ok(ColumnarValue::Array(Arc::new(unary_string_function::< - i32, - i32, - _, - _, - >( - &[a.as_ref()], op, name - )?))) - } - DataType::LargeUtf8 => { - Ok(ColumnarValue::Array(Arc::new(unary_string_function::< - i64, - i64, - _, - _, - >( - &[a.as_ref()], op, name - )?))) - } - other => exec_err!("Unsupported data type {other:?} for function {name}"), - }, - ColumnarValue::Scalar(scalar) => match scalar { - ScalarValue::Utf8(a) => { - let result = a.as_ref().map(|x| (op)(x).as_ref().to_string()); - Ok(ColumnarValue::Scalar(ScalarValue::Utf8(result))) - } - ScalarValue::LargeUtf8(a) => { - let result = a.as_ref().map(|x| (op)(x).as_ref().to_string()); - Ok(ColumnarValue::Scalar(ScalarValue::LargeUtf8(result))) - } - other => exec_err!("Unsupported data type {other:?} for function {name}"), - }, - } -} - /// Returns the character with the given code. chr(0) is disallowed because text data types cannot store that character. /// chr(65) = 'A' pub fn chr(args: &[ArrayRef]) -> Result { @@ -319,12 +245,6 @@ pub fn instr(args: &[ArrayRef]) -> Result { } } -/// Converts the string to all lower case. -/// lower('TOM') = 'tom' -pub fn lower(args: &[ColumnarValue]) -> Result { - handle(args, |string| string.to_lowercase(), "lower") -} - /// Repeats string the specified number of times. /// repeat('Pg', 4) = 'PgPgPgPg' pub fn repeat(args: &[ArrayRef]) -> Result { @@ -414,12 +334,6 @@ pub fn ends_with(args: &[ArrayRef]) -> Result { Ok(Arc::new(result) as ArrayRef) } -/// Converts the string to all upper case. -/// upper('tom') = 'TOM' -pub fn upper(args: &[ColumnarValue]) -> Result { - handle(args, |string| string.to_uppercase(), "upper") -} - /// Prints random (v4) uuid values per row /// uuid() = 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11' pub fn uuid(args: &[ColumnarValue]) -> Result { diff --git a/datafusion/proto/proto/datafusion.proto b/datafusion/proto/proto/datafusion.proto index 3724eb9be4ad..e4953283b184 100644 --- a/datafusion/proto/proto/datafusion.proto +++ b/datafusion/proto/proto/datafusion.proto @@ -574,11 +574,11 @@ enum ScalarFunction { InitCap = 30; Left = 31; Lpad = 32; - Lower = 33; + // 33 was Lower // 34 was Ltrim // 35 was MD5 // 36 was NullIf - OctetLength = 37; + // 37 was OctetLength Random = 38; // 39 was RegexpReplace Repeat = 40; diff --git a/datafusion/proto/src/generated/pbjson.rs b/datafusion/proto/src/generated/pbjson.rs index 90b0e22c779d..7cdebdf85944 100644 --- a/datafusion/proto/src/generated/pbjson.rs +++ b/datafusion/proto/src/generated/pbjson.rs @@ -22936,8 +22936,6 @@ impl serde::Serialize for ScalarFunction { Self::InitCap => "InitCap", Self::Left => "Left", Self::Lpad => "Lpad", - Self::Lower => "Lower", - Self::OctetLength => "OctetLength", Self::Random => "Random", Self::Repeat => "Repeat", Self::Replace => "Replace", @@ -23006,8 +23004,6 @@ impl<'de> serde::Deserialize<'de> for ScalarFunction { "InitCap", "Left", "Lpad", - "Lower", - "OctetLength", "Random", "Repeat", "Replace", @@ -23105,8 +23101,6 @@ impl<'de> serde::Deserialize<'de> for ScalarFunction { "InitCap" => Ok(ScalarFunction::InitCap), "Left" => Ok(ScalarFunction::Left), "Lpad" => Ok(ScalarFunction::Lpad), - "Lower" => Ok(ScalarFunction::Lower), - "OctetLength" => Ok(ScalarFunction::OctetLength), "Random" => Ok(ScalarFunction::Random), "Repeat" => Ok(ScalarFunction::Repeat), "Replace" => Ok(ScalarFunction::Replace), diff --git a/datafusion/proto/src/generated/prost.rs b/datafusion/proto/src/generated/prost.rs index 09e2fa07c877..2932bcf6d93f 100644 --- a/datafusion/proto/src/generated/prost.rs +++ b/datafusion/proto/src/generated/prost.rs @@ -2873,11 +2873,11 @@ pub enum ScalarFunction { InitCap = 30, Left = 31, Lpad = 32, - Lower = 33, + /// 33 was Lower /// 34 was Ltrim /// 35 was MD5 /// 36 was NullIf - OctetLength = 37, + /// 37 was OctetLength Random = 38, /// 39 was RegexpReplace Repeat = 40, @@ -3009,8 +3009,6 @@ impl ScalarFunction { ScalarFunction::InitCap => "InitCap", ScalarFunction::Left => "Left", ScalarFunction::Lpad => "Lpad", - ScalarFunction::Lower => "Lower", - ScalarFunction::OctetLength => "OctetLength", ScalarFunction::Random => "Random", ScalarFunction::Repeat => "Repeat", ScalarFunction::Replace => "Replace", @@ -3073,8 +3071,6 @@ impl ScalarFunction { "InitCap" => Some(Self::InitCap), "Left" => Some(Self::Left), "Lpad" => Some(Self::Lpad), - "Lower" => Some(Self::Lower), - "OctetLength" => Some(Self::OctetLength), "Random" => Some(Self::Random), "Repeat" => Some(Self::Repeat), "Replace" => Some(Self::Replace), diff --git a/datafusion/proto/src/logical_plan/from_proto.rs b/datafusion/proto/src/logical_plan/from_proto.rs index fc39df6a815b..d00aeeda462b 100644 --- a/datafusion/proto/src/logical_plan/from_proto.rs +++ b/datafusion/proto/src/logical_plan/from_proto.rs @@ -54,11 +54,11 @@ use datafusion_expr::{ factorial, find_in_set, floor, gcd, initcap, iszero, lcm, left, levenshtein, ln, log, log10, log2, logical_plan::{PlanType, StringifiedPlan}, - lower, lpad, nanvl, octet_length, overlay, pi, power, radians, random, repeat, - replace, reverse, right, round, rpad, signum, sin, sinh, split_part, sqrt, strpos, - substr, substr_index, substring, translate, trunc, uuid, AggregateFunction, Between, - BinaryExpr, BuiltInWindowFunction, BuiltinScalarFunction, Case, Cast, Expr, - GetFieldAccess, GetIndexedField, GroupingSet, + lpad, nanvl, overlay, pi, power, radians, random, repeat, replace, reverse, right, + round, rpad, signum, sin, sinh, split_part, sqrt, strpos, substr, substr_index, + substring, translate, trunc, uuid, AggregateFunction, Between, BinaryExpr, + BuiltInWindowFunction, BuiltinScalarFunction, Case, Cast, Expr, GetFieldAccess, + GetIndexedField, GroupingSet, GroupingSet::GroupingSets, JoinConstraint, JoinType, Like, Operator, TryCast, WindowFrame, WindowFrameBound, WindowFrameUnits, @@ -457,9 +457,7 @@ impl From<&protobuf::ScalarFunction> for BuiltinScalarFunction { ScalarFunction::Ceil => Self::Ceil, ScalarFunction::Round => Self::Round, ScalarFunction::Trunc => Self::Trunc, - ScalarFunction::OctetLength => Self::OctetLength, ScalarFunction::Concat => Self::Concat, - ScalarFunction::Lower => Self::Lower, ScalarFunction::Log2 => Self::Log2, ScalarFunction::Signum => Self::Signum, ScalarFunction::BitLength => Self::BitLength, @@ -1428,12 +1426,6 @@ pub fn parse_expr( ScalarFunction::Signum => { Ok(signum(parse_expr(&args[0], registry, codec)?)) } - ScalarFunction::OctetLength => { - Ok(octet_length(parse_expr(&args[0], registry, codec)?)) - } - ScalarFunction::Lower => { - Ok(lower(parse_expr(&args[0], registry, codec)?)) - } ScalarFunction::BitLength => { Ok(bit_length(parse_expr(&args[0], registry, codec)?)) } diff --git a/datafusion/proto/src/logical_plan/to_proto.rs b/datafusion/proto/src/logical_plan/to_proto.rs index a774444960f3..edb8c4e4eb01 100644 --- a/datafusion/proto/src/logical_plan/to_proto.rs +++ b/datafusion/proto/src/logical_plan/to_proto.rs @@ -1478,9 +1478,7 @@ impl TryFrom<&BuiltinScalarFunction> for protobuf::ScalarFunction { BuiltinScalarFunction::Ceil => Self::Ceil, BuiltinScalarFunction::Round => Self::Round, BuiltinScalarFunction::Trunc => Self::Trunc, - BuiltinScalarFunction::OctetLength => Self::OctetLength, BuiltinScalarFunction::Concat => Self::Concat, - BuiltinScalarFunction::Lower => Self::Lower, BuiltinScalarFunction::Log2 => Self::Log2, BuiltinScalarFunction::Signum => Self::Signum, BuiltinScalarFunction::BitLength => Self::BitLength,