Skip to content

Commit

Permalink
feat/11953: Support StringView for TRANSLATE() fn
Browse files Browse the repository at this point in the history
Signed-off-by: Devan <devandbenz@gmail.com>
  • Loading branch information
devanbenz committed Aug 13, 2024
1 parent 7a1a23d commit 1087ace
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion datafusion/functions/src/unicode/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ impl TranslateFunc {
use DataType::*;
Self {
signature: Signature::one_of(
vec![Exact(vec![Utf8, Utf8, Utf8])],
vec![
Exact(vec![Utf8View, Utf8, Utf8]),
Exact(vec![Utf8, Utf8, Utf8])
],
Volatility::Immutable,
),
}
Expand All @@ -72,6 +75,7 @@ impl ScalarUDFImpl for TranslateFunc {

fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {
match args[0].data_type() {
DataType::Utf8View => make_scalar_function(translate::<i32>, vec![])(args),
DataType::Utf8 => make_scalar_function(translate::<i32>, vec![])(args),
DataType::LargeUtf8 => make_scalar_function(translate::<i64>, vec![])(args),
other => {
Expand Down
3 changes: 1 addition & 2 deletions datafusion/sqllogictest/test_files/string_view.slt
Original file line number Diff line number Diff line change
Expand Up @@ -895,14 +895,13 @@ logical_plan
02)--TableScan: test projection=[column1_utf8view, column2_utf8view]

## Ensure no casts for TRANSLATE
## TODO file ticket
query TT
EXPLAIN SELECT
TRANSLATE(column1_utf8view, 'foo', 'bar') as c
FROM test;
----
logical_plan
01)Projection: translate(CAST(test.column1_utf8view AS Utf8), Utf8("foo"), Utf8("bar")) AS c
01)Projection: translate(test.column1_utf8view, Utf8("foo"), Utf8("bar")) AS c
02)--TableScan: test projection=[column1_utf8view]

## Ensure no casts for FIND_IN_SET
Expand Down

0 comments on commit 1087ace

Please sign in to comment.