Skip to content

Commit dfa420e

Browse files
committed
Make CSV test loader to use numbers when there are multivalued numeric fields
1 parent 9896adf commit dfa420e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ public class CsvTestsDataLoader {
217217
CITY_BOUNDARIES_ENRICH,
218218
CITY_AIRPORTS_ENRICH
219219
);
220+
public static final String NUMERIC_REGEX = "-?\\d+(\\.\\d+)?";
220221

221222
/**
222223
* <p>
@@ -639,7 +640,8 @@ private static void loadCsvData(RestClient client, String indexName, URL resourc
639640

640641
private static String quoteIfNecessary(String value) {
641642
boolean isQuoted = (value.startsWith("\"") && value.endsWith("\"")) || (value.startsWith("{") && value.endsWith("}"));
642-
return isQuoted ? value : "\"" + value + "\"";
643+
boolean isNumeric = value.matches(NUMERIC_REGEX);
644+
return isQuoted || isNumeric ? value : "\"" + value + "\"";
643645
}
644646

645647
private static void sendBulkRequest(String indexName, StringBuilder builder, RestClient client, Logger logger, List<String> failures)

0 commit comments

Comments
 (0)