Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-28310

ANSI SQL grammar support: first_value/last_value(expression, [RESPECT NULLS | IGNORE NULLS])

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Reopened
    • Minor
    • Resolution: Unresolved
    • 3.0.0
    • None
    • SQL
    • None

    Description

      According to the ANSI SQL 2011:

      <default expression> ::= <value expression>
      <null treatment> ::= RESPECT NULLS | IGNORE NULLS
      <first or last value function> ::=
      <first or last value> <left paren> <value expression> <right paren> [ <null treatment>
      ]
      <first or last value> ::=
      FIRST_VALUE | LAST_VALUE
      

      Teradata - https://docs.teradata.com/reader/756LNiPSFdY~4JcCCcR5Cw/SUwCpTupqmlBJvi2mipOaA 

      Oracle - https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/FIRST_VALUE.html#GUID-D454EC3F-370C-4C64-9B11-33FCB10D95EC

      Redshift – https://docs.aws.amazon.com/redshift/latest/dg/r_WF_first_value.html

       

      Postgresql didn't implement the Ignore/respect nulls. 

      https://www.postgresql.org/docs/devel/functions-window.html

      Note

      The SQL standard defines a RESPECT NULLS or IGNORE NULLS option for leadlagfirst_valuelast_value, and nth_value. This is not implemented in PostgreSQL: the behavior is always the same as the standard's default, namely RESPECT NULLS.

        

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lipzhu Zhu, Lipeng
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: