[SPARK-1442][SQL][WIP] Initial window function implementation (refactored from #2953)

This WIP PR is refactored from PR #2953. Please refer to the original PR description for features implemented and not implemented in this PR.

The original PR was a huge one, commenting on each issue could be very time consuming. After offline discussions with @guowei2, I decided to work on a refactoring branch to fix most minor issues first and then start discussion based on this refactored version.

Major issues left in this PR are:

1. Window spec is added to aggregation functions with a `var`, which breaks query plan immutability.
2. When used with window specs, common aggregation functions like `COUNT`, `SUM`, `AVG` etc are not translated into Hive aggregation functions rather than Spark SQL builtin implementations.
3. Execution code (`execution.WindowFunction`) can be further simplified.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/apache/spark/3703)
<!-- Reviewable:end -->