Skip to content

Commit

Permalink
add aliases to match substrait "substring" and "string_split"
Browse files Browse the repository at this point in the history
  • Loading branch information
Blizzara committed Jul 4, 2024
1 parent 3421b52 commit 75f3912
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datafusion/functions-array/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl StringToArray {
],
Volatility::Immutable,
),
aliases: vec![String::from("string_to_list")],
aliases: vec![String::from("string_to_list"), String::from("string_split")],
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/unicode/substr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::utils::{make_scalar_function, utf8_to_str_type};
#[derive(Debug)]
pub struct SubstrFunc {
signature: Signature,
aliases: Vec<String>,
}

impl Default for SubstrFunc {
Expand All @@ -53,6 +54,7 @@ impl SubstrFunc {
],
Volatility::Immutable,
),
aliases: vec![String::from("substring")],
}
}
}
Expand All @@ -66,6 +68,10 @@ impl ScalarUDFImpl for SubstrFunc {
"substr"
}

fn aliases(&self) -> &[String] {
&self.aliases
}

fn signature(&self) -> &Signature {
&self.signature
}
Expand Down
13 changes: 13 additions & 0 deletions datafusion/sqllogictest/test_files/array.slt
Original file line number Diff line number Diff line change
Expand Up @@ -6471,6 +6471,19 @@ select string_to_list(e, 'm') from values;
[adipiscing]
NULL

query ?
select string_split(e, 'm') from values;
----
[Lore, ]
[ipsu, ]
[dolor]
[sit]
[a, et]
[,]
[consectetur]
[adipiscing]
NULL

# array_resize scalar function #1
query ?
select array_resize(make_array(1, 2, 3), 1);
Expand Down
6 changes: 6 additions & 0 deletions datafusion/sqllogictest/test_files/functions.slt
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ SELECT substr('alphabet', 3)
----
phabet

# Alias for substr
query T
SELECT substring('alphabet', 3)
----
phabet

query T
SELECT substr('alphabet', 30)
----
Expand Down

0 comments on commit 75f3912

Please sign in to comment.