Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Databricks SQL
Databricks Runtime 19.0 and above
Important
This feature is in Beta.
Returns a column value relative to the first row in the match. Use this function only in the MEASURES and DEFINE clauses of MATCH_RECOGNIZE.
For the generic first aggregate function, see first.
Syntax
first ( { colName | rowPatternVar.colName } [, offset ] )
Arguments
colName: A column from thetable_referencethatMATCH_RECOGNIZEoperates on.rowPatternVar.colName: A column qualified by a row pattern variable name. Reads the column value from rows mapped to that variable in the current match. For example,FIRST(down.tstamp)returns the timestamp of the first row classified asdown.offset: An optional integral literal greater than or equal to0. The offset relative to the first row. The default is0.
Returns
A value of the type of colName. If the identified row is outside the current partition, returns NULL.