-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Initial support for unmapped fields #119886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 27 commits
fa3dd20
c2b0d9c
7b33f15
a105f0a
0ca5e79
bf309fb
0b72c89
c046112
aca3796
dacc8f6
f71a586
2ba5935
c22b9d4
f5c77fa
d6afb24
25f0c53
165ad16
9d85915
d0959ea
d68a0ca
a12aa82
f02fd43
a8d9372
fcd4663
be4bbfd
b84ff2c
a0e1840
0b4132e
b05b327
3f9faef
903f6fa
85b84f5
400f473
fb09120
0d9b280
d7ce623
0f01ebe
5c2c7d7
af26d5f
faef67a
1204791
22569b8
a9f4a0b
8f3c235
7d07d1a
697989c
c0fe85e
ab9bfdf
5c1c2be
9805f12
d5dc662
ef56e8a
13b3dff
088a622
ea8567b
9c466e4
1fb5cb4
8017c78
4f6f6a1
971b869
ef94c52
c9fdc92
b46cb9d
b5da964
7a48277
dcc518c
770ea6f
97399fc
e32a446
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 119886 | ||
summary: Initial support for unmapped fields | ||
area: ES|QL | ||
type: feature | ||
issues: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.esql.core.type; | ||
|
||
import org.elasticsearch.common.io.stream.StreamInput; | ||
|
||
import java.io.IOException; | ||
|
||
/** Information about a field in an ES index that may not mapped. If it is unmapped, it should be loaded from source directly. */ | ||
public class PotentiallyUnmappedKeywordEsField extends KeywordEsField { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The field will be unmapped in at least one index hence its potential has been realized :) and the class can be simply called UnmappedKeywordEsField There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason it is "potentially" unmapped is that it might be mapped in some fields. I've added a comment to try to better explain this. |
||
public PotentiallyUnmappedKeywordEsField(String name) { | ||
super(name); | ||
} | ||
|
||
public PotentiallyUnmappedKeywordEsField(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
public String getWriteableName() { | ||
return "PotentiallyUnmappedKeywordEsField"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,9 @@ public static Tuple<Version, Version> skipVersionRange(String testName, String i | |
return null; | ||
} | ||
|
||
public static Tuple<Page, List<String>> loadPageFromCsv(URL source, Map<String, String> typeMapping) throws Exception { | ||
public record PageColumn(String name, DataType dataType) {} | ||
|
||
|
||
public static Tuple<Page, List<PageColumn>> loadPageFromCsv(URL source, Map<String, String> typeMapping) throws Exception { | ||
|
||
record CsvColumn(String name, Type type, BuilderWrapper builderWrapper) implements Releasable { | ||
void append(String stringValue) { | ||
|
@@ -230,13 +232,13 @@ public void close() { | |
lineNumber++; | ||
} | ||
} | ||
var columnNames = new ArrayList<String>(columns.length); | ||
var pageColumns = new ArrayList<PageColumn>(columns.length); | ||
try { | ||
var blocks = Arrays.stream(columns) | ||
.peek(b -> columnNames.add(b.name)) | ||
.peek(b -> pageColumns.add(new PageColumn(b.name, DataType.fromTypeName(b.type.name())))) | ||
.map(b -> b.builderWrapper.builder().build()) | ||
.toArray(Block[]::new); | ||
return new Tuple<>(new Page(blocks), columnNames); | ||
return new Tuple<>(new Page(blocks), pageColumns); | ||
} finally { | ||
Releasables.closeExpectNoException(columns); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@timestamp:date,client_ip:ip,event_duration:long,message:keyword,unmapped_message:keyword,unmapped_event_duration:keyword | ||
2024-10-23T13:55:01.543Z,173.21.3.15,1756466,Connected to 10.1.0.1!,Disconnected from 10.1.0.1,1756468 | ||
2024-10-23T13:53:55.832Z,173.21.3.15,5033754,Connection error?,Disconnection error,5033756 | ||
2024-10-23T13:52:55.015Z,173.21.3.15,8268152,Connection error?,Disconnection error,8268154 | ||
2024-10-23T13:51:54.732Z,173.21.3.15,725447,Connection error?,Disconnection error,725449 | ||
2024-10-23T13:33:34.937Z,173.21.0.5,1232381,42,43,1232383 | ||
2024-10-23T12:27:28.948Z,173.21.2.113,2764888,Connected to 10.1.0.2!,Disconnected from 10.1.0.2,2764890 | ||
2024-10-23T12:15:03.360Z,173.21.2.162,3450232,Connected to 10.1.0.3!,Disconnected from 10.1.0.3,3450234 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"dynamic": "false", | ||
"properties": {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"dynamic": "false", | ||
"properties": { | ||
"@timestamp": { | ||
"type": "date" | ||
} | ||
}, | ||
"_source": { | ||
"excludes": [ | ||
"message" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"dynamic": "false", | ||
"properties": { | ||
"@timestamp": { | ||
"type": "date" | ||
} | ||
}, | ||
"_source": { | ||
"enabled": false | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"dynamic": "false", | ||
"properties": { | ||
"@timestamp": { | ||
"type": "date" | ||
}, | ||
"client_ip": { | ||
"type": "ip" | ||
}, | ||
"event_duration": { | ||
"type": "long" | ||
}, | ||
"message": { | ||
"type": "keyword" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, format this javadoc properly. And add a bit more details. For example, what does "unmapped" mean? There are many situations (ES mapping particularities) where a field is unmapped, but it can be loaded from "somewhere".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You make it sound as if a one-line javadoc isn't a valid javadoc 😉. Done.