Skip to content

Commit 41bf783

Browse files
committed
Fix fields comparison in CalcitePPLRenameIT
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent f511aa8 commit 41bf783

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLRenameIT.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import java.io.IOException;
1717
import java.util.Arrays;
1818
import java.util.HashSet;
19-
import java.util.List;
2019
import java.util.Set;
2120
import java.util.regex.Matcher;
2221
import java.util.regex.Pattern;
@@ -174,7 +173,7 @@ public void testRenameWithBackticksInAgg() throws IOException {
174173
*/
175174
private static void verifyNotFoundAndInputFields(String actual, String expected) {
176175
String notFoundFieldPattern = "field \\[(.*?)\\] not found";
177-
String inputFieldsPattern = "input fields are:\\s*\\[([^]]+)\\]";
176+
String inputFieldsPattern = "input fields are: \\[(.*?)\\]";
178177
String actualUnfoundField = extractByPattern(actual, notFoundFieldPattern);
179178
String expectedUnfoundField = extractByPattern(expected, notFoundFieldPattern);
180179
// splitIntoSet makes it order-insensitive
@@ -187,16 +186,16 @@ private static void verifyNotFoundAndInputFields(String actual, String expected)
187186
}
188187

189188
/**
190-
* Split a string representation of a list into a HashSet.
191-
* The input string is expected to be in the format: "[item1, item2, item3]"
189+
* Split a string of comma-separated fields into a Set.
192190
*
193-
* @param listString the string representation of the list
191+
* @param str the string representation of the list
194192
* @return a HashSet containing the items from the list
195193
*/
196-
private static HashSet<String> splitIntoSet(String listString) {
197-
List<String> list =
198-
Arrays.stream(listString.strip().substring(1, listString.length() - 1).split(",")).collect(Collectors.toList());
199-
return list.stream().map(String::strip).collect(Collectors.toCollection(HashSet::new));
194+
private static Set<String> splitIntoSet(String str) {
195+
if (str.isEmpty()) {
196+
return new HashSet<>();
197+
}
198+
return Arrays.stream(str.split(",")).map(String::trim).collect(Collectors.toSet());
200199
}
201200

202201
/**

0 commit comments

Comments
 (0)