public static boolean applyCondition(CompiledValue operand, ExecutionContext context)
      throws FunctionDomainException, TypeMismatchException, NameResolutionException,
      QueryInvocationTargetException {
    if (operand == null) {
      return true;
    }
    Object result = operand.evaluate(context);
    if (result instanceof Boolean) {
      return (Boolean) result;
    } else if (result != null && result != QueryService.UNDEFINED) {
      throw new TypeMismatchException(
          String.format("AND/OR operands must be of type boolean, not type ' %s '",
              result.getClass().getName()));
    } else {
      return false;
    }
  }
This util function does a cartesian of the array of SelectResults object , expanding the
resultant set to the number of iterators passed in expansionList. The position of the iterator
fields in the final result is governed by the order of RuntimeIterators present in the
finalList. If any condition needs to be evaluated during cartesian , it can be passed as
operand

@param results Array of SelectResults object which are to be cartesianed
@param itrsForResultFields A two dimensional array of RuntimeIterator. Each row of this two
       dimensional RuntimeIterator array , maps to a SelectResults object in the results array.
       Thus the 0th row of two dimensional RuntimeIterator array will map to the 0th element of
       the SelectResults array. The order of RuntimeIterator in a row will map to the fields in
       the SelectResults object. The 0th RuntimeIterator will map to the 0th field of the
       corresponding SelectResults object. The number of rows in the two dimensional array of
       RuntimeIterator should be equal to the size of array of SelectResults object passed and
       the number of RuntimeIterators in each row should be equal to the number of fields in
       the SelectResults object . The SelectResults object itself may be a ResultBag object or
       a StructBag object.

@param expansionList List containing RunimeIterators to which the final Results should be
       expanded to.
@param finalList List containing RuntimeIterators which define the number of fields to be
       present in the resultant SelectResults and their relative positions. The Runtime
       Iterators present in the List should be either available in the expansion List or should
       be present in each row of the two dimensional RuntimeIterator array.

@param context ExecutionContext object
@param operand The CompiledValue which needs to be iter evaluated during cartesian. Only those
       tuples will be selected in the final Result for which oerand evaluates to true.
@return SelectResults object representing the final result of the cartesian
geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryUtils.java