INTERPOLATE_BFILL

functionsupportedCore SQL functionspreview

docs.snowflake.com ↗

Window functions

Updates rows in a time-series data set to gap-fill missing values based on surrounding values. You can call the following interpolation window functions: - INTERPOLATE_BFILL: Gap-fills rows based on the next observed row. - INTERPOLATE_FFILL: Gap-fills rows based on the previously observed row. - INTERPOLATE_LINEAR: Gap-fills rows based on the linear interpolation of previous and next values. This function only supports numeric values. These functions have the same window function syntax. They don’t support explicit window frames.

Syntax

supportedpartialnot supportednot scored

INTERPOLATE_BFILL( <expr> )
  OVER ( [ PARTITION BY <expr1> ] ORDER BY <expr2> [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] )
INTERPOLATE_FFILL( <expr> )
  OVER ( [ PARTITION BY <expr1> ] ORDER BY <expr2> [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] )
INTERPOLATE_LINEAR( <expr> )
  OVER ( [ PARTITION BY <expr1> ] ORDER BY <expr2> [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] )

Parameters

NameRequiredDescription
exprrequiredAn expression that defines the column that you want to gap-fill. The INTERPOLATE_LINEAR input expression must be a numeric data type. The INTERPOLATE_BFILL and INTERPOLATE_FFILL input expressions do not support geospatial data types.

Returns

These functions return the same data type as the data type of the input expression.

Usage notes

Parameters

OVER: Standard window function OVER clause. See Window function syntax and usage. For the interpolation functions, the PARTITION BY clause is optional, but the ORDER BY clause is required. You can’t specify an explicit window frame. The INTERPOLATE_LINEAR function can have only one ORDER BY expression, and it must be a numeric, DATE, or TIMESTAMP expression (including all TIMESTAMP variants).