Skip to content

Commit 8e9b280

Browse files
committed
Make CSV test loader to use numbers when there are multivalued numeric fields
1 parent fb2a3c7 commit 8e9b280

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
@@ -233,6 +233,7 @@ public class CsvTestsDataLoader {
233233
CITY_BOUNDARIES_ENRICH,
234234
CITY_AIRPORTS_ENRICH
235235
);
236+
public static final String NUMERIC_REGEX = "-?\\d+(\\.\\d+)?";
236237

237238
/**
238239
* <p>
@@ -658,7 +659,8 @@ private static void loadCsvData(RestClient client, String indexName, URL resourc
658659

659660
private static String quoteIfNecessary(String value) {
660661
boolean isQuoted = (value.startsWith("\"") && value.endsWith("\"")) || (value.startsWith("{") && value.endsWith("}"));
661-
return isQuoted ? value : "\"" + value + "\"";
662+
boolean isNumeric = value.matches(NUMERIC_REGEX);
663+
return isQuoted || isNumeric ? value : "\"" + value + "\"";
662664
}
663665

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

0 commit comments

Comments
 (0)