SCD_AT_TIME

All functions > BUSINESS_HISTORICAL > SCD_AT_TIME

Returns the state of an SCD (slowly changing dimension) value at the given point in time.

Syntax

SCD_AT_TIME(scd: ARRAY<ROW(time_update: TIMESTAMP, value: T)>, point_in_time: TIMESTAMP) → T
sql

Type Parameters:

  • T: Any type

Arguments

ParameterTypeRequiredDescription
scdARRAY<ROW(time_update: TIMESTAMP, value: T)>YesArray of SCD records with time_update and value fields
point_in_timeTIMESTAMPYesTimestamp to query the SCD state at

Returns

Value as it was at the specified point in time

Notes

  • SCD (Slowly Changing Dimension) tracks values that change over time
  • Each record has a time_update timestamp and a value
  • Returns the most recent value where time_update <= point_in_time
  • If no records exist before point_in_time, returns NULL
  • Useful for historical analysis and time travel queries
  • Commonly used for tracking customer attributes, prices, or configurations over time
Last update at: 2025/10/13 10:23:46