MCPcopy Create free account
hub / github.com/apache/datafusion / invoke_with_args

Method invoke_with_args

datafusion/functions/src/unicode/initcap.rs:93–136  ·  view source on GitHub ↗
(&self, args: ScalarFunctionArgs)

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
initcap_stringFunction · 0.85
make_scalar_functionFunction · 0.50
cloneMethod · 0.45
data_typeMethod · 0.45

Tested by

no test coverage detected