Parallel icon
Size icon
Queries icon
Assert icon
Webhook icon

Fill short sensor gaps with DuckDB and preserve outage provenance

Resample sensor CSVs with DuckDB, fill only bounded internal gaps, and export Parquet with observed, interpolated and missing provenance.

Categories
Data

A smooth-looking time series can hide a disconnected sensor. This flow fills only short gaps bracketed by real observations. Long outages, leading/trailing gaps and entirely absent expected sensors remain visible in the output.

How it works

  1. Upload a CSV or pass its Kestra storage URI through the keyed webhook.
  2. Validate the expected sensor list, explicit-offset timestamps, finite readings, unique sensor/time pairs and alignment to the requested grid.
  3. DuckDB builds the regular grid. Window functions find the nearest real observations; linear interpolation fills only eligible internal gaps.
  4. Export ordered Parquet plus per-sensor coverage counts as CSV.

What you get

  • One row per expected sensor and grid point in the half-open [start_at, end_at) window.
  • OBSERVED, INTERPOLATED or MISSING status, original observed value, anchor times and gap length.
  • No extrapolation, cross-device interpolation, deduplication or silent out-of-window filtering.

Who it's for

  • Data engineers preparing continuous-valued fleet, environmental or equipment telemetry.

Why orchestrate this with Kestra

Validation and interpolation exchange typed Parquet checkpoints. A final task reads the exported series to check row counts and provenance. Invalid input stops execution. The webhook can reuse a producer's stored CSV, and both output artifacts remain attached to the run.

Prerequisites

  • Kestra with the DuckDB JDBC plugin. No database service, Python or Docker runner.
  • UTF-8 CSV containing sensor_id,observed_at,value; values must be finite numbers. Missing readings are absent rows, not blank or NaN values. Timestamps need Z or an offset.
  • 1-100 expected sensor IDs, at most 100,000 observations and a 10 MiB file. The requested window must contain a whole number of steps and at most 200,000 total grid rows.
  • Interpolate only measurements where linear estimation is appropriate; these are estimates, not observations.

Secrets

  • SENSOR_WEBHOOK_KEY: Authentication key for automated batch submissions.

Quick start

  1. Set the secret and upload your CSV, listing every expected sensor explicitly.
  2. Set window bounds, step seconds and maximum missing steps; execute and inspect both artifacts.
  3. Automate with a JSON webhook body containing samples (a kestra:///... URI), sensors, start_at and end_at. Step and gap limits have defaults.

How to extend

  • Route low-coverage sensors for review or load the Parquet into an analytical warehouse.

Links

Orchestrate with Kestra
Orchestrate DuckDB with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.