Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuqi-lucas committed Nov 1, 2024
1 parent 43973fe commit 533fbdd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,8 @@ public static List<String> split(String s, String delimiter) {

/** SQL {@code SPLIT_PART(string, string, int)} function. */
public static String splitPart(String s, String delimiter, int n) {
if (s == null || delimiter == null || delimiter.isEmpty() || n == 0) {
return null;
if (s == null || s == "" || delimiter == null || delimiter.isEmpty() || n == 0) {

Check failure on line 920 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 23)

[Task :core:checkstyleMain] [StringLiteralEquality] Literal Strings should be compared using equals(), not '=='.

Check failure on line 920 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 21)

[Task :core:checkstyleMain] [StringLiteralEquality] Literal Strings should be compared using equals(), not '=='.

Check failure on line 920 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 11, Pacific/Chatham Timezone)

[Task :core:checkstyleMain] [StringLiteralEquality] Literal Strings should be compared using equals(), not '=='.

Check failure on line 920 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 8, oldest Guava, America/New_York Timezone)

[Task :core:checkstyleMain] [StringLiteralEquality] Literal Strings should be compared using equals(), not '=='.

Check failure on line 920 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 11, Avatica main)

[Task :core:checkstyleMain] [StringLiteralEquality] Literal Strings should be compared using equals(), not '=='.

Check failure on line 920 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 17)

[Task :core:checkstyleMain] [StringLiteralEquality] Literal Strings should be compared using equals(), not '=='.

Check failure on line 920 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 8, latest Guava, America/New_York Timezone)

[Task :core:checkstyleMain] [StringLiteralEquality] Literal Strings should be compared using equals(), not '=='.
return "";
}

String[] parts = s.split(Pattern.quote(delimiter), -1);
Expand All @@ -929,7 +929,7 @@ public static String splitPart(String s, String delimiter, int n) {
}

if (n <= 0 || n > partCount) {
return null;
return "";
}

return parts[n - 1];
Expand Down
12 changes: 6 additions & 6 deletions core/src/test/java/org/apache/calcite/test/SqlFunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1061,14 +1061,14 @@ private void checkCeil(int x, int y, int result) {

assertThat(SqlFunctions.splitPart("abc,,ghi", ",", 2), is(""));
assertThat(SqlFunctions.splitPart("", ",", 1), is(""));
assertThat(SqlFunctions.splitPart("abc", "", 1), is(nullValue()));
assertThat(SqlFunctions.splitPart("abc", "", 1), is(""));

assertThat(SqlFunctions.splitPart(null, ",", 1), is(nullValue()));
assertThat(SqlFunctions.splitPart("abc,def", null, 1), is(nullValue()));
assertThat(SqlFunctions.splitPart("abc,def", ",", 0), is(nullValue()));
assertThat(SqlFunctions.splitPart(null, ",", 1), is(""));
assertThat(SqlFunctions.splitPart("abc,def", null, 1), is(""));
assertThat(SqlFunctions.splitPart("abc,def", ",", 0), is(""));

assertThat(SqlFunctions.splitPart("abc,def", ",", 3), is(nullValue()));
assertThat(SqlFunctions.splitPart("abc,def", ",", -3), is(nullValue()));
assertThat(SqlFunctions.splitPart("abc,def", ",", 3), is(""));
assertThat(SqlFunctions.splitPart("abc,def", ",", -3), is(""));
}

@Test void testByteString() {
Expand Down

0 comments on commit 533fbdd

Please sign in to comment.