forked from substrait-io/substrait-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(isthmus): support for char_length (substrait-io#212)
test: added tests for string functions
- Loading branch information
1 parent
9abf1a0
commit ba8ccfd
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
isthmus/src/test/java/io/substrait/isthmus/StringFunctionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.substrait.isthmus; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
public class StringFunctionTest extends PlanTestBase { | ||
|
||
static List<String> CREATES = List.of("CREATE TABLE strings (c16 CHAR(16), vc32 VARCHAR(32))"); | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"c16", "vc32"}) | ||
void charLength(String column) throws Exception { | ||
String query = String.format("SELECT char_length(%s) FROM strings", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"vc32"}) | ||
void concat(String column) throws Exception { | ||
String query = String.format("SELECT %s || %s FROM strings", column, column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"c16", "vc32"}) | ||
void lower(String column) throws Exception { | ||
String query = String.format("SELECT lower(%s) FROM strings", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"c16", "vc32"}) | ||
void upper(String column) throws Exception { | ||
String query = String.format("SELECT upper(%s) FROM strings", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"c16", "vc32"}) | ||
void substringWith1Param(String column) throws Exception { | ||
String query = String.format("SELECT substring(%s, 42) FROM strings", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"c16", "vc32"}) | ||
void substringWith2Params(String column) throws Exception { | ||
String query = String.format("SELECT substring(%s, 42, 5) FROM strings", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"c16", "vc32"}) | ||
void substringFrom(String column) throws Exception { | ||
String query = String.format("SELECT substring(%s FROM 42) FROM strings", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"c16", "vc32"}) | ||
void substringFromFor(String column) throws Exception { | ||
String query = String.format("SELECT substring(%s FROM 42 FOR 5) FROM strings", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
} |