SPARK-3111 Implement the LAST analytic function for sql

SPARK-3111
Implement the LAST analytic function for sql