Skip to content

Instantly share code, notes, and snippets.

View drewbanin's full-sized avatar
📈
We're hiring!

Drew Banin drewbanin

📈
We're hiring!
View GitHub Profile
id region user_id price
1 US 1 5.00
2 US 1 7.50
3 US 2 12.99
id region user_id price returned_at
1 UK 3 6.50 2017-10-14 12:30:00
2 UK 4 3.99 NULL
3 UK 5 8.00 NULL
_dbt_source_table id region user_id price returned_at
analytics.uk_orders 1 UK 3 6.50 2017-10-14 12:30:00
analytics.uk_orders 2 UK 4 3.99 NULL
analytics.uk_orders 3 UK 5 8.00 NULL
analytics.us_orders 1 US 1 5.00 NULL
analytics.us_orders 2 US 1 7.50 NULL
analytics.us_orders 3 US 2 12.99 NULL
id user state is_CA is_PA is_NY
1 alice CA 1 0 0
2 bob CA 1 0 0
3 cathy NY 0 0 1
4 dave PA 0 1 0
-- USAGE:
{{
config(
materialized='insert',
dest_table='dbt_dbanin.table_to_insert_into',
date_field="timestamp",
start_date='2017-07-01'
)
}}
create table public.test as (
select 1 as id
);
create view public.test_view as (
select * from public.test
);
drop table public.test;
create table public.test as (
select 1 as id
);
-- NOTE: This is a late binding view. Note the
-- "WITH NO SCHEMA BINDING" clause at the
-- end of the `create view` statement.
create view public.test_view as (
select * from public.test
select * from public.test_view;
ERROR: relation "public.test" does not exist
create table public.test as (
select 2 as id
);
select * from public.test_view;
--SELECT (it worked!)
/*
This config will materialize this dbt model as a late-binding view.
Note that dbt models are by-default materialized as views, so it's
not always necessary to specify `materialized='view` here.
*/
{{ config(materialized='view', bind=False) }}
select * from public.test