Search code examples
snowflake-cloud-data-platformdbt

Can I specify cluster keys for Snowflake in DBT within my yaml file?


According to current DBT documentation for Snowflake, you can configure clustering in Snowflake by providing cluster_by into a models' config.

config(
    materialized='table',
    cluster_by=['col_1']
  )

I would rather provide these values in the model's yml file, like so:

models:
  - name: my_model
  cluster_by: ['col_1']

Is this possible to do?


Solution

  • You should be able to do this using a config resource property in the .yml file.

    e.g.

    models:
      - name: my_model
        config:
          cluster_by: ['col_1']
    

    see https://docs.getdbt.com/reference/model-configs and https://docs.getdbt.com/reference/model-properties