Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(isthmus): support for replace #224

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class FunctionMappings {
s(SqlStdOperatorTable.FLOOR, "floor"),
s(SqlStdOperatorTable.ROUND, "round"),
s(SqlStdOperatorTable.LIKE),
s(SqlStdOperatorTable.REPLACE, "replace"),
s(SqlStdOperatorTable.SUBSTRING, "substring"),
s(SqlStdOperatorTable.CONCAT, "concat"),
s(SqlStdOperatorTable.CHAR_LENGTH, "char_length"),
Expand Down
11 changes: 11 additions & 0 deletions isthmus/src/test/java/io/substrait/isthmus/StringFunctionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
public class StringFunctionTest extends PlanTestBase {

static List<String> CREATES = List.of("CREATE TABLE strings (c16 CHAR(16), vc32 VARCHAR(32))");
static List<String> REPLACE_CREATES =
List.of(
"CREATE TABLE replace_strings (c16 CHAR(16), vc32 VARCHAR(32), replace_from VARCHAR(16), replace_to VARCHAR(16))");

@ParameterizedTest
@ValueSource(strings = {"c16", "vc32"})
Expand Down Expand Up @@ -36,6 +39,14 @@ void upper(String column) throws Exception {
assertSqlSubstraitRelRoundTrip(query, CREATES);
}

@ParameterizedTest
@ValueSource(strings = {"c16", "vc32"})
void replace(String column) throws Exception {
String query =
String.format("SELECT replace(%s, replace_from, replace_to) FROM replace_strings", column);
assertSqlSubstraitRelRoundTrip(query, REPLACE_CREATES);
}

@ParameterizedTest
@ValueSource(strings = {"c16", "vc32"})
void substringWith1Param(String column) throws Exception {
Expand Down
Loading