(&self, args: ScalarFunctionArgs)
| 91 | } |
| 92 | |
| 93 | fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> { |
| 94 | let arg = &args.args[0]; |
| 95 | |
| 96 | // Scalar fast path - handle directly without array conversion |
| 97 | if let ColumnarValue::Scalar(scalar) = arg { |
| 98 | return match scalar { |
| 99 | ScalarValue::Utf8(None) |
| 100 | | ScalarValue::LargeUtf8(None) |
| 101 | | ScalarValue::Utf8View(None) => Ok(arg.clone()), |
| 102 | ScalarValue::Utf8(Some(s)) => { |
| 103 | let mut result = String::new(); |
| 104 | initcap_string(s, &mut result); |
| 105 | Ok(ColumnarValue::Scalar(ScalarValue::Utf8(Some(result)))) |
| 106 | } |
| 107 | ScalarValue::LargeUtf8(Some(s)) => { |
| 108 | let mut result = String::new(); |
| 109 | initcap_string(s, &mut result); |
| 110 | Ok(ColumnarValue::Scalar(ScalarValue::LargeUtf8(Some(result)))) |
| 111 | } |
| 112 | ScalarValue::Utf8View(Some(s)) => { |
| 113 | let mut result = String::new(); |
| 114 | initcap_string(s, &mut result); |
| 115 | Ok(ColumnarValue::Scalar(ScalarValue::Utf8View(Some(result)))) |
| 116 | } |
| 117 | other => { |
| 118 | exec_err!( |
| 119 | "Unsupported data type {:?} for function `initcap`", |
| 120 | other.data_type() |
| 121 | ) |
| 122 | } |
| 123 | }; |
| 124 | } |
| 125 | |
| 126 | // Array path |
| 127 | let args = &args.args; |
| 128 | match args[0].data_type() { |
| 129 | DataType::Utf8 => make_scalar_function(initcap::<i32>, vec![])(args), |
| 130 | DataType::LargeUtf8 => make_scalar_function(initcap::<i64>, vec![])(args), |
| 131 | DataType::Utf8View => make_scalar_function(initcap_utf8view, vec![])(args), |
| 132 | other => { |
| 133 | exec_err!("Unsupported data type {other:?} for function `initcap`") |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | fn documentation(&self) -> Option<&Documentation> { |
| 139 | self.doc() |
nothing calls this directly
no test coverage detected