Skip to content

Commit

Permalink
Merge pull request #4 from lironesamoun/dbt/models
Browse files Browse the repository at this point in the history
(dbt) Add first dbt model for data
  • Loading branch information
lironesamoun authored Apr 17, 2023
2 parents f2f6d87 + 91e96b1 commit 3d06eb7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbt/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ clean-targets: # directories to be removed by `dbt clean`
# as tables. These settings can be overridden in the individual model files
# using the `{{ config(...) }}` macro.
models:
my_new_project:
global_terrorism:
# Applies to all files under models/example/
example:
materialized: view
8 changes: 8 additions & 0 deletions dbt/models/production/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2

sources:
- name: production
database: de-capstone-project-23
schema: globalterrorism_raw
tables:
- name: data
25 changes: 25 additions & 0 deletions dbt/models/staging/global_terrorism_lite.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{ config(materialized="table") }}

select
eventid as event_id,
case when iday != 0 then cast(concat(iyear, '-', imonth, '-', iday) as date) else null end as event_date,
country_txt as country,
region_txt as region,
provstate,
city,
summary,
cast(crit1 as integer) as reason1,
cast(crit2 as integer) as reason2,
cast(crit3 as integer) as reason3,
cast(doubtterr as integer) as doubt_terrorism_proper,
attacktype1_txt as attack_type,
targtype1_txt as target_type,
weaptype1_txt as weapon_type,
gname as perpetrator_group_name,
cast(nkill as integer) as nkill,
cast(nwound as integer) as nwound,
cast(ishostkid as integer) as ishostkid,
cast(nhostkid as integer) as nhostkid
from {{ source("staging", "data") }}

{% if var("is_test_run", default=true) %} limit 100 {% endif %}
8 changes: 8 additions & 0 deletions dbt/models/staging/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2

sources:
- name: staging
database: de-capstone-project-23
schema: globalterrorism_raw
tables:
- name: data
5 changes: 5 additions & 0 deletions dbt/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packages:
- package: dbt-labs/dbt_utils
version: 1.0.0
- package: calogica/dbt_date
version: 0.7.2

0 comments on commit 3d06eb7

Please sign in to comment.