Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the region test #119

Open
wants to merge 28 commits into
base: main-emea
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions macros/dollar_string_to_decimal.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro dollar_string_to_decimal(column_name) -%}
CAST(regexp_replace({{ column_name }}, '\\$', '') AS DECIMAL(16, 2))
{%- endmacro %}
4 changes: 3 additions & 1 deletion models/marts/airbnb/core/dim_listings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ final as (
listings.listing_last_scraped_at,
listings.calendar_last_scraped_at,
listings.calendar_updated_at,
listings.host_since,

-- Commend out due to error parsing
-- listings.host_since,

calendar_summary.minimum_minimum_nights,
calendar_summary.maximum_minimum_nights,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ calendar_summary as (
{% endfor %}

from calendar
where availability_date >= current_date()
-- where availability_date >= current_date()
where availability_date >= date('2022-01-01')
group by 1

)
Expand Down
8 changes: 5 additions & 3 deletions models/marts/core/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ models:
description: region name
tests:
- accepted_values:
values: ['AFRICA','MIDDLE EAST','ASIA','EUROPE','AMERICA']
severity: warn
values: ['AFRICA', 'MIDDLE EAST', 'ASIA', 'EUROPE', 'AMERICA']
- name: account_balance
tests:
- dbt_expectations.expect_column_values_to_be_within_n_stdevs:
sigma_threshold: 2 # (Optional. Default is 3)
- name: name
description: customer id
- name: address
Expand All @@ -28,7 +31,6 @@ models:
- name: market_segment
description: market segment of the customer


- name: dim_parts
description: Parts dimensions table
columns:
Expand Down
2 changes: 1 addition & 1 deletion models/marts/core/dim_customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final as (
customer.customer_key,
customer.name,
customer.address,
{# nation.nation_key as nation_key, #}
nation.nation_key as nation_key,
nation.name as nation,
{# region.region_key as region_key, #}
region.name as region,
Expand Down
3 changes: 3 additions & 0 deletions models/my_first_model.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ config(materialized='table') }}

select 42 as my_lucky_number
2 changes: 2 additions & 0 deletions models/my_second_model.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
select my_lucky_number*2 as doubled_lucky_number
from {{ ref('my_first_model') }}
4 changes: 2 additions & 2 deletions models/staging/airbnb/stg_airbnb_calendar.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ renamed as (
'date'
]) }} as calendar_id,
listing_id,
price as price_in_dollars,
adjusted_price as adjusted_price_in_dollars,
{{ dollar_string_to_decimal('price') }} as price_in_dollars,
{{ dollar_string_to_decimal('price') }} as adjusted_price_in_dollars,
minimum_nights,
maximum_nights,
boolean(available) as is_available,
Expand Down
8 changes: 5 additions & 3 deletions models/staging/airbnb/stg_airbnb_listings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ renamed as (
bathrooms_text as bathrooms_description,
beds as num_beds,
amenities,
price as price_in_dollars,
{{ dollar_string_to_decimal('price') }} as price_in_dollars,
minimum_nights,
maximum_nights,
picture_url,
Expand Down Expand Up @@ -68,8 +68,10 @@ renamed as (
boolean(has_availability) as has_availability,
to_date(last_scraped) as listing_last_scraped_at,
to_date(calendar_last_scraped) as calendar_last_scraped_at,
to_date(calendar_updated) as calendar_updated_at,
to_date(host_since) as host_since
to_date(calendar_updated) as calendar_updated_at

-- Commented out due to error parsing
-- to_date(host_since) as host_since
from source

)
Expand Down
2 changes: 2 additions & 0 deletions packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ packages:
version: 0.8.7
- package: dbt-labs/spark_utils
version: 0.3.0
- package: calogica/dbt_expectations
version: 0.8.3
Loading