jayzhan211 commented on code in PR #13420:
URL: https://github.com/apache/datafusion/pull/13420#discussion_r1845264760
##########
datafusion/sqllogictest/test_files/scalar.slt:
##########
@@ -1864,10 +1864,10 @@ query TT
EXPLAIN SELECT letter, letter = LEFT(letter2, 1) FROM simple_string;
----
logical_plan
-01)Projection: simple_string.letter, simple_string.letter =
left(simple_string.letter2, Int64(1))
+01)Projection: simple_string.letter, simple_string.letter =
left(CAST(simple_string.letter2 AS Utf8View), Int64(1))
Review Comment:
Check the `fn invoke` function for each function.
For example `lpad`
```rust
fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {
match args[0].data_type() {
Utf8 | Utf8View => make_scalar_function(lpad::<i32>,
vec![])(args),
LargeUtf8 => make_scalar_function(lpad::<i64>, vec![])(args),
other => exec_err!("Unsupported data type {other:?} for function
lpad"),
}
}
```
It support utf8/utf8view/largeutf8, but not dictionary. You can rewrite it
like this
```rust
fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {
invoke_inner(args, &args[0].data_type())
}
fn invoke_inner(args: &[ColumnarValue], data_type: &DataType) ->
Result<ColumnarValue> {
match data_type {
DataType::Dictionary(_, v) => {
invoke_inner(args, v.as_ref())
}
Utf8 | Utf8View => make_scalar_function(lpad::<i32>, vec![])(args),
LargeUtf8 => make_scalar_function(lpad::<i64>, vec![])(args),
other => exec_err!("Unsupported data type {other:?} for function
lpad"),
}
}
```
--
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]