beliefer opened a new pull request #29800:
URL: https://github.com/apache/spark/pull/29800


   ### What changes were proposed in this pull request?
   Spark SQL supports some window function like `NTH_VALUE`, `FIRST_VALUE` and 
`LAST_VALUE`.
   If we specify window frame like `UNBOUNDED PRECEDING AND CURRENT ROW` or 
`UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING`, we can elimate some calculations.
   For example: if we execute the SQL show below:
   ```
   SELECT NTH_VALUE(col,
            2) OVER(ORDER BY rank UNBOUNDED PRECEDING
           AND CURRENT ROW)
   FROM tab;
   ```
   The output for row number greater than 1, return the fixed value. otherwise, 
return null. So we just calculate the value once and notice whether the row 
number less than 2.
   `UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` is simpler.
   
   
   ### Why are the changes needed?
   Improve the performance for `NTH_VALUE`, `FIRST_VALUE` and `LAST_VALUE`.
   
   
   ### Does this PR introduce _any_ user-facing change?
    'No'.
   
   
   ### How was this patch tested?
   Jenkins test.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to