Skip to content

Commit 657f1c0

Browse files
committed
Possible solution with passing tests
But it seems we should not need to divide by 1M at this point and rather deal with this deeper in the stack, where there is ns specific support.
1 parent 9c13833 commit 657f1c0

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/lookup/QueryList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public static QueryList dateNanosTermQueryList(MappedFieldType field, SearchExec
219219
null,
220220
field instanceof RangeFieldMapper.RangeFieldType rangeFieldType
221221
? offset -> rangeFieldType.dateTimeFormatter().formatNanos(block.getLong(offset))
222-
: block::getLong
222+
: i -> block.getLong(i) / 1000_000
223223
);
224224
}
225225

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public class CsvTestsDataLoader {
8383
private static final TestDataset SAMPLE_DATA_TS_NANOS = SAMPLE_DATA.withIndex("sample_data_ts_nanos")
8484
.withData("sample_data_ts_nanos.csv")
8585
.withTypeMapping(Map.of("@timestamp", "date_nanos"));
86+
private static final TestDataset SAMPLE_DATA_TS_NANOS_LOOKUP = SAMPLE_DATA_TS_NANOS.withIndex("sample_data_ts_nanos_lookup")
87+
.withSetting("lookup-settings.json");
8688
private static final TestDataset MISSING_IP_SAMPLE_DATA = new TestDataset("missing_ip_sample_data");
8789
private static final TestDataset SAMPLE_DATA_PARTIAL_MAPPING = new TestDataset("partial_mapping_sample_data");
8890
private static final TestDataset SAMPLE_DATA_NO_MAPPING = new TestDataset(
@@ -162,6 +164,7 @@ public class CsvTestsDataLoader {
162164
Map.entry(SAMPLE_DATA_STR.indexName, SAMPLE_DATA_STR),
163165
Map.entry(SAMPLE_DATA_TS_LONG.indexName, SAMPLE_DATA_TS_LONG),
164166
Map.entry(SAMPLE_DATA_TS_NANOS.indexName, SAMPLE_DATA_TS_NANOS),
167+
Map.entry(SAMPLE_DATA_TS_NANOS_LOOKUP.indexName, SAMPLE_DATA_TS_NANOS_LOOKUP),
165168
Map.entry(MISSING_IP_SAMPLE_DATA.indexName, MISSING_IP_SAMPLE_DATA),
166169
Map.entry(CLIENT_IPS.indexName, CLIENT_IPS),
167170
Map.entry(CLIENT_IPS_LOOKUP.indexName, CLIENT_IPS_LOOKUP),

x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,3 +1742,26 @@ max:long
17421742
3450233
17431743
8268153
17441744
;
1745+
1746+
###############################################
1747+
# LOOKUP JOIN on date_nanos field
1748+
###############################################
1749+
1750+
joinDateNanos
1751+
required_capability: join_lookup_v12
1752+
required_capability: date_nanos_type
1753+
1754+
FROM sample_data_ts_nanos
1755+
| LOOKUP JOIN sample_data_ts_nanos_lookup ON @timestamp
1756+
| KEEP @timestamp, client_ip, event_duration, message
1757+
;
1758+
1759+
@timestamp:date_nanos | client_ip:ip | event_duration:long | message:keyword
1760+
2023-10-23T13:55:01.543123456Z | 172.21.3.15 | 1756467 | Connected to 10.1.0.1
1761+
2023-10-23T13:53:55.832123456Z | 172.21.3.15 | 5033755 | Connection error
1762+
2023-10-23T13:52:55.015123456Z | 172.21.3.15 | 8268153 | Connection error
1763+
2023-10-23T13:51:54.732123456Z | 172.21.3.15 | 725448 | Connection error
1764+
2023-10-23T13:33:34.937123456Z | 172.21.0.5 | 1232382 | Disconnected
1765+
2023-10-23T12:27:28.948123456Z | 172.21.2.113 | 2764889 | Connected to 10.1.0.2
1766+
2023-10-23T12:15:03.360123456Z | 172.21.2.162 | 3450233 | Connected to 10.1.0.3
1767+
;

0 commit comments

Comments
 (0)