Skip to content

Commit 66536ef

Browse files
committed
Test from field
1 parent 2244bd5 commit 66536ef

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-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
@@ -133,6 +133,7 @@ public class CsvTestsDataLoader {
133133
private static final TestDataset ADDRESSES = new TestDataset("addresses");
134134
private static final TestDataset BOOKS = new TestDataset("books").withSetting("books-settings.json");
135135
private static final TestDataset SEMANTIC_TEXT = new TestDataset("semantic_text").withInferenceEndpoint(true);
136+
private static final TestDataset LOGS = new TestDataset("logs");
136137

137138
public static final Map<String, TestDataset> CSV_DATASET_MAP = Map.ofEntries(
138139
Map.entry(EMPLOYEES.indexName, EMPLOYEES),
@@ -182,7 +183,8 @@ public class CsvTestsDataLoader {
182183
Map.entry(DISTANCES.indexName, DISTANCES),
183184
Map.entry(ADDRESSES.indexName, ADDRESSES),
184185
Map.entry(BOOKS.indexName, BOOKS),
185-
Map.entry(SEMANTIC_TEXT.indexName, SEMANTIC_TEXT)
186+
Map.entry(SEMANTIC_TEXT.indexName, SEMANTIC_TEXT),
187+
Map.entry(LOGS.indexName, LOGS)
186188
);
187189

188190
private static final EnrichConfig LANGUAGES_ENRICH = new EnrichConfig("languages_policy", "enrich-policy-languages.json");
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@timestamp:date ,system:keyword,message:keyword
2+
2023-10-23T13:55:01.543Z, ping,Pinging 192.168.86.046
3+
2023-10-23T13:55:01.544Z, cron,Running cats
4+
2023-10-23T13:55:01.545Z, java,Doing java stuff for 192.168.86.038
5+
2023-10-23T13:55:01.546Z, java,More java stuff

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,25 @@ s:keyword | ip:ip
297297
// end::to_ip_leading_zeros_octal-result[]
298298
;
299299

300+
convertFromStringFancy
301+
FROM logs
302+
| KEEP @timestamp, system, message
303+
| EVAL client = CASE(
304+
system == "ping",
305+
TO_IP(REPLACE(message, "Pinging ", ""), {"leading_zeros": "octal"}),
306+
system == "java" AND STARTS_WITH(message, "Doing java stuff for "),
307+
TO_IP(REPLACE(message, "Doing java stuff for ", ""), {"leading_zeros": "decimal"}))
308+
| SORT @timestamp
309+
| LIMIT 4
310+
;
311+
312+
@timestamp:date |system:keyword|message:keyword |client:ip
313+
2023-10-23T13:55:01.543Z| ping|Pinging 192.168.86.046 |192.168.86.38
314+
2023-10-23T13:55:01.544Z| cron|Running cats |null
315+
2023-10-23T13:55:01.545Z| java|Doing java stuff for 192.168.86.038|192.168.86.38
316+
2023-10-23T13:55:01.546Z| java|More java stuff |null
317+
;
318+
300319
toIpInAgg
301320
ROW s = "1.1.1.1" | STATS COUNT(*) BY ip = TO_IP(s)
302321
;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"properties" : {
3+
"@timestamp" : {
4+
"type" : "date"
5+
},
6+
"system" : {
7+
"type" : "keyword"
8+
},
9+
"message" : {
10+
"type" : "keyword"
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)