beliefer opened a new pull request #27442: [SPARK-30708][SQL] Fix parse 
exception for first_value and last_value
URL: https://github.com/apache/spark/pull/27442
 
 
   ### What changes were proposed in this pull request?
   When I running first_value and last_value window function occur a 
`ParserException`.
   Take first_value as an example, the `ParserException` show below.
   ```
   SELECT first_value(unique1) over w,
   last_value(unique1) over w
   FROM tenk1 WHERE unique1 < 10
   WINDOW w AS (order by four range between current row and unbounded following)
    
   org.apache.spark.sql.catalyst.parser.ParseException
    
   no viable alternative at input 'first_value'(line 1, pos 7)
    
   == SQL ==
   SELECT first_value(unique1) over w,
   -------^^^
   last_value(unique1) over w
   FROM tenk1 WHERE unique1 < 10
   WINDOW w AS (order by four range between current row and unbounded following)
   ```
   
   After my investigation, I found that `FIRST`, `FIRST_VALUE`, `LAST`, 
`LAST_VALUE` are all ansi reserved words. But both `FIRST` and `LAST` are now 
on the `ansiNonReserved` list, so I put `FIRST_VALUE` and `LAST_VALUE` on the 
`ansiNonReserved` list too.
   
   ### Why are the changes needed?
   Fix bug.
   
   ### Does this PR introduce any user-facing change?
   No
   
   ### How was this patch tested?
   Exists UT

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to