public static Set<RexTableInputRef> findRexTableInputRefs(RexNode rexNode) {
    Set<RexTableInputRef> rexTableInputRefs = new HashSet<>();
    RexVisitor<RexTableInputRef> visitor = new RexVisitorImpl<RexTableInputRef>(true) {
      @Override
      public RexTableInputRef visitTableInputRef(RexTableInputRef ref) {
        rexTableInputRefs.add(ref);
        return ref;
      }
    };

    rexNode.accept(visitor);
    return rexTableInputRefs;
  }
Extracts inputs referenced by aggregate operator.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java