File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments