Skip to content

Commit 718db9b

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

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

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

Lines changed: 8 additions & 7 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
@@ -190,13 +189,15 @@ private static void verifyNotFoundAndInputFields(String actual, String expected)
190189
* Split a string representation of a list into a HashSet.
191190
* The input string is expected to be in the format: "[item1, item2, item3]"
192191
*
193-
* @param listString the string representation of the list
192+
* @param str the string representation of the list
194193
* @return a HashSet containing the items from the list
195194
*/
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));
195+
private static Set<String> splitIntoSet(String str) {
196+
// Split the string by commas, strip whitespace from each item, and collect into a HashSet
197+
if (str.isEmpty()) {
198+
return new HashSet<>();
199+
}
200+
return Arrays.stream(str.split(",")).map(String::trim).collect(Collectors.toSet());
200201
}
201202

202203
/**

0 commit comments

Comments
 (0)