Skip to content

Commit c0f98e4

Browse files
committed
Simplify Verifier methods
1 parent 1321019 commit c0f98e4

File tree

1 file changed

+11
-18
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis

1 file changed

+11
-18
lines changed

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -627,43 +627,37 @@ private static void checkRemoteEnrich(LogicalPlan plan, Set<Failure> failures) {
627627
}
628628

629629
/**
630-
* Checks a whether a condition contains a disjunction with the specified typeToken. Adds to failure if it does.
630+
* Checks whether a condition contains a disjunction with the specified typeToken. Adds to failure if it does.
631631
*
632-
* @param condition condition to check for disjunctions
633-
* @param typeToken type that is forbidden in disjunctions
632+
* @param condition condition to check for disjunctions
634633
* @param typeNameProvider provider for the type name to add in the failure message
635-
* @param failures failures collection to add to
636-
* @param <E> type of the token to look for
634+
* @param failures failures collection to add to
637635
*/
638-
private static <E extends Expression> void checkNotPresentInDisjunctions(
636+
private static void checkNotPresentInDisjunctions(
639637
Expression condition,
640-
Class<E> typeToken,
641-
java.util.function.Function<E, String> typeNameProvider,
638+
java.util.function.Function<FullTextFunction, String> typeNameProvider,
642639
Set<Failure> failures
643640
) {
644641
condition.forEachUp(Or.class, or -> {
645-
checkNotPresentInDisjunctions(or.left(), or, typeToken, typeNameProvider, failures);
646-
checkNotPresentInDisjunctions(or.right(), or, typeToken, typeNameProvider, failures);
642+
checkNotPresentInDisjunctions(or.left(), or, typeNameProvider, failures);
643+
checkNotPresentInDisjunctions(or.right(), or, typeNameProvider, failures);
647644
});
648645
}
649646

650647
/**
651-
* Checks a whether a condition contains a disjunction with the specified typeToken. Adds to failure if it does.
648+
* Checks whether a condition contains a disjunction with the specified typeToken. Adds to failure if it does.
652649
*
653650
* @param parentExpression parent expression to add to the failure message
654651
* @param or disjunction that is being checked
655-
* @param typeToken type that is forbidden in disjunctions
656652
* @param failures failures collection to add to
657-
* @param <E> type of the token to look for
658653
*/
659-
private static <E extends Expression> void checkNotPresentInDisjunctions(
654+
private static void checkNotPresentInDisjunctions(
660655
Expression parentExpression,
661656
Or or,
662-
Class<E> typeToken,
663-
java.util.function.Function<E, String> elementName,
657+
java.util.function.Function<FullTextFunction, String> elementName,
664658
Set<Failure> failures
665659
) {
666-
parentExpression.forEachDown(typeToken, ftp -> {
660+
parentExpression.forEachDown(FullTextFunction.class, ftp -> {
667661
failures.add(
668662
fail(or, "Invalid condition [{}]. {} can't be used as part of an or condition", or.sourceText(), elementName.apply(ftp))
669663
);
@@ -697,7 +691,6 @@ private static void checkFullTextQueryFunctions(LogicalPlan plan, Set<Failure> f
697691
);
698692
checkNotPresentInDisjunctions(
699693
condition,
700-
FullTextFunction.class,
701694
ftf -> "[" + ftf.functionName() + "] " + ftf.functionType(),
702695
failures
703696
);

0 commit comments

Comments
 (0)