Public
Like
alexBlogs
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of cheatsheet branch: v11View latest version
with events as (
select * from {{ref('events')}}
{% if is_incremental() %}
where event_timestamp >= (select max(event_timestamp)::date from {{this}})
{% endif %}
)
--rest of model...
Unique Key (Incremental Models docs)
{{
config(
materialized='incremental',
unique_key='date_day'
)
}}
select
date_trunc('day', event_at) as date_day,
count(distinct user_id) as daily_active_users
from {{ ref('app_data_events') }}
{% if is_incremental() %}
-- this filter will only be applied on an incremental run
-- (uses >= to include records arriving later on the same day as the last run of this model)
where date_day >= (select coalesce(max(date_day), '1900-01-01') from {{ this }})
{% endif %}
group by 1
dbt run --full-refresh --select my_incremental_model+
I probably want to avoid packages, but if you need codegen or utils, create a packages.yml
file in the dir as the project yaml, and run dbt deps
.
packages:
- package: dbt-labs/codegen
version: 0.10.0
Run dbt deps
. And then here's the command line
dbt --quiet run-operation generate_source --args '{"table_names": ["orders"]}' > models/staging/jaffle_shop/_sources.yml