postgres_sql
TimescaleDB SQL
Type:
postgres_sql
• Category:flow
• Tags:sql
,postgres
,timescale
,data
Description
Execute advanced SQL against TimescaleDB
Parameters
Name | Type | Description | Required | Default |
---|---|---|---|---|
sql | code | SQL query | no |
Help
Overview
The TimescaleDB SQL Worker runs advanced SQL statements directly against a TimescaleDB instance. It is designed for scenarios where complex queries, analytical functions, or custom data transformations are required beyond the capabilities of standard data‑pipeline operators. By submitting a raw SQL string, users can leverage the full power of PostgreSQL and TimescaleDB extensions (such as hypertables, continuous aggregates, and time‑bucket functions) while the worker handles connection management, query execution, and result handling.
Inputs
sql
(code
) – The complete SQL query to be executed. This may include any valid PostgreSQL/TimescaleDB syntax, such asSELECT
,INSERT
,UPDATE
,DELETE
, CTEs, window functions, or Timescale‑specific commands. The query is sent to the target database exactly as provided, so it must be syntactically correct and reference existing tables, schemas, and extensions.
Minimal Example Usage
Assume a TimescaleDB database contains a hypertable named sensor_data
with columns time
, device_id
, and temperature
. To retrieve the average temperature per device for the last 24 hours, you could configure the worker as follows:
-
Set the
sql
input to:SELECT device_id, AVG(temperature) AS avg_temp FROM sensor_data WHERE time > now() - interval '24 hours' GROUP BY device_id;
When the worker runs, it connects to the configured TimescaleDB instance, executes the query, and returns a result set containing each device_id
paired with its corresponding avg_temp
. The output can then be consumed by downstream steps in your workflow, such as alerting, visualization, or further data enrichment.