private boolean references(RexNode e, CorRef correlation) {
    switch (e.getKind()) {
    case CAST:
      final RexNode operand = ((RexCall) e).getOperands().get(0);
      if (isWidening(e.getType(), operand.getType())) {
        return references(operand, correlation);
      }
      return false;
    case FIELD_ACCESS:
      final RexFieldAccess f = (RexFieldAccess) e;
      if (f.getField().getIndex() == correlation.field
          && f.getReferenceExpr() instanceof RexCorrelVariable) {
        if (((RexCorrelVariable) f.getReferenceExpr()).id.equals(correlation.corr)) {
          return true;
        }
      }
      // fall through
    default:
      return false;
    }
  }
Finds a {@link RexInputRef} that is equivalent to a {@link CorRef},
and if found, throws a {@link Util.FoundOne}.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java