INTERPOLATE_LINEAR
functionsupportedCore SQL functionspreviewUpdates 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
| Name | Required | Description |
|---|---|---|
expr | required | An 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
- When you use INTERPOLATE window functions with the RESAMPLE clause, include the columns to partition by in both PARTITION BY clauses: RESAMPLE (PARTITION BY) and INTERPOLATE (PARTITION BY). This approach ensures that: RESAMPLE generates rows with non-NULL values for the partition columns.
- INTERPOLATE functions operate within the correct partitions.
- Any WHERE clause filters preserve the generated rows for the partitions you want to keep.
- For examples of using INTERPOLATE with RESAMPLE, see Filling gaps in time-series data.
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).