Skip to content

Commit f74d1fb

Browse files
committed
Revert quaternary function change
1 parent 772295c commit f74d1fb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -995,10 +995,15 @@ protected interface TernaryBuilder<T> {
995995
@SuppressWarnings("overloads") // These are ambiguous if you aren't using ctor references but we always do
996996
protected static <T extends Function> FunctionDefinition def(Class<T> function, QuaternaryBuilder<T> ctorRef, String... names) {
997997
FunctionBuilder builder = (source, children, cfg) -> {
998-
boolean hasMinimumThree = OptionalArgument.class.isAssignableFrom(function);
999-
if (hasMinimumThree && (children.size() > 4 || children.size() < 3)) {
1000-
throw new QlIllegalArgumentException("expects three or four arguments");
1001-
} else if (hasMinimumThree == false && children.size() != 4) {
998+
if (OptionalArgument.class.isAssignableFrom(function)) {
999+
if (children.size() > 4 || children.size() < 3) {
1000+
throw new QlIllegalArgumentException("expects three or four arguments");
1001+
}
1002+
} else if (TwoOptionalArguments.class.isAssignableFrom(function)) {
1003+
if (children.size() > 4 || children.size() < 2) {
1004+
throw new QlIllegalArgumentException("expects minimum two, maximum four arguments");
1005+
}
1006+
} else if (children.size() != 4) {
10021007
throw new QlIllegalArgumentException("expects exactly four arguments");
10031008
}
10041009
return ctorRef.build(

0 commit comments

Comments
 (0)