Skip to content
Download

Step types ​

You choose the type in Step type when you add a step. Other steps use its data as ${step_id}, see Jobs and steps.

SQL query, MongoDB query, JavaScript code and plugin steps have an Execution timeout (ms) field. When it is empty, the step gets 30 seconds, and a plugin step gets 10 minutes.

SQL query ​

Runs SQL against a database connection.

  • Data source: a PostgreSQL, MySQL, ClickHouse, SQLite or Local files connection, or an S3 or SFTP connection, where SQL reads files by their address, see Query files with SQL.
  • Database: another database on the same server. Leave Connection default to use the database of the connection. Not available for SQLite and Local files.
  • Schema: for PostgreSQL, the schema that goes first in the search path.

Separate statements with semicolons. The rows of the last statement become the step result.

Tokens such as ${step_id} and ${variable} are sent to the driver as parameters, also inside string literals. After FROM, JOIN, INTO, UPDATE and similar keywords a token becomes a quoted identifier, so you can pass a table name. On PostgreSQL and ClickHouse an array is passed as a database array, for example WHERE id = ANY(${step_ids}) on PostgreSQL.

Run selection under Debug run runs only the selected SQL.

MongoDB query ​

Runs shell-style JavaScript against a MongoDB connection chosen in Data source. The code can use db, db.<collection>, db.getCollection(name) and ObjectId. Database picks another database for db.

A single expression such as db.orders.find({ status: 'paid' }) is returned as is. For longer code, end with return. Cursors are read into arrays.

JavaScript code ​

Runs local JavaScript with access to files, the network, processes and installed npm packages. The returned value is the step result. See JavaScript steps.

API request ​

Sends an HTTP(S) request. Fill in the Builder tab or edit the request as text on the JSON tab.

  • Method: GET, POST, PUT, PATCH or DELETE.
  • URL: the address, with tokens if needed: https://api.example.com/orders?since=${since}.
  • Headers: add them with Add header.
  • Request body (JSON): the request body.
  • Response type: auto returns parsed JSON when it can and text otherwise; json and text force the format.
  • Timeout (ms): 30000 by default.
  • Proxy profile: a proxy from Settings > Network.

A token that fills a whole JSON value keeps its type, so "items": "${step_rows}" sends an array. The step result is the response body. An error status such as 404 or 500 does not stop the job by itself.

CSV file ​

Reads a CSV file. On the Settings tab set the File path (or click Select file), Delimiter, Encoding and Has headers. The Preview tab shows the first rows. The result is an array of records.

JSON file ​

Reads a JSON file. Set the File path, the Encoding and, if you need part of the file, a JSONPath such as $.data[*]. The result is the parsed value or the JSONPath selection.

CSV and JSON steps only read files. To save rows as a file on S3 or SFTP, use Write file. For a file on your computer, use a JavaScript step.

Write file ​

Saves the rows of an earlier step, or a piece of text, as a file on an S3 or SFTP connection. Fill in the Settings tab or edit the settings as JSON on the JSON tab.

  • Storage: the S3 or SFTP connection the file goes to
  • Path: relative to the folder of the connection, its bucket folder or start folder. Variables work here, as in reports/orders-${report_date}.csv
  • Bucket: for an S3 connection that has no bucket of its own
  • Format: CSV, TSV, JSON, JSONL, XLSX, Parquet or Text. From the extension takes it from the path
  • Rows: the step whose rows are written. With the Text format, the Text field holds what is written
  • Column names in the first row: for CSV and TSV
  • If the file exists: Replace it (the default, so a daily run rewrites its file), Keep it and skip or Stop the step
json
{
  "path": "reports/orders-${report_date}.parquet",
  "format": "parquet",
  "rows": "${step_orders}",
  "ifExists": "replace"
}

The step result describes the file: its address, the number of rows and the size. Execution history shows the rows and size, or Existing file kept when the step skipped.

Transfer files ​

Copies or moves files between two storages, or inside one. The data streams from the source to the target without a copy on your computer.

  • Storage: the S3 or SFTP connection the files come from
  • From: a file, or a folder when the path ends with /
  • File names: for a folder, a pattern where * and ? match any characters, such as *.csv. When it is empty, every file is taken
  • Include subfolders: also copies the files of subfolders and keeps their paths
  • Target storage: where the files go. The same storage copies inside the source connection
  • To: a file path, or a folder when it ends with /
  • If the file exists: the same choices as in Write file
  • Delete source files after copying: turns the copy into a move. The sources are deleted only after every file has been copied

