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
@@ -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