Skip to content

Commit

Permalink
test: add a roundtrip test to REPLACE()
Browse files Browse the repository at this point in the history
  • Loading branch information
bvolpato committed Feb 6, 2024
1 parent 05eba1d commit a44e5f4
Showing 1 changed file with 11 additions and 0 deletions.
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

0 comments on commit a44e5f4

Please sign in to comment.