protected final RelNode processProject(Project project) {
        RelNode origInput = project.getInput();
        relBuilder.push(origInput);
        RexShuttle shuttle = new ProcessShuttle();
        List<RexNode> newProjects = new ArrayList<RexNode>();
        for (RexNode expr : project.getProjects()) {
          newProjects.add(expr.accept(shuttle));
        }
        if (relBuilder.peek() == origInput) {
          relBuilder.clear();
          return project;
        }
        relBuilder.project(newProjects);
        return relBuilder.build();
      }
Generic support for rewriting Windowing expression into a different form usually using joins.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRewriteToDataSketchesRules.java