# Transforms

> Build new nodes from existing ones in DDL: SQL, Merge, Union, Identity Matching, scripts, Duplicate and node actions, then export, transfer or publish the result.

Source: https://dev.delman-guide.pages.dev/transforms

A transform builds a new node from one or more existing nodes: a join, a union, a SQL query, a script or a chain of small steps such as filters. DDL stores how the node is built, draws an edge from each input to it, and builds it again every time an input gets new data. This page lists every transform, how to create it and how to change it later, and the ways to send a node's data out of DDL.

Most transforms start from **Transform** in the Pipeline toolbar, which opens **Transform Data** ("Transform data from different source").

> Screenshot: The Transform Data dialog with five cards: Merge (Add information through join), Union (Append data together), Identity Matching (Matched by identity), Use Script (Use script to join data) and SQL Query (Write SQL query). Transform › Transform Data: five ways to build a node from other nodes.

## Choose a transform

| To | Use | Start from |
|---|---|---|
| Write the logic yourself, in SQL | **SQL Query** | **Transform** › **SQL Query**, or the **SQL Query** page |
| Add columns from another table, matched on key columns | **Merge** | **Transform** › **Merge** |
| Stack tables with the same columns on top of each other | **Union** | **Transform** › **Union** |
| Link records that describe the same customer, product or store | **Identity Matching** | **Transform** › **Identity Matching** |
| Run your own Python code on one or more nodes | **Use Script** | **Transform** › **Use Script** |
| Start a new node from a copy of an existing one | **Duplicate** | The node's side panel |
| Filter, sort, rename, group or clean a node step by step, without code | Actions | The node page › **Search Action** |

The AI Assistant can build these nodes for you too, after you approve its plan. See [AI Assistant](/ai-assistant).

### Rules for every transform

- You need the **Modify Project** permission, and the project must not be locked.
- **Merge**, **Union** and **Identity Matching** are greyed out until the project has at least two nodes. **Use Script** is not available on Free accounts.
- The inputs must be ready. If one is still running, scheduled or failed, DDL answers *Some data sources are still processing, being scheduled or broken*.
- The new node's name must be unique in the project: *Node with the same name already exists in this project*.
- The transform editors work on a phone, but say *Editing works best on a tablet or a computer.*

To change a transform later, click its node, open the ⋮ menu of the side panel and choose its edit item:

| Node made with | ⋮ menu item | Opens |
|---|---|---|
| SQL Query | **Edit SQL Query** | The SQL editor with the node's query |
| Merge | **Edit Merge Data** | The Merge editor, filled in |
| Union | **Edit Union** | The Union editor, filled in |
| Identity Matching | **Continue Identity Match** | The **Matching Records** page |
| Use Script | **Edit Script** | The script's parameters |
| Duplicate, or an imported table | **Edit Source** | Shown but disabled |

The edit item is disabled while the node or its downstream nodes are busy, and for people who may not edit the node.

## SQL Query

**Transform** › **SQL Query** opens the project's **SQL Query** page. Write a query that names nodes in backticks, such as `` `demo_orders` ``, run it, then **Save** it as a node. The node runs the query again whenever one of the nodes it names gets new data. [SQL Query](/sql) explains the editor.

## Merge

Merge joins two tables side by side on key columns, like a SQL join. Several merges can be chained in one node.

1. Click **Transform** › **Merge**. The **Merge Table** page opens (`/projects/<id>/merge`).
2. Under **Select Data to Merge**, in the **Join nodes** card, choose the **Left Table**, the join type (the icon between the two tables; **Inner Join** until you pick another) and the **Right Table**. The two fields then read *Table 1:* and *Table 2:* with the node names, and previews of both tables appear on the left.
3. Under **On key columns**, pick the column of each table that must match, for example `customer_id` and `customer_id`. **+ Add key column** adds another condition. The key columns are coloured in the previews.
4. To join a third table, click **+ Add Merge**. The left table of the new join is one of the tables already joined.
5. Click **Preview**. Under **Select Columns to Include**, untick the columns you do not need. **Node Result** counts the columns that remain.
6. Click **Merge Data**. In **Save Merge Data Node**, type the **Node Name** and click **Save**.

> Screenshot: The Merge Table page: on the right, Select Data to Merge with demo_orders as Table 1, the Left Join icon and demo_customers as Table 2, joined on customer_id and customer_id, with + Add key column, + Add Merge, Cancel and Preview; on the left, the previews of demo_orders and demo_customers with the customer_id columns in colour. Merge: pick the tables, the join type and the key columns; the previews show the keys in colour.

