Krisztian Kasa created HIVE-24869:
-------------------------------------

             Summary: Implement Respect/Ignore Nulls in lag/lead
                 Key: HIVE-24869
                 URL: https://issues.apache.org/jira/browse/HIVE-24869
             Project: Hive
          Issue Type: Improvement
          Components: UDF
            Reporter: Krisztian Kasa


{code}
<lead or lag function> ::=
  <lead or lag> <left paren> <lead or lag extent>
  [ <comma> <offset> [ <comma> <default expression> ] ] <right paren>
  [ <null treatment> ]

<lead or lag> ::=
  LEAD | LAG

<lead or lag extent> ::=
  <value expression>

<offset> ::=
  <exact numeric literal>

<default expression> ::=
  <value expression>

<null treatment> ::=
  RESPECT NULLS | IGNORE NULLS
{code}
Example: get the a column value from the previous and the next row or return 0 
if there is no  previous/next row corresponding to the current row. 
Respect/Ignore nulls control whether null values should be preserved or 
eliminated.
{code}
SELECT 
  a,
  LAG(a, 1, 0) OVER (ORDER BY a) IGNORE NULLS,
  LEAD(a, 1, 0) OVER (ORDER BY a) RESPECT NULLS
FROM ...
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to