Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Noel Gomez committed Sep 23, 2023
1 parent a1af9f5 commit 7b06e46
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ repos:

- repo: https://github.com/sqlfluff/sqlfluff
# this is the version of sqlfluff, needs to be updated when using a new sqlfluff version (pip show sqlfluff)
rev: 2.0.3
rev: 2.3.2
hooks:
- id: sqlfluff-lint
language: python
# Need these two dependencies.
# sqlfluff-templater-dbt should match the version of sqlfluff above in rev (pip show sqlfluff-templater-dbt)
# dbt-snowflake needs to match the version in transform tab of Datacoves (pip show dbt-snowflake)
additional_dependencies:
["sqlfluff-templater-dbt==2.0.3", "dbt-snowflake==1.6.2"]
["sqlfluff-templater-dbt==2.3.2", "dbt-snowflake==1.6.2"]
args: [--config, transform/.sqlfluff]

- repo: https://github.com/adrienverge/yamllint.git
Expand Down
75 changes: 41 additions & 34 deletions transform/models/L2_bays/covid_observations/covid_location.sql
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
{{ config(materialized="view") }}

with
jhu_covid_19 as (
select distinct
country_region,
coalesce(province_state, 'UNDEFINED') as province_state,
coalesce(county, 'UNDEFINED') as county,
lat,
long,
iso3166_1,
iso3166_2,
date
from {{ ref("jhu_covid_19") }}
),
with jhu_covid_19 as (
select distinct
country_region,
coalesce(province_state, 'UNDEFINED') as province_state,
coalesce(county, 'UNDEFINED') as county,
lat,
long,
iso3166_1,
iso3166_2,
date
from {{ ref("jhu_covid_19") }}
),

rank_locations as (
select
hash(
country_region || '|' || province_state || '|' || county
) as snowflake_location_id,
{{
dbt_utils.generate_surrogate_key(
["country_region", "province_state", "county"]
)
}} as location_id,
country_region as country,
province_state as state,
county,
lat,
long,
iso3166_1,
iso3166_2,
rank() over (partition by location_id order by date desc) as rowrank
from jhu_covid_19
)
rank_locations as (
select
hash(
country_region || '|' || province_state || '|' || county
) as snowflake_location_id,
{{
dbt_utils.generate_surrogate_key(
["country_region", "province_state", "county"]
)
}} as location_id,
country_region as country,
province_state as state,
county,
lat,
long,
iso3166_1,
iso3166_2,
rank() over (partition by location_id order by date desc) as rowrank
from jhu_covid_19
)

select location_id, country, state, county, lat, long, iso3166_1, iso3166_2
select
location_id,
country,
state,
county,
lat,
long,
iso3166_1,
iso3166_2
from rank_locations
where rowrank = 1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ select
covid_cases.recovered
from covid_cases
join location
on location.location_id = covid_cases.location_id
on covid_cases.location_id = location.location_id
where
location.country is not null
and location.state is null
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ select
covid_cases.recovered
from covid_cases
inner join location
on location.location_id = covid_cases.location_id
on covid_cases.location_id = location.location_id
where
location.state is not null
and location.county is not null

0 comments on commit 7b06e46

Please sign in to comment.