Skip to content

Temporal Domain

For time-series data. Provides resampling, rolling windows, alignment, interpolation, filtering, and period statistics. All operations are powered by DuckDB.

Decided in ADR-0006

Schema Extension

The temporal: block on a layer declares time-series metadata.

FieldTypeRequiredDescription
time_columnstringYesColumn containing timestamps
frequencystringNoExpected frequency: 1h, 1D, 1W, 1M, 1Y
timezonestringNoTimezone identifier (e.g., UTC, America/Denver)
rangeobjectNoExpected time range: {start, end} as ISO 8601 strings
gapsstringNoGap handling strategy
yaml
layers:
  weather-observations:
    uri: data/station-temps.parquet
    type: table
    temporal:
      time_column: observed_at
      frequency: 1h
      timezone: America/Denver
      range:
        start: "2020-01-01"
        end: "2024-12-31"

Operations

The temporal domain provides 6 operations in 3 categories:

Transform

OperationTypeDescriptionKey Params
temporal_resampletable → tableResample time series to a different frequencytime_column, freq (e.g., 1D, 1W), agg_method, value_columns
temporal_rollingtable → tableRolling window aggregation over a trailing time windowtime_column, window (e.g., 7D), value_columns, agg
temporal_aligntable + table → tableAlign two time series to common timestamps via ASOF JOINtime_column, method
temporal_interpolatetable → tableFill gaps using forward or backward filltime_column, value_columns, method

Filter

OperationTypeDescriptionKey Params
temporal_time_rangetable → tableFilter to a time window (inclusive bounds)time_column, start, end (ISO 8601)

Aggregate

OperationTypeDescriptionKey Params
temporal_period_statstable → tableStatistics per calendar period (month, year, etc.)time_column, period, value_columns, aggregations

Compute

All temporal operations are powered by DuckDB. For small datasets, queries run in-browser via DuckDB-WASM. Larger time-series data runs server-side with DuckDB native in the local or cloud tier.

DuckDB provides:

  • Native timestamp types and date_trunc() for period grouping
  • Window functions for rolling aggregations
  • ASOF JOIN for time-series alignment
  • Interval arithmetic for frequency-based operations

Examples

Daily Resample with 7-Day Rolling Average

yaml
layers:
  source/hourly-temps:
    uri: data/station-temps.parquet
    type: table
    temporal:
      time_column: observed_at
      frequency: 1h

  analysis/daily-temps:
    type: table
    compute:
      op: temporal_resample
      inputs:
        table: { layer: source/hourly-temps }
      params:
        time_column: observed_at
        freq: "1D"
        agg_method: mean

  analysis/weekly-trend:
    type: table
    compute:
      op: temporal_rolling
      inputs:
        table: { layer: analysis/daily-temps }
      params:
        time_column: observed_at
        window: "7D"
        value_columns: [temperature]
        agg: mean
    style:
      chart:
        type: line
        x: observed_at
        y: temperature

Filter and Summarize by Month

yaml
layers:
  analysis/2024-only:
    type: table
    compute:
      op: temporal_time_range
      inputs:
        table: { layer: source/observations }
      params:
        time_column: observed_at
        start: "2024-01-01"
        end: "2024-12-31"

  results/monthly-stats:
    type: table
    compute:
      op: temporal_period_stats
      inputs:
        table: { layer: analysis/2024-only }
      params:
        time_column: observed_at
        period: month
        value_columns: [temperature, precipitation]
        aggregations:
          avg_temp: "AVG(temperature)"
          total_precip: "SUM(precipitation)"
          max_temp: "MAX(temperature)"

Licensed under CC-BY-4.0