Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading