prev function for MATCH_RECOGNIZE
Applies to: Databricks SQL
Databricks Runtime 19.0 and above
Beta
This feature is in Beta. Workspace admins can control access to this feature from the Previews page. See Manage Databricks previews.
Returns a preceding column value relative to the current row in the match. Use this function only in the MEASURES and DEFINE clauses of MATCH_RECOGNIZE.
Syntax
prev ( { 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.offset: An optional integral literal greater than or equal to0. The offset relative to the current row. The default is1.
Returns
A value of the type of colName. If the identified row is outside the current partition, returns NULL.