Skip to content
Snippets Groups Projects
Commit f8a74147 authored by Israel Weeks's avatar Israel Weeks :speech_balloon:
Browse files

Merge branch 'chrissharp-main-patch-7c99' into 'main'

Add guidance on simple_cte usage

See merge request !7711
parents c453aa5a 84fe8a5f
No related branches found
No related tags found
1 merge request!7711Add guidance on simple_cte usage
Pipeline #1414919090 canceled
...@@ -678,7 +678,8 @@ The Data Team reservers the right to reject code that will dramatically slow the ...@@ -678,7 +678,8 @@ The Data Team reservers the right to reject code that will dramatically slow the
``` ```
- All `{{ ref('...') }}` statements should be placed in CTEs at the top of the file. (Think of these as import statements.) - All `{{ ref('...') }}` statements should be placed in CTEs at the top of the file. (Think of these as import statements.)
- This does not imply all CTE's that have a `{{ ref('...') }}` should be `SELECT *` only. It is ok to do additional manipulations in a CTE with a `ref` if it makes sense for the model - This does not imply all CTE's that have a `{{ ref('...') }}` should be `SELECT *` only. It is ok to do additional manipulations in a CTE with a `ref` if it makes sense for the model.
- If only a small number of fields are required from a model containing many columns then it can be performant to list them in the CTE, otherwise it is better to use `SELECT *`. To do this, the `simple_cte` macro can be used.
- If you want to separate out some complex SQL into a separate model, you absolutely should to keep things DRY and easier to understand. The config setting `materialized='ephemeral'` is one option which essentially treats the model like a CTE. - If you want to separate out some complex SQL into a separate model, you absolutely should to keep things DRY and easier to understand. The config setting `materialized='ephemeral'` is one option which essentially treats the model like a CTE.
...@@ -706,7 +707,7 @@ In normal usage, dbt knows the proper order to run all models based on the usage ...@@ -706,7 +707,7 @@ In normal usage, dbt knows the proper order to run all models based on the usage
}) })
}} }}
-- depends on: {{ ref('snowplow_sessions') }} -- depends_on: {{ ref('snowplow_sessions') }}
{{ schema_union_all('snowplow_', 'snowplow_sessions') }} {{ schema_union_all('snowplow_', 'snowplow_sessions') }}
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment