Skip to content

Commit e85d048

Browse files
committed
review comments
1 parent 8a90d88 commit e85d048

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,23 @@ emp_no:integer | a:keyword | b:keyword
291291
;
292292

293293
multiPatterns
294+
required_capability: grok_multi_pattern
294295
row text = "XYZ extractme" | grok text "ABC %{WORD:foo}","XYZ %{WORD:bar}" | keep foo, bar;
295296

296297
foo:keyword | bar:keyword
297298
null | extractme
298299
;
299300

301+
multiPatterns2
302+
required_capability: grok_multi_pattern
303+
from employees | sort emp_no asc | eval full_name = concat(first_name, " ", last_name) | grok full_name "Georgi %{WORD:georgis_last_name}", "%{WORD:first_name} %{WORD:last_name}" | keep full_name, first_name, last_name, georgis_last_name | limit 3;
304+
305+
full_name:keyword | first_name:keyword | last_name:keyword | georgis_last_name:keyword
306+
Georgi Facello | null | null | Facello
307+
Bezalel Simmel | Bezalel | Simmel | null
308+
Parto Bamford | Parto | Bamford | null
309+
;
310+
300311
overwriteInputName
301312
required_capability: grok_dissect_masking
302313
row text = "123 abc", int = 5 | sort int asc | grok text "%{NUMBER:text:int} %{WORD:description}" | keep text, int, description;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,11 @@ public enum Cap {
15161516
*/
15171517
FIX_FILTER_ORDINALS,
15181518

1519+
/**
1520+
* Allow multiple patterns for GROK command
1521+
*/
1522+
GROK_MULTI_PATTERN,
1523+
15191524
;
15201525

15211526
private final boolean enabled;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ public PlanFactory visitEvalCommand(EsqlBaseParser.EvalCommandContext ctx) {
216216
public PlanFactory visitGrokCommand(EsqlBaseParser.GrokCommandContext ctx) {
217217
return p -> {
218218
Source source = source(ctx);
219+
FoldContext patternFoldContext = FoldContext.small(); /* TODO remove me */
219220
List<String> patterns = ctx.string()
220221
.stream()
221-
.map(stringContext -> BytesRefs.toString(visitString(stringContext).fold(FoldContext.small() /* TODO remove me */)))
222+
.map(stringContext -> BytesRefs.toString(visitString(stringContext).fold(patternFoldContext)))
222223
.toList();
223224

224225
String combinePattern = org.elasticsearch.grok.Grok.combinePatterns(patterns);

0 commit comments

Comments
 (0)