Skip to content

Commit 1cab96f

Browse files
committed
Change wording inm error message function named arguments to named parameters since it has a broader usage.
1 parent 2490d7e commit 1cab96f

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ private BitSet gatherPreAnalysisMetrics(LogicalPlan plan, BitSet b) {
14051405
private static class ImplicitCasting extends ParameterizedRule<LogicalPlan, LogicalPlan, AnalyzerContext> {
14061406
@Override
14071407
public LogicalPlan apply(LogicalPlan plan, AnalyzerContext context) {
1408-
// do implicit casting for function arguments
1408+
// do implicit casting for named parameters
14091409
return plan.transformExpressionsUp(
14101410
org.elasticsearch.xpack.esql.core.expression.function.Function.class,
14111411
e -> ImplicitCasting.cast(e, context.functionRegistry().snapshotRegistry())

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,26 +653,26 @@ public MapExpression visitMapExpression(EsqlBaseParser.MapExpressionContext ctx)
653653
if (key.isBlank()) {
654654
throw new ParsingException(
655655
source(ctx),
656-
"Invalid named function argument [{}], empty key is not supported",
656+
"Invalid named parameter [{}], empty key is not supported",
657657
entry.getText()
658658
);
659659
}
660660
if (names.contains(key)) {
661-
throw new ParsingException(source(ctx), "Duplicated function arguments with the same name [{}] is not supported", key);
661+
throw new ParsingException(source(ctx), "Duplicated named parameters with the same name [{}] is not supported", key);
662662
}
663663
Expression value = expression(entry.constant());
664664
String entryText = entry.getText();
665665
if (value instanceof Literal l) {
666666
if (l.dataType() == NULL) {
667-
throw new ParsingException(source(ctx), "Invalid named function argument [{}], NULL is not supported", entryText);
667+
throw new ParsingException(source(ctx), "Invalid named parameter [{}], NULL is not supported", entryText);
668668
}
669669
namedArgs.add(Literal.keyword(source(stringCtx), key));
670670
namedArgs.add(l);
671671
names.add(key);
672672
} else {
673673
throw new ParsingException(
674674
source(ctx),
675-
"Invalid named function argument [{}], only constant value is supported",
675+
"Invalid named parameter [{}], only constant value is supported",
676676
entryText
677677
);
678678
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,7 +2968,7 @@ public void testNamedFunctionArgumentNotConstant() {
29682968
}
29692969
}
29702970

2971-
public void testNamedFunctionArgumentEmptyMap() {
2971+
public void testNamedFunctionNamedParametersEmptyMap() {
29722972
Map<String, String> commands = Map.ofEntries(
29732973
Map.entry("eval x = {}", "30"),
29742974
Map.entry("where {}", "27"),
@@ -2987,7 +2987,7 @@ public void testNamedFunctionArgumentEmptyMap() {
29872987
}
29882988
}
29892989

2990-
public void testNamedFunctionArgumentMapWithNULL() {
2990+
public void testNamedFunctionNamedParametersMapWithNULL() {
29912991
Map<String, String> commands = Map.ofEntries(
29922992
Map.entry("eval x = {}", "29"),
29932993
Map.entry("where {}", "26"),
@@ -3007,13 +3007,13 @@ public void testNamedFunctionArgumentMapWithNULL() {
30073007
null,
30083008
"line 1:{}: {}",
30093009
error,
3010-
"Invalid named function argument [\"option\":null], NULL is not supported"
3010+
"Invalid named parameter [\"option\":null], NULL is not supported"
30113011
)
30123012
);
30133013
}
30143014
}
30153015

3016-
public void testNamedFunctionArgumentMapWithEmptyKey() {
3016+
public void testNamedFunctionNamedParametersMapWithEmptyKey() {
30173017
Map<String, String> commands = Map.ofEntries(
30183018
Map.entry("eval x = {}", "29"),
30193019
Map.entry("where {}", "26"),
@@ -3033,7 +3033,7 @@ public void testNamedFunctionArgumentMapWithEmptyKey() {
30333033
null,
30343034
"line 1:{}: {}",
30353035
error,
3036-
"Invalid named function argument [\"\":1], empty key is not supported"
3036+
"Invalid named parameter [\"\":1], empty key is not supported"
30373037
)
30383038
);
30393039
expectError(
@@ -3042,13 +3042,13 @@ public void testNamedFunctionArgumentMapWithEmptyKey() {
30423042
null,
30433043
"line 1:{}: {}",
30443044
error,
3045-
"Invalid named function argument [\" \":1], empty key is not supported"
3045+
"Invalid named parameter [\" \":1], empty key is not supported"
30463046
)
30473047
);
30483048
}
30493049
}
30503050

3051-
public void testNamedFunctionArgumentMapWithDuplicatedKey() {
3051+
public void testNamedFunctionNamedParametersMapWithDuplicatedKey() {
30523052
Map<String, String> commands = Map.ofEntries(
30533053
Map.entry("eval x = {}", "29"),
30543054
Map.entry("where {}", "26"),
@@ -3068,13 +3068,13 @@ public void testNamedFunctionArgumentMapWithDuplicatedKey() {
30683068
null,
30693069
"line 1:{}: {}",
30703070
error,
3071-
"Duplicated function arguments with the same name [dup] is not supported"
3071+
"Duplicated named parameters with the same name [dup] is not supported"
30723072
)
30733073
);
30743074
}
30753075
}
30763076

3077-
public void testNamedFunctionArgumentInInvalidPositions() {
3077+
public void testNamedFunctionNamedParametersInInvalidPositions() {
30783078
// negative, named arguments are not supported outside of a functionExpression where booleanExpression or indexPattern is supported
30793079
String map = "{\"option1\":\"string\", \"option2\":1}";
30803080

@@ -3103,7 +3103,7 @@ public void testNamedFunctionArgumentInInvalidPositions() {
31033103
}
31043104
}
31053105

3106-
public void testNamedFunctionArgumentWithUnsupportedNamedParameterTypes() {
3106+
public void testNamedFunctionNamedParametersWithUnsupportedNamedParameterTypes() {
31073107
Map<String, String> commands = Map.ofEntries(
31083108
Map.entry("eval x = {}", "29"),
31093109
Map.entry("where {}", "26"),
@@ -3124,7 +3124,7 @@ public void testNamedFunctionArgumentWithUnsupportedNamedParameterTypes() {
31243124
null,
31253125
"line 1:{}: {}",
31263126
error,
3127-
"Invalid named function argument [\"option1\":?n1], only constant value is supported"
3127+
"Invalid named parameter [\"option1\":?n1], only constant value is supported"
31283128
)
31293129
);
31303130
expectError(
@@ -3134,7 +3134,7 @@ public void testNamedFunctionArgumentWithUnsupportedNamedParameterTypes() {
31343134
null,
31353135
"line 1:{}: {}",
31363136
error,
3137-
"Invalid named function argument [\"option1\":?n1], only constant value is supported"
3137+
"Invalid named parameter [\"option1\":?n1], only constant value is supported"
31383138
)
31393139
);
31403140
}
@@ -3967,7 +3967,7 @@ public void testInvalidCompletion() {
39673967
);
39683968
expectError(
39693969
"FROM foo* | COMPLETION prompt WITH { \"inference_id\": \"inferenceId\", \"unknown_option\": 3 }",
3970-
"line 1:42: Inavalid option [unknown_option] in COMPLETION, expected one of [[inference_id]]"
3970+
"line 1:31: Inavalid option [unknown_option] in COMPLETION, expected one of [[inference_id]]"
39713971
);
39723972

39733973
expectError("FROM foo* | COMPLETION WITH inferenceId", "line 1:24: extraneous input 'WITH' expecting {");

0 commit comments

Comments
 (0)