| Join type | Keeps |
|---|---|
| **Inner Join** | Only rows whose keys match in both tables |
| **Left Join** | All rows of the left table, with the right table's columns where the keys match |
| **Right Join** | All rows of the right table, with the left table's columns where the keys match |
| **Full Join** | All rows of both tables |
| **Cross Join** | Every combination of rows. It has no key columns. |
| **Left Join Exclusive** | Left rows that have no match on the right |
| **Right Join Exclusive** | Right rows that have no match on the left |
| **Full Join Exclusive** | Rows of either table that have no match in the other |

DDL returns to the pipeline and says *Successfully created node …, click here to view the node details*. To change the joins later, use **Edit Merge Data**; **Merge Data** then updates the node (*Node updated successfully*).

## Union

Union appends tables with the same columns, like `UNION ALL` with a column mapping.

1. Click **Transform** › **Union**. The **Union** page opens (`/union/<projectId>`).
2. Choose the first node in **Select dataset**. Its columns become the **Union Output** on the left ("6 columns in union").
3. Click **+ Add new dataset** and choose the next node. DDL proposes one of its columns for each output column. Check every row: pick the column that belongs there, or **(no match)** to leave that output column empty for this dataset. Repeat for more datasets.
4. Adjust the output if needed: rename an output column in its field, remove it with ✕, or add one with **Add Column** at the bottom.
5. Click **Save**. In **Save Union**, type a **Data name** of at least three characters and click **Save**.

> Screenshot: The Union page: Union Output with 6 columns in union on the left; the datasets demo_orders and demo_orders_archive side by side, each of their columns mapped to the output column of the same name; + Add new dataset, Cancel and Save at the top and Add Column at the bottom. Union: one column per dataset, each mapped to the output columns on the left.

- Columns mapped to the same output column must have the same data type. A mismatch is highlighted and **Save** stays disabled.
- Output column names must be unique and not empty. Duplicates are reported: *Duplicate column names detected: "…"*.
- The Union editor lives at `/union/<projectId>`, outside `/projects/`. Open it through **Transform** › **Union**, or **Edit Union** for an existing node (`/union/<projectId>/<nodeId>`). Saving an edit says *Updated union node …*.

## Identity Matching

Identity Matching links the records of one dataset to a reference dataset, for example the customers of a web shop to the customer master list, even when names are spelled differently. Each matched record gets the ID of its reference record. Matching runs in two phases: you set it up once, then you review and complete the matches.

### Set up the matching

1. Click **Transform** › **Identity Matching**. The **Identity Matching** panel on the right takes you through three steps; ⓘ next to each step explains it.
2. **Choosing Datasets**: in **Select a Dataset To Match**, choose the records to identify, for example `demo_customers`. In **Select The Reference Dataset**, choose the master list, for example `crm_customers`. Click **Next**.
3. **Match columns**: for each pair of columns that hold the same information, such as `customer_name` and `full_name`, set:
   - **Matching columns**: the column of the **Selected Dataset** and of the **Reference Dataset**.
   - **Weight**: how much this pair counts in the overall score (1 or more).
   - **Minimum Threshold**: the lowest score, from 0 to 100, at which this pair counts as matching during automation.

   Each pair is numbered (**Match 1**, **Match 2**) and gets a colour, shown next to **Color**, that marks its columns in the previews on the left. **Add new match columns** adds a pair, and the bin icon removes one. **Global Threshold** (0 to 100) is the lowest overall weighted score that a match needs. Click **Next**.
4. **Identification**: choose the unique ID column of each dataset under **Use existing column in selected dataset as unique ID** and **Use existing column in reference dataset as unique ID**. For records that you add to the reference dataset later, tick **Auto-generated ID** and set the ID format, for example `Customer-{{ id }}`. Click **Next**.
5. In **Save Result as**, type the **Node Name** and click **Save**.

> Screenshot: The Identity Matching panel in the Match columns step: Global Threshold 60, and Match 1 with the matching columns customer_name and full_name, Weight 2 and Minimum Threshold 70, Add new match columns, and Cancel, Back and Next; on the left, previews of demo_customers and crm_customers with the two matched columns in colour. Match columns: tell DDL which columns to compare and how much each pair counts.

### Match the records

DDL opens **Matching Records** for the new node. It lists the records of the selected dataset with their best candidate from the reference dataset and a score, such as *87 Confidence*, or *Manual Match* for a match you picked yourself.

- **Select Match** shows the candidates for one record so that you can pick one.
- **Automate Match** matches the remaining records using your thresholds. While it runs, the button reads **Running Automation**, and **Stop Automation** stops it; matches already made are kept.
- Tick records, or **Select All**, then **Match** or **Unmatch** them together. Unmatching cannot be undone. The history icon (**Bulk History**) lists these bulk jobs.
- **Reference Dataset** shows the reference records, with buttons to edit or delete each one. **Back to Project View** returns to the pipeline.

### Finalize

While you match, the node shows as **Running** on the canvas and the nodes downstream wait. When you are done, click the node on the canvas and, on the **Data** tab of its side panel, click **Finalize** under **Finalize Identity Match**. DDL confirms with *Success Finalize Identity Match*, the node becomes **Success** and the nodes downstream run.

To go back to the matches later, use **Continue Identity Match** in the node's ⋮ menu. **Edit Configuration** on the **Matching Records** page changes the setup; it is only available once the node is finalized ("Please finalize the node first in the pipeline to edit the configuration").

## Use Script

**Use Script** runs a Python combine script that you upload. Scripts belong to your account, so you can use them in all your projects.

:::note[Availability]
Not available on Free accounts: **Use Script** is greyed out, and DDL answers *You may not use script to define custom combines*.
:::

1. Click **Transform** › **Use Script**. The **Use Script** side panel opens on the **Script List** tab.
2. Click **Add New Script**. In **Add New Combine Script**, paste your code in **Code** or upload a `.py` file, type a **Script Name** (letters, numbers and underscores only) and click **Save Script**.
3. Open the **Select Script** tab and choose the script.
4. Under **Data source**, choose a node for each input that the script declares (**Select data source**). **View** shows the data of the chosen node.
5. Fill in the script's parameters under **Additional parameter**, if any, type the **New Data Name** and click **Execute Script**.

> Screenshot: The Use Script side panel on the Script List tab with the Add New Script button, the Search Script Name box, the sort Last Updated and the message You don't have any available script. Please upload at least one script.. Use Script starts on the Script List. Add a script before you can select it.

A combine script defines one class based on DDL's `Combiner`. `tables` lists the input nodes, `params` the optional parameters, and `run` writes the new node's table:

```python title="total_per_city.py"

from analytics.combine.base import Combiner
from app import current_ds

class TotalPerCity(Combiner):
    """Sums order amounts per city."""

    # One entry per input node, in the order you pick them under Data source
    tables = [{"name": "orders", "desc": "orders with a city column"}]
    # Optional parameters, read with self["key"]
    params = {"amount_col": {"description": "Amount column", "default": "amount"}}

    def run(self):
        (orders,) = self.SOURCES  # table names of the input nodes
        df = pd.read_sql(f'SELECT * FROM "{orders}"', current_ds.engine)
        out = df.groupby("city", as_index=False)[self["amount_col"]].sum()
        out.to_sql(self.RESULT, current_ds.engine, index=False)  # the new node
```

The **Script List** tab has a search box, sorting and, per script, edit and delete. A node made with a script says *This node is result of … Transform Script*; change its parameters with **Edit Script** in its ⋮ menu.

## Duplicate a node

