TS_FIRST_VALUE

Processes the data that belongs to each time slice. A time series aggregate (TSA) function, TS_FIRST_VALUE returns the value at the start of the time slice, where an interpolation scheme is applied if the timeslice is missing, in which case the value is determined by the values corresponding to the previous (and next) timeslices based on the interpolation scheme of const (linear). There is one value per time slice per partition.

Behavior Type

Immutable

Syntax

TS_FIRST_VALUE ( expression [ IGNORE NULLS ] 
... [, { 'CONST' | 'LINEAR' }   ] ) 

Parameters

expression

Argument expression on which to aggregate and interpolate.

expression is data type INTEGER or FLOAT.

IGNORE NULLS

The IGNORE NULLS behavior changes depending on a CONST or LINEAR interpolation scheme. See When Time Series Data Contains Nulls in Analyzing Data for details.

'CONST' | 'LINEAR'

(Default CONST) Optionally specifies the interpolation value as either constant or linear.

  • CONST—New value are interpolated based on previous input records.
  • LINEAR—Values are interpolated in a linear slope based on the specified time slice.

Notes

Example

For detailed examples, see Gap Filling and Interpolation in Analyzing Data.