This example moves the CSV files that arrived in incoming/ into a dated folder:

json
{
  "from": { "path": "incoming/" },
  "to": { "path": "archive/${report_date}/" },
  "pattern": "*.csv",
  "recursive": false,
  "ifExists": "replace",
  "deleteSource": true
}

A running storage step shows how much it has moved, and Stop leaves no partly written files behind. Execution history shows the number of files and their size.

Write to table ​

Writes the rows of an earlier step into a table: PostgreSQL, MySQL, SQL Server, ClickHouse, MongoDB, SQLite, their compatible servers and databases from plugins.

  • Database: the connection the table is in. The Database and Schema fields below it pick another database or schema on that server, where it has them
  • Table: the table name, with suggestions from the schema
  • Rows: the step whose rows are written
  • Mode: how the rows go in, see Write modes
  • Create the table if it does not exist, with types read from the rows: builds a missing table from the first rows

Columns are matched to row fields by name. A field the table has no column for stops the step, and so do missing values for required columns and values for columns the database computes itself. Dates go into columns without a time zone as your local wall-clock time, and into columns with a time zone as the exact moment.

json
{
  "table": "daily_orders",
  "rows": "${step_orders}",
  "mode": "upsert",
  "keys": ["order_id"]
}

Transfer to table ​

Runs a query on one connection and streams its rows into a table on another, in batches, so the step never holds all rows in memory. For example, it can move orders from PostgreSQL into ClickHouse.

  • Data source: the connection the query runs on: any database, an S3 or SFTP connection or a Local files connection
  • Source query: runs read-only on the source and must return one result. Tokens in it are passed as parameters, as in SQL steps
  • Write to: the database connection that holds the table. The source connection writes into the source itself
  • Database, Schema, Table, Mode and the option to create the table work as in Write to table
json
{
  "query": "SELECT * FROM orders WHERE created_at >= ${period_start} AND created_at < ${period_end}",
  "table": "orders",
  "mode": "replacePeriod",
  "period": { "column": "created_at", "from": "${period_start}", "to": "${period_end}" }
}

Write modes ​

Write to table and Transfer to table have four modes:

ModeWhat it does
AppendAdds the rows to the table
Replace the table contentsReplaces every row of the table with the new ones
Insert or update by keyUpdates rows with the same key and inserts the others. Key columns must be the primary key or a unique index. Not available on ClickHouse
Replace a periodDeletes the rows whose Period column is between From, inclusive and To, exclusive, then writes the new ones

Replace a period suits jobs that load one day or one month at a time. Every new row must fall within the period, so running the same period again replaces its rows instead of adding them twice, and a daily job refreshes only its own dates. Bounds without a time zone are read in the time zone of the database.

When a write fails ​

  • On databases with transactions, such as PostgreSQL, SQL Server, SQLite and MySQL with InnoDB, the whole write runs in one transaction, so a failed or stopped step leaves the table as it was
  • Replace the table contents and Replace a period never leave a half-written table: ClickHouse and MongoDB fill a staging copy first, and MySQL tables that cannot roll back, such as MyISAM, are refused in these modes
  • Append into ClickHouse, and Append or Insert or update by key into MongoDB or a table without transactions, can keep the rows written before the failure
  • A table the step created is removed again when the write fails

A running table step shows how many rows it has written. Execution history shows the rows, how many were replaced and Table created when the step made the table.

Agents can run these four steps only with Read and write on the connection the step writes to, and a connection set to Ask waits for your approval, see Approvals.

Chart ​

Builds charts from earlier step results. The code runs like a JavaScript step and returns an Apache ECharts option object, { title, option, height }, or an array of them. Pick a starting point in Template: Line over time, Bars by category, Share pie, Key number or Several charts.

The option must be plain JSON: functions are rejected, so use ECharts string formatters such as '{b}: {c}'. A step can return up to 24 charts. They appear in the Report tab of the run, see Charts.

Report tab of a run with two charts built by a Chart step

Plugin steps ​

Installed plugins add their own steps to the Step type list. The step code is written in the language the plugin declares, for example Python for a browser automation plugin, and runs in the plugin's own environment.

  • Plugin preset: a saved set of plugin settings, or Default settings.
  • Step settings: values for this step only. They travel with the job; secrets stay in the plugin settings.

If the plugin is not installed, disabled or not set up, the editor says the step will not run and shows Enable, Set up or Open plugins to fix it.