java.lang.Object
org.elasticsearch.xpack.esql.expression.predicate.Predicates

public abstract class Predicates extends Object
  • Constructor Details

    • Predicates

      public Predicates()
  • Method Details

    • splitAnd

      public static List<Expression> splitAnd(Expression exp)
    • splitOr

      public static List<Expression> splitOr(Expression exp)
    • combineOr

      public static Expression combineOr(List<Expression> exps)
    • combineAnd

      public static Expression combineAnd(List<Expression> exps)
    • inCommon

      public static List<Expression> inCommon(List<Expression> l, List<Expression> r)
    • subtract

      public static List<Expression> subtract(List<Expression> from, List<Expression> list)
    • extractCommon

      public static org.elasticsearch.core.Tuple<Expression,List<Expression>> extractCommon(List<Expression> expressions)
      Given a list of expressions of predicates, extract a new expression of all the common ones and return it, along the original list with the common ones removed.

      Example: for ['field1 > 0 AND field2 > 0', 'field1 > 0 AND field3 > 0', 'field1 > 0'], the function will return 'field1 > 0' as the common predicate expression and ['field2 > 0', 'field3 > 0', Literal.TRUE] as the left predicates list.

      Parameters:
      expressions - list of expressions to extract common predicates from.
      Returns:
      a tuple having as the first element an expression of the common predicates and as the second element the list of expressions with the common predicates removed. If there are no common predicates, `null` will be returned as the first element and the original list as the second. If for one of the expressions in the input list, nothing is left after trimming the common predicates, it will be replaced with Literal.TRUE.