What is a Node?¶
A Node is a container for a single SQL
SELECT statement. Nodes live under Pipes.
A query in a Node can read data from Data Sources or from other Nodes.
What should I use Nodes for?¶
Nodes allow you to break your query logic down into multiple, smaller queries. You can then chain Nodes together to build the logic incrementally.
Each Node can be developed & tested individually. This makes it much easier to build complex query logic in Tinybird as you avoid creating large monolithic queries with many sub-queries.
You can create as many Nodes in a Pipe as you need.
Creating Nodes in the UI¶
This section describes how to create a Node in the UI.
When you create a Pipe, the UI will create new Nodes for you with a placeholder query. To save the Node, write your query in the Node query box (see Mark 1 below), and click Run (see Mark 2 below).
Creating Nodes in the CLI¶
This section describes how to create a Pipe in the CLI.
To create Nodes on the command line, you will need your Pipes defined as files. To add a new node, edit the
.pipe file and add a new Node block.
A Node block consists of a
Below is an example of a Node block:
NODE aggregate_by_product_id DESCRIPTION > Create a count of searches aggregated by the product ID SQL > SELECT product_id, count() as total FROM search_events GROUP BY product_id ORDER BY total DESC