**Duplicate** creates a new transform node that starts as a copy of another node. Use it to transform a file or dataset node with [actions](#actions-on-the-node-page), or to try changes without touching the original.

1. Click the node and, in its side panel, click **Duplicate**.
2. Type a name in **Insert name for this new dataset** and click **Create**.

DDL adds the copy downstream of the original, and the confirmation links to its node page. On the node page of a file or dataset node, *Click here to transform this data* does the same and opens the copy's node page straight away.

Duplicate works on transform, file and dataset nodes once they have data (**Success** or **Created**).

## Actions on the node page

Every transform node keeps a **recipe**: how the node is built (its origin, such as a merge or a copy), followed by a list of actions that run in order. Actions are small, no-code steps: filter rows, rename columns, group and aggregate, clean values. They are added on the node page (`/node/<nodeId>`) and work on any transform node, including imported tables and SQL nodes. File and dataset nodes take no actions: [duplicate](#duplicate-a-node) them first.

### Add an action

1. Open the node page: double-click the node, or click **View** in its side panel.
2. Click **Search Action** (magnifier icon) in the toolbar.
3. Type part of a name, or browse the list: recently used actions come first, then AI actions (if enabled), then all actions. Each entry has a one-line description.
4. Pick an action. Its panel opens on the right. Fill in its fields; for example **Filter** has **Add Filter** for each condition.
5. Click **Submit**. **Cancel** closes the panel; **Filter** and **Group By and Aggregate** also have **Clear** to empty the form.

> Screenshot: The node page of orders_clean with the Search Action dialog open: under RECENT the actions Rename Column and Filter, then under AI the actions AI Classify, AI Extract and AI Prompt, each with a one-line description. Search Action: recently used actions first, then AI actions (when they are turned on), then all actions, each with a short description.

DDL runs the new step (the node shows **Running**), then updates the nodes downstream. In a locked project the search box says *Action not Available on Project Locked*.

| Kind | Actions |
|---|---|
| Rows | **Filter**, **Sort**, **Handle Duplicates** (remove or keep duplicate rows), **Validate Primary Key** (check that columns form a unique key) |
| Columns | **Rename Column**, **Remove Column(s)**, **Reorder Column**, **Change Data Type**, **Create Equation from Column(s)** (a new column from Excel-style formulas), **Extract Key from JSON Column**, **Encrypt Column(s)**, **Decrypt Encrypted Column(s)** |
| Values | **Change Case**, **Replace Column Values**, **Remove Characters**, **Format Datetime**, **Datetime Difference**, **Standardize** |
| Totals | **Group By and Aggregate**, **Sum**, **Average**, **Count**, **Minimum**, **Maximum** |
| AI | **AI Classify**, **AI Extract**, **AI Summarize**, **AI Translate**, **AI Prompt**. Only when AI actions are turned on for your DDL; see [AI settings](/ai-settings). **Try 20 rows** tests one on a sample before you submit it. |

**Make Custom Action** (pencil icon) adds your own action as a Python script, with a **Custom Action Name** and a **Custom Action Script**. Custom actions belong to your account, appear in **Search Action** with an edit button, and are not available on Free accounts.

### Review, edit or remove actions

**Actions History** (clock icon) opens the list of the node's steps under **List of History**, starting with **Original Data Source**.

- Click a step to see the data as it was after that step. The page then says *You are looking at historical data after.* Use *Click here to go to the current data state* to return to the latest data.
- The arrow next to a step shows its parameters, for example the column, operator and value of a filter.
- The selected step has a ⋮ menu with **Edit Action** and **Delete Action** (not for people who may only view the project). Editing shows the data the step starts from (*You're currently editing an Action based on the following data.*). Deleting asks *Are you sure you want to delete this action ?*, and DDL rebuilds the node without that step.
- A failed step shows its error: *Unable to display the data as this action or its predecessor(s) failed to run successfully.* Edit or delete it to fix the node.

> Screenshot: The node page of orders_clean with the Actions History panel: Original Data Source, then the steps 1. Filter (quantity, gt, 0) and 2. Rename Column (amount renamed revenue), both Success and opened to show their parameters; the selected second step has a ⋮ menu. Actions History: every step of the recipe, with the data after each one.

### Standardize values

**Standardize** groups similar spellings of a column's values, such as `New York`, `new york` and `NEW-YORK`, into clusters and replaces each cluster with its most frequent value.

1. On the node page, choose **Standardize** in **Search Action**, pick the column in **Select Field** and click **Submit**.
2. DDL opens the Standardize page (`/standardize/<nodeId>/<actionId>`). Click a cluster to see its values and how often each appears.
3. To change the value a cluster becomes, click its pencil, type the new value and confirm with ✓.
4. To move values to another cluster, click **Move**, tick clusters or single values on the left, open the destination cluster on the right (**Pick a cluster for merge destination**) and click **Merge**. In the dialog, confirm **Merge**, or fill in new values and click **Merge to new cluster**.

The link with the node name at the top of the page returns to the node page.

## Send data out of DDL

These options sit in the ⋮ menu of a transform node's side panel, except **Transfer**, which is in the toolbar.

| Option | Sends | Runs |
|---|---|---|
| **Export Data** | The node's table to an export connection | After every successful run of the node, and on demand |
| **Transfer** | Tables from an import connection straight to an export connection, without a node in between | When it is created, whenever its source node is synced (by hand or on a schedule), and on demand |
| **Publish to Cloud** | The node's table to DDL's publish database, for BI tools | After every successful run of the node, until you unpublish it |
| **Download As** | A CSV, JSON or Excel file of the node | Once |
| **Data Repository** (button) | The node as a Data Repository dataset | Updated with every run; see [Save a project node](/data-repository#save-a-project-node) |

### Export Data

1. Click the node, open ⋮ and choose **Export Data**. The panel shows **Export Data to Sink** with the node's exports, and the node's data opens on the left (**Viewing Data on** *node*).
2. Click **Create New Export**.
3. In **Select Destination**, choose an export connection, or **Add New Sink** to create one. See [Connections](/connections).
4. Fill in where to write. For a database: **Schema**, **Table** (pick one, or type a new name), and **Sync method**: **Drop old data before inserting**, **Append new data** or **Insert new data and update existing data** (then **Upsert primary keys**).
5. **View Table** shows what the destination holds now. Click **Save**.

> Screenshot: The Export Data to Sink panel of orders_enriched next to the node's data: Create New Export and one export to the connection Reporting warehouse with Export successful, the on/off switch, the ⋮ menu, Schema public, Table orders_enriched, Export Method replace, On Row Error fail and the Export Now button. Each export has a switch, Export Now and a menu with its history.

Each export card shows its destination connection, its last status and where it writes (**Schema**, **Table**, **Export Method**), and has:

- a switch that turns the automatic export on or off,
- **Export Now** to export at once,
- a ⋮ menu with **View Destination**, **Export History**, **Edit Export** and **Delete**.

The cloud icon on the node shows the export's status on the canvas, and the **Export** column of the [List view](/pipeline-views#list-view) shows it for all nodes.

### Transfer to another connection

A transfer copies tables from an import connection to an export connection, for example from one database to another, without storing them in a node. It appears on the canvas as a round transfer node after its source node.

1. Click **Transfer** in the toolbar (on a phone: **⋯** › **Transfer to another connection**). The **Transfer to Other Connection** panel opens.
2. Under **Source connection**, choose the source node to read from. Only connection source nodes are offered. Under **Destination connection**, choose an export connection, or **Add new destination connection**. **Transfer route** turns to *Route ready*. Click **Next**.
3. In **Create New Transfer Node**, check **Transfer From** and **Transfer To**, then click **Add Transfer Item**. Fill in **Input** (what to read, for example a table or a query) and **Output** (where to write it), and click **Save**. Add as many items as you need, then click **Next**.
4. In **Save Transfer Node As**, type the name in **Save As** and click **Finish**.

> Screenshot: The Transfer to Other Connection side panel with the Transfer route at Route ready, Analytics warehouse (PostgreSQL) as Source connection and Reporting warehouse as Destination connection, and the Cancel and Next buttons. A transfer goes from a source connection to a destination connection.

The transfer node's side panel lists its items. ▶ runs one item again; an item that failed part-way may offer **Resume from last checkpoint** or **Restart from scratch**. The item's ⋮ menu has **View Logs**, **Edit** and **Delete**, and the panel's ⋮ menu has **Sync only failed transfer**, **Sync All** and **Delete Node**. The node's status sums up its items: it is **Failed** if one item failed.

### Publish to Cloud

**Publish to Cloud** copies the node's table to DDL's publish database, where BI tools can read it.

1. Click the node, open ⋮ and choose **Publish to Cloud**.
2. Type a table name in **Publish as** and click **Publish**.
3. Under **How to connect**, open a card for the connection details and a step-by-step guide: **Google Data Studio** (host, port, database name, user name and password) or **DDL REST API** (URL, HTTP method and headers).

Treat these details like a password: anyone who has them can read the data. **Unpublish** removes the published table.

:::note[Availability]
Publishing must be enabled on your DDL server. Otherwise **Publish** fails with *API not implemented for this server*.
:::

### Download As

Open ⋮ › **Download As**, choose the **File Type** (`csv`, `json` or `excel`), type a **File name** and click **Download**. **Preview** shows the data first.

## Troubleshooting

| Problem | Cause and fix |
|---|---|
| **Merge**, **Union** or **Identity Matching** is greyed out | The project has fewer than two nodes. |
| **Use Script** is greyed out | Scripts are not available on Free accounts. |
| *Some data sources are still processing, being scheduled or broken* | An input node is running, scheduled or failed. Wait, or fix and rerun it. |
| **Save** stays disabled in Union | A column has a different data type than the output column, an output name is empty, or two output names are the same. |
| The edit item in ⋮ is disabled | The node or a node downstream is busy, the project is locked, or you may not edit it. |
| **Download As**, **Export Data** and **Publish to Cloud** are greyed out | The node is not **Success** or **Created** (it failed, waits or runs), the project is locked, or you lack **Modify Project**. Fix or rerun the node first. |
| The Identity Matching node stays **Running** | It waits for you: click **Finalize** on the node's **Data** tab. |
| *Name may only contain letters, numbers, or underscores (_)* | Rename the script, for example `total_per_city`. |

## Related pages

  - [Pipeline canvas](/pipelines): Nodes, statuses, the side panel and reruns.
  - [SQL Query](/sql): Write SQL on the nodes of a project and save it as a node.
  - [List, Lineage and Groups](/pipeline-views): See what a transform reads and feeds.
  - [Connections](/connections): Export connections for exports and transfers.
