id: temporal_interpolate
name: Interpolate
description: >
  Fill gaps in a time series using interpolation. Supports forward fill
  (carry last known value forward) and backward fill (carry next known
  value backward).
version: 1.0.0
category: transform
type: table-to-table
default_implementation: duckdb

inputs:
  - name: table
    type: table
    format: parquet
    description: Input table with a timestamp column and nullable value columns
    required: true

requires: {}

outputs:
  - name: result
    type: table
    format: parquet
    description: Table with gaps filled

params:
  time_column:
    type: string
    description: Name of the timestamp column
    required: true
  value_columns:
    type: array
    items:
      type: string
    description: Columns to interpolate
    required: true
  method:
    type: string
    default: forward
    enum: [forward, backward]
    description: >
      Interpolation method. 'forward' carries the last known value forward.
      'backward' carries the next known value backward.

# backends: audited 2026-08-14 (defect 50). A key means a runtime that DISPATCHES this op —
# folia-engine `dispatch_op` (products/sdk/folia-engine/src/lib.rs), a `registerOp`/OP_TABLE
# entry in packages/compute, `_BUILTIN_OP_MAP` in folia/compute.py, or a backend manifest
# (folia/backends/*/backend.yaml).
backends:
  python:
    function: temporal.ops.interpolate
    dispatch: folia/compute.py _BUILTIN_OP_MAP

display_hints:
  chart:
    renderer: observable-plot
    chartType: line
    xAxis: { field: ts }
