private static void addJoinKey(
      List<RexNode> joinKeyList,
      RexNode key,
      boolean preserveLastElementInList) {
    if (!joinKeyList.isEmpty() && preserveLastElementInList) {
      joinKeyList.add(joinKeyList.size() - 1, key);
    } else {
      joinKeyList.add(key);
    }
  }
Splits out the equi-join (and optionally, a single non-equi) components
of a join condition, and returns what's left. Projection might be
required by the caller to provide join keys that are not direct field
references.

@param sysFieldList  list of system fields
@param inputs        join inputs
@param condition     join condition
@param joinKeys      The join keys from the inputs which are equi-join
                     keys
@param filterNulls   The join key positions for which null values will not
                     match. null values only match for the "is not distinct
                     from" condition.
@param rangeOp       if null, only locate equi-joins; otherwise, locate a
                     single non-equi join predicate and return its operator
                     in this list; join keys associated with the non-equi
                     join predicate are at the end of the key lists
                     returned
@return What's left, never null
@throws CalciteSemanticException
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptUtil.java