private static boolean isValidRemoteJoinRef(int inputRexIndex, RelNode relNode) {
    if (relNode instanceof TableScan) {
      return relNode.getRowType().getFieldList().get(inputRexIndex).getName().equals(SamzaSqlRelMessage.KEY_NAME);
    }
    // has to be a single rel kind filter/project/table scan
    Preconditions.checkState(relNode.getInputs().size() == 1,
        "Has to be single input RelNode and got " + relNode.getDigest());
    if (relNode instanceof LogicalFilter) {
      return isValidRemoteJoinRef(inputRexIndex, relNode.getInput(0));
    }
    RexNode inputRef = ((LogicalProject) relNode).getProjects().get(inputRexIndex);
    if (inputRef instanceof RexCall) {
      return false; // we can not push any expression as of now stop and return null.
    }
    return isValidRemoteJoinRef(((RexInputRef) inputRef).getIndex(), relNode.getInput(0));
  }
Helper method to check if the join condition can be evaluated by the remote table.
It does follow single path  using the index ref path checking if it is a simple reference all the way to table scan.
In case any RexCall is encountered will stop an return null as a marker otherwise will return Column Name.

@param inputRexIndex rex ref index
@param relNode current Rel Node
@return false if any Relational Expression is encountered on the path, true if is simple ref to __key__ column.
samza-sql/src/main/java/org/apache/samza/sql/translator/JoinTranslator.java