diff --git a/dbt/models/intermediate/int_contributions_to_congressional_candidates.sql b/dbt/models/intermediate/int_contributions_to_congressional_candidates.sql new file mode 100644 index 0000000..4d7958a --- /dev/null +++ b/dbt/models/intermediate/int_contributions_to_congressional_candidates.sql @@ -0,0 +1,49 @@ +/* + The purpose of this intermediate model is to track contributions to Congressional candidates from Committee-filers only. +*/ + +with candidates as ( + /* grab all Congressional candidates only */ + + select * from {{ ref('stg_candidate_master') }} where cand_office in ('H', 'S') + +) + +, contributions as ( + + select * from {{ ref('stg_contributions_from_committees_to_candidates') }} + +) + +, committees as ( + + select * from {{ ref('stg_committee_master') }} + +) + +, combined as ( + + select + candidates.cand_id, + candidates.cand_name, + candidates.cand_pty_affiliation, + candidates.cand_election_yr, + candidates.cand_office_st, + candidates.cand_office, + candidates.cand_office_district, + contributions.cmte_id, + committees.cmte_nm, + committees.cmte_pty_affiliation, + contributions.tran_id, + contributions.transaction_tp, + contributions.state as contributor_state, + contributions.transaction_amt + + from candidates + left join contributions on candidates.cand_id = contributions.cand_id + left join committees on contributions.cmte_id = committees.cmte_id + +) + +select * from combined + diff --git a/dbt_project.yml b/dbt_project.yml index 2b51c65..1393eb5 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -34,7 +34,7 @@ models: # Config indicated by + and applies to all files under models/example/ staging: +materialized: view - intermeidate: + intermediate: +materialized: view marts: +materialized: table