1616import java .io .IOException ;
1717import java .util .Arrays ;
1818import java .util .HashSet ;
19- import java .util .List ;
2019import java .util .Set ;
2120import java .util .regex .Matcher ;
2221import 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