Version:

sql_models.yaml

Write SQL queries in a Profile project.

You can write queries within the YAML file or in standalone sql files and reference them in the sql_template model. They have the same keys as an input model.

This data is saved in the model folder of a Profiles project, along with any referenced sql files.

models:
    - name: name_of_sql_model       
      model_type: sql_template      
      model_spec:
          <model-spec>
KeyDescription
name
Required
SQL model name.
model_type
Required
Model type - set it to sql_template.
model_spec
Required
Model configuration. See SQL Model Spec for more information.

Example

models:
    - name: 
      model_type: sql_template
      model_spec:
          single_sql: |
              {% with input_table = this.DeRef("inputs/rsIDS) %}
                select 
                  id,
                  first,
                  last
                from
                  {{input_table}}
                where
                  id_type = 'email'
              {% endwith %}              
          ids:
              select: "id"
              type: user_id
              entity: user

Questions? Contact us by email or on Slack