Load entity data with a pipeline
Read the machines dataset in a Batch pipeline, Upsert it into iot_machine, and verify the Data tab.
The previous lesson defined the structure of iot_machine. Now create a source dataset and load two rows through a Batch pipeline's Entity output. Keep the entity and dataset in the same collection so both are available in the component library.
Prerequisites
- The
iot_machineentity from the previous lesson idconfigured as its Identity Key- Permission to create datasets and pipelines in the practice collection
Create the machines source dataset
- Open the practice collection from Collections.
- Select Add item → Dataset → Table.
- Enter the name
machinesunder Basic information, then select Next. - Create this schema.
| Column | Data type | Nullability | Purpose |
|---|---|---|---|
id | Text | NOT NULL | Entity identity key |
sensor_count | Bigint | NULL | Number of attached sensors |
reading_count | Bigint | NULL | Cumulative readings |
latest_recorded_at | Text | NULL | Source ISO date string |
anomaly_count | Bigint | NULL | Cumulative anomalies |
latest_health_score | Double | NULL | Latest health score |
- Select Create.
- Download machines.csv, or save the following content with that filename.
id,sensor_count,reading_count,latest_recorded_at,anomaly_count,latest_health_score
machine_001,1,120,2026-07-01T09:00:00,2,0.92
machine_002,2,80,2026-07-01T09:05:00,0,0.99
- Open
machinesand add the CSV under Data → Upload. - Confirm that Data shows two rows.
The source stores latest_recorded_at as Text while the entity uses Timestamp. The pipeline Code converts that type.
Create a Batch pipeline
- Open Data → Pipelines.
- Select Create.
- In Select pipeline collection, choose the collection containing
machinesandiot_machine. - Keep the pipeline type set to Batch.
Create Python Code
- Drag Quick add → Code → Python from the component library to the canvas.
- Enter the name
map_machines_to_iot_machine. - Use this code.
import polars as pl
def run(machines, *, options=None, contexts=None):
output = machines.with_columns(
pl.col("id").cast(pl.Utf8),
pl.col("sensor_count").cast(pl.Int64),
pl.col("reading_count").cast(pl.Int64),
pl.col("latest_recorded_at").str.to_datetime(strict=False),
pl.col("anomaly_count").cast(pl.Int64),
pl.col("latest_health_score").cast(pl.Float64),
)
return {"iot_machine": output}
The runtime passes pipeline input keys as keyword arguments. Input key machines must match function argument machines, and returned key iot_machine must match the output key.
Connect input, Code, and Entity
- Add
machinesfrom the collection section of the component library. - Connect its right handle to the Code node's left handle.
- Add the
iot_machineentity displayed as CNC machine. - Connect the Code node's right handle to
iot_machine. - In the Code node's Options, confirm input key
machinesand output keyiot_machine. - Confirm write mode Upsert on the Entity output.
The pipeline has one source, one transformation, and one Entity output.
Loading the diagram. Mermaid source:
flowchart LR
accTitle: Pipeline from source dataset to entity
accDescr: Python Code transforms the machines source dataset to the entity schema and upserts the result into iot_machine.
dataset[(machines<br/>source dataset)] -->|input key machines| code[map_machines_to_iot_machine<br/>Python Code]
code -->|output key iot_machine| entity[(iot_machine<br/>Entity Upsert)]Save and run
- Select Save and name the pipeline
load_iot_machines. - Select Run now.
- Wait for top-level status Ready and latest run Success.
- Confirm that step
map_machines_to_iot_machinealso succeeded.
Upsert updates an existing row when the same id arrives again. Running the pipeline again must not create duplicate machine_001 or machine_002 rows.
Verify the Data tab
- Return to Ontology → Modeling.
- Select the CNC machine node in the practice collection.
- Open Data and refresh if needed.
- Confirm these two rows.
| id | sensor_count | reading_count | anomaly_count | latest_health_score |
|---|---|---|---|---|
machine_001 | 1 | 120 | 2 | 0.92 |
machine_002 | 2 | 80 | 0 | 0.99 |
Graph synchronization runs in the background, so the nodes may appear in Graph Explorer shortly afterward.
Self-check
- Two rows are uploaded to
machines. - Input key and function argument are both
machines. - Return key and Entity output key are both
iot_machine. - Write mode is Upsert.
- Status is Ready and the latest run is Success.
- Two rows appear under
iot_machineData.
Next lesson
Next, define a relation from iot_sensor to iot_machine and load its structural columns through a Relation output.