Models

Run custom SQL queries on your warehouse and send resulting data to the specified destinations.

RudderStack’s Models feature lets you create models by defining custom SQL queries. You can then run these queries on your warehouse and send the resulting data to specific destinations. You can create as many models and reuse them with their corresponding Reverse ETL sources.

With this feature, you can:

  • Build models with complex SQL queries using an intuitive UI.
  • Manage views of all models synced to different destinations in one place.
  • Reuse existing models in multiple connections.

Create new model

  1. Log in to the RudderStack dashboard.
  2. From the left navigation bar, go to Activate > Models and click New model.
  3. Configure the settings explained in the following sections:

Select source

Select the warehouse source for which you want to create a model. RudderStack supports the Models feature for the following sources:

Specify warehouse credentials

Specify the warehouse credentials to authenticate RudderStack. See the Configure warehouse credentials section of the source-specific documentation (for example, Redshift) for more details.

info
Once you select or add your warehouse credentials and click Next, RudderStack will validate them before you can proceed with the setup. See FAQ for more information on these validations.

Specify model name

  • Assign a name to uniquely identify the source in the RudderStack dashboard.
  • Select the source type to Model and click Continue.

Configure model

  1. Enter an optional model description.
  2. Specify the custom SQL query in Query section.
  3. Click Run Query to fetch the data preview.
  4. Select the Primary key to use a column that uniquely identifies your warehouse records.
warning
You can set a primary key only after you run the SQL query successfully using the Run Query option.
Model configuration

Note the following:

  • The Preview section displays the preview of the 50 resultant rows in a paginated format.
  • You can add single-line/multiline comments above the query. However, RudderStack supports only multiline comments at the end of the query. Support for single-line comments is coming soon.
  • You don’t need to add a semi-colon at the end of a query. RudderStack handles this automatically before running the query on the warehouse data.

Review and complete setup

To make any changes to the warehouse credentials or audience configuration, click the edit icon present next to those sections.

Edit audience configuration

Once you have reviewed your configuration, click Create source to complete the setup.

Connect model to destination

You can connect this source to an existing or new destination to start using it. To connect to a destination later, click Done on the top right.

Next steps

You will then be redirected to the Overview page of the source where you get the option of connecting it to an existing or new destination.

Add destination

See Set up Reverse ETL Connection section for more information.

Update model

  1. Go to the Configuration tab of the model source.
  2. To change the model description, click the edit icon in the Configuration settings.
  3. Click Edit query to change or update the model settings and primary key.
warning

Note that:

  • You can set a primary key only after you run the updated SQL query successfully using the Run Query option.
  • If you update the model’s query, you also need to check and update the relevant destination mappings in the Schema tab of the connection page.
  • After updating the configuration, the next sync will be a full sync. To validate if the query is running fine, you can manually trigger a full sync.

Go to the Settings tab to:

  • Get your source ID.
  • Change your warehouse credentials.
  • Set up custom alerts for your Reverse ETL source.
  • Delete the source permanently.
warning
You cannot delete a source that is connected to any destination.
Edit source settings

FAQ

What do the three validations under Verifying Credentials imply?

Once you proceed after entering the connection credentials, you will see the following validations under the Verifying Credentials option:

Validating credentials

These options are explained below:

  • Verifying Connection: Indicates that RudderStack is trying to connect to the warehouse with the information specified in the connection credentials.
warning
If this option gives an error, it means that one or more fields specified in the connection credentials are incorrect. Verify your credentials in this case.
  • Able to List Schema: Checks if RudderStack is able to fetch all schema details using the provided credentials.

  • Able to Access RudderStack Schema: Checks if RudderStack has the required access to the _RUDDERSTACK / _rudderstack schema (depending on your warehouse). To create the schema, run all commands listed in the Permissions section of the respective Reverse ETL source documentation:

warning
If this option gives an error, verify if you have successfully created the _RUDDERSTACK / _rudderstack schema and given RudderStack the required permissions to access it.

Questions? Contact us by email or on Slack