# How to Create a Model in RudderStack

<p>This guide lists the steps to create a SQL model in RudderStack.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="create-a-new-model">Create a new model</h2><ol>
<li>Log in to the <a href="https://app.rudderstack.com" >RudderStack dashboard</a>.</li>
<li>From the left navigation bar, go to <strong>Activate</strong> &gt; <strong>Models</strong> and click <strong>New model</strong>.</li>
<li>Configure the settings explained in the following sections:</li>
</ol>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="1-select-source">1. Select source</h3><p>Select the warehouse source for which you want to create a model. RudderStack supports the Models feature for the following sources:</p>
<ul>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/amazon-redshift/" >Amazon Redshift</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/google-bigquery/" >Google BigQuery</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/postgresql/" >PostgreSQL</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/snowflake/" >Snowflake</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/databricks/" >Databricks</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/trino/" >Trino</a></li>
</ul>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="2-specify-warehouse-credentials">2. Specify warehouse credentials</h3><p>Specify the warehouse credentials to authenticate RudderStack. See the <strong>Configure warehouse credentials</strong> section of the <a href="https://www.rudderstack.com/docs/sources/reverse-etl/#supported-reverse-etl-sources" >source-specific documentation</a> (for example, <a href="https://www.rudderstack.com/docs/sources/reverse-etl/amazon-redshift/#configuring-the-connection-credentials" >Redshift</a>) for more details.</p>

<html lang="en">
<blockquote class="info">
  <div class="tip-quote">
    
    <div class="tip-text">Once you select or add your warehouse credentials and click <strong>Next</strong>, RudderStack will validate them before you can proceed with the setup. See <a href="#faq" >FAQ</a> for more information on these validations.</div>
  </div>
</blockquote>

</html>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="3-specify-model-name">3. Specify model name</h3><ul>
<li>Assign a name to uniquely identify the source in the RudderStack dashboard.</li>
<li>Select the source type to <strong>Model</strong> and click <strong>Continue</strong>.</li>
</ul>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="4-configure-model">4. Configure model</h3><ol>
<li>Enter an optional model description.</li>
<li>Specify the custom SQL query in <strong>Query</strong> section.</li>
<li>Click <strong>Run Query</strong> to fetch the data preview.</li>
<li>Select the <strong>Primary key</strong> to use a column that uniquely identifies your warehouse records.</li>
</ol>

<blockquote class="warning">
  <div class="tip-quote">
    
    <div class="tip-text">You can set a primary key only after you run the SQL query successfully using the <strong>Run Query</strong> option.</div>
  </div>
</blockquote>

<figure class="image--main "  >
    <a 
         href="/docs/images/data-pipelines/model-source-configuration.webp"
        
        >
        <img src="/docs/images/data-pipelines/model-source-configuration.webp" 
         alt="Model configuration"  
         
         
        decoding="async" loading="lazy" class="img-shortcode"/>
    </a>
    
</figure>

<p>Note the following:</p>
<ul>
<li>The <strong>Preview</strong> section displays the preview of the 50 resultant rows in a paginated format.</li>
<li>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.</li>
<li>You don&rsquo;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.</li>
</ul>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="5-review-and-complete-setup">5. Review and complete setup</h3><p>To make any changes to the warehouse credentials or model configuration, click the edit icon present next to those sections.</p>

<figure class="image--main "  >
    <a 
         href="/docs/images/data-pipelines/edit-model-configuration.webp"
        
        >
        <img src="/docs/images/data-pipelines/edit-model-configuration.webp" 
         alt="Edit model configuration"  
         
         
        decoding="async" loading="lazy" class="img-shortcode"/>
    </a>
    
</figure>

<p>Once you have reviewed your configuration, click <strong>Create source</strong> to complete the setup.</p>
<p>To change the query, description, credentials, or alerts later, see <a href="https://www.rudderstack.com/docs/activate/models/update-model/" >How to Update a Model</a>.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="6-connect-model-to-destination">6. Connect model to destination</h3>

<p>To start using the newly-created source, you can connect it to:</p>
<ul>
<li>A new <a href="https://www.rudderstack.com/docs/destinations/overview/" >destination</a>, or</li>
<li>An existing destination that is <strong>not already connected</strong> to any other source.</li>
</ul>
<p>To connect to a destination later, click <strong>Done</strong> on the top right:</p>

<figure class="image--main "  >
    <a 
         href="/docs/images/retl-sources/created-source.webp"
        
        >
        <img src="/docs/images/retl-sources/created-source.webp" 
         alt="Next steps"  
         
         
        decoding="async" loading="lazy" class="img-shortcode"/>
    </a>
    
</figure>

<p>You will then be redirected to the <strong>Overview</strong> page of the source where you will see the option of connecting it to a new or existing destination.</p>

<figure class="image--main "  >
    <a 
         href="/docs/images/retl-sources/add-destination.webp"
        
        >
        <img src="/docs/images/retl-sources/add-destination.webp" 
         alt="Add destination"  
         
         
        decoding="async" loading="lazy" class="img-shortcode"/>
    </a>
    
</figure>

<p>See <a href="https://www.rudderstack.com/docs/data-pipelines/reverse-etl/developer-guides/retl-connection-setup/" >Set up Reverse ETL Connection</a> section for more information.</p>

<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="faq">FAQ</h2><!-- end-chunk -->
<!-- begin-chunk -->
<h4 id="what-do-the-three-validations-under-verifying-credentials-imply">What do the three validations under Verifying Credentials imply?</h4><p>Once you proceed after entering the connection credentials, you will see the following validations under the <strong>Verifying Credentials</strong> option:</p>

<figure class="image--main "  >
    <a 
         href="/docs/images/retl-sources/retl-credentials-validate.webp"
        
        >
        <img src="/docs/images/retl-sources/retl-credentials-validate.webp" 
         alt="Validating credentials"  
         
         
        decoding="async" loading="lazy" class="img-shortcode"/>
    </a>
    
</figure>

<p>These options are explained below:</p>
<ul>
<li><strong>Verifying Connection</strong>: Indicates that RudderStack is trying to connect to the warehouse with the information specified in the connection credentials.</li>
</ul>

<blockquote class="warning">
  <div class="tip-quote">
    
    <div class="tip-text">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.</div>
  </div>
</blockquote>
<ul>
<li>
<p><strong>Able to List Schema</strong>: Checks if RudderStack is able to fetch all schema details using the provided credentials.</p>
</li>
<li>
<p><strong>Able to Access RudderStack Schema</strong>: Checks if RudderStack has the required access to the <code>_RUDDERSTACK</code> / <code>_rudderstack</code> schema (depending on your warehouse). To create the schema, run all commands listed in the <strong>Permissions</strong> section of the respective Reverse ETL source documentation:</p>
<ul>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/google-bigquery/#granting-permissions" >BigQuery</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/databricks/#granting-permissions" >Databricks</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/postgresql/#granting-permissions" >PostgreSQL</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/amazon-redshift/#granting-permissions" >Redshift</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/snowflake/#granting-permissions" >Snowflake</a></li>
<li><a href="https://www.rudderstack.com/docs/sources/reverse-etl/trino/#granting-permissions" >Trino</a></li>
</ul>
</li>
</ul>

<blockquote class="warning">
  <div class="tip-quote">
    
    <div class="tip-text">If this option gives an error, verify if you have successfully created the <code>_RUDDERSTACK</code> / <code>_rudderstack</code> schema and given RudderStack the required permissions to access it.</div>
  </div>
</blockquote>

