A Rudder CLI project directory for storing the SQL model YAML resources
Important: At least one Reverse ETL source in the RudderStack dashboard using the data warehouse you want to query — RudderStack uses the connection credentials used to set up the warehouse account this source to fetch the account ID. An example is shown below:
List Reverse ETL accounts
Before creating a SQL model resource, identify the account ID for the warehouse you want to connect to.
Use the following command to list all accounts linked to your workspace:
./rudder-cli workspace accounts list
This command displays all available accounts along with their IDs. Make note of the account ID that corresponds to your target warehouse — you will need this for the resource configuration.
Create the resource file
Create a new YAML file in your project folder containing the SQL model configuration. This file should have the following structure:
version:"rudder/v0.1"kind:"retl-source-sql-model"metadata:name:"product-purchases-model"spec:id:"product-purchases-mode"display_name:"Product Purchases SQL Model"primary_key:"user_id"description:"SQL model for product purchases"source_definition:"postgres"enabled:trueaccount_id:"2rzPI1ARibivIvNH5DSpAKGTATy"sql:| SELECT
user_id,
event_name,
event_type,
timestamp,
properties,
pruduct_id
FROM
user_events
WHERE
timestamp >= CURRENT_DATE() - INTERVAL 180 DAY
ORDER BY
timestamp DESC
Use external files: For complex queries, use the file option to keep your SQL in separate .sql files for better syntax highlighting and version control.
Descriptive IDs: Choose clear, descriptive IDs that reflect the model’s purpose.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.