Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
import org.elasticsearch.common.network.InetAddresses;
import org.elasticsearch.common.time.DateFormatters;
import org.elasticsearch.common.time.DateUtils;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.compute.data.Block;
import org.elasticsearch.compute.data.BlockFactory;
Expand Down Expand Up @@ -471,7 +472,7 @@ public enum Type {
return null;
}
Instant parsed = DateFormatters.from(ISO_DATE_WITH_NANOS.parse(x)).toInstant();
return parsed.getEpochSecond() * 1_000_000_000 + parsed.getNano();
return DateUtils.toLong(parsed);
}, (l, r) -> l instanceof Long maybeIP ? maybeIP.compareTo((Long) r) : l.toString().compareTo(r.toString()), Long.class),
BOOLEAN(Booleans::parseBoolean, Boolean.class),
GEO_POINT(x -> x == null ? null : GEO.wktToWkb(x), BytesRef.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public class CsvTestsDataLoader {
private static final TestsDataset SAMPLE_DATA_TS_LONG = SAMPLE_DATA.withIndex("sample_data_ts_long")
.withData("sample_data_ts_long.csv")
.withTypeMapping(Map.of("@timestamp", "long"));
private static final TestsDataset SAMPLE_DATA_TS_NANOS = SAMPLE_DATA.withIndex("sample_data_ts_nanos")
.withData("sample_data_ts_nanos.csv")
.withTypeMapping(Map.of("@timestamp", "date_nanos"));
private static final TestsDataset MISSING_IP_SAMPLE_DATA = new TestsDataset("missing_ip_sample_data");
private static final TestsDataset CLIENT_IPS = new TestsDataset("clientips");
private static final TestsDataset CLIENT_CIDR = new TestsDataset("client_cidr");
Expand Down Expand Up @@ -101,6 +104,7 @@ public class CsvTestsDataLoader {
Map.entry(ALERTS.indexName, ALERTS),
Map.entry(SAMPLE_DATA_STR.indexName, SAMPLE_DATA_STR),
Map.entry(SAMPLE_DATA_TS_LONG.indexName, SAMPLE_DATA_TS_LONG),
Map.entry(SAMPLE_DATA_TS_NANOS.indexName, SAMPLE_DATA_TS_NANOS),
Map.entry(MISSING_IP_SAMPLE_DATA.indexName, MISSING_IP_SAMPLE_DATA),
Map.entry(CLIENT_IPS.indexName, CLIENT_IPS),
Map.entry(CLIENT_CIDR.indexName, CLIENT_CIDR),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@timestamp:date_nanos,client_ip:ip,event_duration:long,message:keyword
2023-10-23T13:55:01.543123456Z,172.21.3.15,1756467,Connected to 10.1.0.1
2023-10-23T13:53:55.832123456Z,172.21.3.15,5033755,Connection error
2023-10-23T13:52:55.015123456Z,172.21.3.15,8268153,Connection error
2023-10-23T13:51:54.732123456Z,172.21.3.15,725448,Connection error
2023-10-23T13:33:34.937123456Z,172.21.0.5,1232382,Disconnected
2023-10-23T12:27:28.948123456Z,172.21.2.113,2764889,Connected to 10.1.0.2
2023-10-23T12:15:03.360123456Z,172.21.2.162,3450233,Connected to 10.1.0.3
Loading