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

Add sqlfluff to CI #9

Merged
merged 7 commits into from
Sep 24, 2023
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ jobs:
run: python3 el.py -lc
- name: Run T
run: dbt deps && dbt build
- name: Lint SQL
run: sqlfluff lint models --format github-annotation-native
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ repos:
rev: 23.9.1
hooks:
- id: black
# - repo: https://github.com/sqlfluff/sqlfluff
# rev: 2.3.2
# hooks:
# - id: sqlfluff-fix
# additional_dependencies:
# ["dbt-metricflow[duckdb]~=0.3.0", "sqlfluff-templater-dbt"]
- repo: https://github.com/sqlfluff/sqlfluff
rev: 2.3.2
hooks:
- id: sqlfluff-fix
additional_dependencies:
["dbt-metricflow[duckdb]~=0.3.0", "sqlfluff-templater-dbt"]
4 changes: 2 additions & 2 deletions .sqlfluff
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ tab_space_size = 4
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = lower

[sqlfluff:convention]
select_trailing_comma = required
[sqlfluff:rules:convention.select_trailing_comma]
select_clause_trailing_comma = require
6 changes: 3 additions & 3 deletions models/marts/issue_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ with

issue_events as (

select * from {{ ref('stg_events') }}
select *, from {{ ref('stg_events') }}

where event_type = 'IssuesEvent'

Expand Down Expand Up @@ -30,10 +30,10 @@ unnest_json as (
payload -> '$.issue' ->> '$.body' as issue_body,
payload ->> '$.changes' as issue_changes,
payload ->> '$.label' as issue_label,
payload ->> '$.assignee' as issue_assignee
payload ->> '$.assignee' as issue_assignee,

from issue_events

)

select * from unnest_json
select *, from unnest_json
6 changes: 3 additions & 3 deletions models/marts/pull_request_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ with

pull_request_events as (

select * from {{ ref('stg_events') }}
select *, from {{ ref('stg_events') }}

where event_type = 'PullRequestEvent'

Expand Down Expand Up @@ -53,10 +53,10 @@ unnest_json as (
payload
-> '$.pull_request'
-> '$.repo'
->> '$.full_name' as repo_full_name
->> '$.full_name' as repo_full_name,

from pull_request_events

)

select * from unnest_json
select *, from unnest_json
4 changes: 2 additions & 2 deletions models/marts/push_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ with

push_events as (

select * from {{ ref('stg_events') }}
select *, from {{ ref('stg_events') }}

where event_type in ('PushEvent')

Expand All @@ -27,4 +27,4 @@ unnest_json as (

)

select * from unnest_json
select *, from unnest_json
8 changes: 4 additions & 4 deletions models/marts/repos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ distill_repos_from_events as (
repo_id,
repo_name,
repo_url,
max(event_created_at) as repo_state_last_seen_at
max(event_created_at) as repo_state_last_seen_at,

from {{ ref('stg_events') }}

Expand All @@ -28,7 +28,7 @@ rank_most_recent_repo_state as (
row_number() over (
partition by repo_id
order by repo_state_last_seen_at desc
) as repo_recency_rank
) as repo_recency_rank,

from distill_repos_from_events

Expand All @@ -39,12 +39,12 @@ pull_most_recent_repo_state as (
select
repo_id,
repo_name,
repo_url
repo_url,

from rank_most_recent_repo_state

where repo_recency_rank = 1

)

select * from pull_most_recent_repo_state
select *, from pull_most_recent_repo_state
8 changes: 4 additions & 4 deletions models/marts/users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ distill_user_states_from_events as (
actor_display_login,
actor_url,
actor_avatar_url,
max(event_created_at) as user_state_last_seen_at
max(event_created_at) as user_state_last_seen_at,

from {{ ref('stg_events') }}

Expand All @@ -39,7 +39,7 @@ rank_user_state_recency as (
row_number() over (
partition by actor_id
order by user_state_last_seen_at desc
) as user_state_recency_rank
) as user_state_recency_rank,

from distill_user_states_from_events

Expand All @@ -53,12 +53,12 @@ pull_most_recent_user_state as (
actor_login,
actor_display_login,
actor_url,
actor_avatar_url
actor_avatar_url,

from rank_user_state_recency

where user_state_recency_rank = 1

)

select * from pull_most_recent_user_state
select *, from pull_most_recent_user_state
6 changes: 3 additions & 3 deletions models/staging/github/stg_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ with

source as (

select * from {{ source('octocatalog', 'github_events') }}
select *, from {{ source('octocatalog', 'github_events') }}

),

Expand Down Expand Up @@ -36,10 +36,10 @@ renamed as (
org['login'] as org_login,
org['gravatar_id'] as org_gravatar_id,
org['url'] as org_url,
org['avatar_url'] as org_avatar_url
org['avatar_url'] as org_avatar_url,

from source

)

select * from renamed
select *, from renamed