Skip to content
Merged
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 @@ -2465,8 +2465,29 @@ by fn2(f3, {"option1":["string1","string2"],"option2":[1,2,3],"option3":2.0,"opt
assertEquals(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields());
UnresolvedRelation ur = as(dissect.child(), UnresolvedRelation.class);
assertEquals(ur, relation("test"));
}

public void testNamedFunctionArgumentInMapWithNamedParameters() {
// map entry values provided in named parameter, arrays are not supported by named parameters yet
assumeTrue(
"named parameters for identifiers and patterns require snapshot build",
EsqlCapabilities.Cap.NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES_SIMPLIFIED_SYNTAX.isEnabled()
);
LinkedHashMap<String, Object> expectedMap1 = new LinkedHashMap<>(4);
expectedMap1.put("option1", "string");
expectedMap1.put("option2", 1);
expectedMap1.put("option3", List.of(2.0, 3.0, 4.0));
expectedMap1.put("option4", List.of(true, false));
LinkedHashMap<String, Object> expectedMap2 = new LinkedHashMap<>(4);
expectedMap2.put("option1", List.of("string1", "string2"));
expectedMap2.put("option2", List.of(1, 2, 3));
expectedMap2.put("option3", 2.0);
expectedMap2.put("option4", true);
LinkedHashMap<String, Object> expectedMap3 = new LinkedHashMap<>(4);
expectedMap3.put("option1", "string");
expectedMap3.put("option2", 2.0);
expectedMap3.put("option3", List.of(1, 2, 3));
expectedMap3.put("option4", List.of(true, false));
assertEquals(
new Filter(
EMPTY,
Expand Down Expand Up @@ -2564,7 +2585,7 @@ by fn2(f3, {"option1":["string1","string2"],"option2":[1,2,3],"option3":2.0,"opt
)
);

plan = statement(
LogicalPlan plan = statement(
"""
from test
| dissect ?fn1(?n1, ?n2, {"option1":?n3,"option2":?n4,"option3":[2.0,3.0,4.0],"option4":[true,false]}) "%{bar}"
Expand All @@ -2584,16 +2605,16 @@ by fn2(f3, {"option1":["string1","string2"],"option2":[1,2,3],"option3":2.0,"opt
)
)
);
grok = as(plan, Grok.class);
Grok grok = as(plan, Grok.class);
assertEquals(function("fn2", List.of(attribute("f3"), mapExpression(expectedMap2))), grok.input());
assertEquals("%{WORD:foo}", grok.parser().pattern());
assertEquals(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields());
dissect = as(grok.child(), Dissect.class);
Dissect dissect = as(grok.child(), Dissect.class);
assertEquals(function("fn1", List.of(attribute("f1"), attribute("f2"), mapExpression(expectedMap1))), dissect.input());
assertEquals("%{bar}", dissect.parser().pattern());
assertEquals("", dissect.parser().appendSeparator());
assertEquals(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields());
ur = as(dissect.child(), UnresolvedRelation.class);
UnresolvedRelation ur = as(dissect.child(), UnresolvedRelation.class);
assertEquals(ur, relation("test"));
}

Expand Down Expand Up @@ -2859,6 +2880,10 @@ public void testNamedFunctionArgumentInInvalidPositions() {
}

public void testNamedFunctionArgumentWithUnsupportedNamedParameterTypes() {
assumeTrue(
"named parameters for identifiers and patterns require snapshot build",
EsqlCapabilities.Cap.NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES_SIMPLIFIED_SYNTAX.isEnabled()
);
Map<String, String> commands = Map.ofEntries(
Map.entry("eval x = {}", "29"),
Map.entry("where {}", "26"),
Expand Down