Switchboard Docs
Data engineering

Create and manage models

Define and build a model from a source resource or SQL.

A model defines a table for a business subject, such as orders. Create one from a source resource, or write SQL to combine and reshape data.

Before you start

You need Builder, Admin, or a custom role that can edit models. For a resource model, connect and sync a source first. Decide what one row means and which column uniquely identifies it.

Create and configure the model

  1. Open Models. Select Add model in the model tree.
  2. Enter a Name and select Create.
  3. Select New source in the model editor. Under Source Type, choose Resource or Custom SQL.
  4. For Resource, select the source and its resource. For Custom SQL, enter your query.
  5. Select Generate preview and inspect the columns and sample rows.
  6. Select Save and create attributes to create properties from the result columns.
  7. Open the identifying property. Turn on Is Primary Key, then return to the model.
  8. Select Save in the model editor.

A property is a field on a model. The primary key is the property, or combination of properties, that identifies one row. The model cannot save without a primary key. See Set up properties for the field controls.

Format model SQL

For a Custom SQL source, select Format in its SQL editor to arrange the query for reading. Formatting does not run or validate the SQL. Use Generate preview to check the query before saving it.

Save and build

After saving the source, save the model separately. The model's Save action validates the definition and starts a build of the model and its downstream models. Use its adjacent menu to choose a different build scope.

Validation errors prevent the model from saving. Once it saves, open Models > Runs to inspect the resulting build. Wait for a successful build before querying the updated table.

Verify model rows and field types

Confirm that the model builds successfully and that its rows match the intended business subject. For an orders model, check that an order appears once and that the date and amount have the expected types. If the preview fails, check source sync status, SQL, and access to the input data.

Delete models

You need model deletion permission. Inspect downstream dependencies before removing a model used by other content.

  1. Open Models and select its Models tab.
  2. Open a model row's actions menu and choose Select items….
  3. Select the checkboxes for the models to remove, then select Delete selected.
  4. Review the selected items in the confirmation dialog, then select Delete.
  5. Check that the intended models have disappeared from the list. Select Done to leave selection mode.

When selecting a folder, review Also delete everything inside before confirming. Leaving it unchecked keeps the folder's contents and moves them to its parent. Selecting it deletes those contents too. If deletion fails, check which items remain and resolve the reported error before retrying.

Next step

Next, define an aggregation or build an explore. For SQL syntax and table references, see the SQL reference.

On this page