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

Taylor test branch #121

Merged
merged 5 commits into from
Aug 13, 2024
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
53 changes: 53 additions & 0 deletions .github/workflows/lint_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: SQLFluff

on:
- pull_request

jobs:
lint-models:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Install Python
uses: "actions/setup-python@v2"
with:
python-version: "3.7"
- name: install sqlfluff
run: "pip install sqlfluff"
- name: Get changed files
id: get_file_changes
uses: trilom/[email protected]
with:
output: ' '

- name: Get changed .sql files in /models to lint
id: get_files_to_lint
shell: bash -l {0}
run: |
# Set the command in the $() brackets as an output to use in later steps
echo "::set-output name=lintees::$(
# Issue where grep regular expressions don't work as expected on the
# Github Actions shell, check dbt/models/ folder
echo \
$(echo ${{ steps.get_file_changes.outputs.files_modified }} |
tr -s ' ' '\n' |
grep -E '^dbt/models.*[.]sql$' |
tr -s '\n' ' ') \
$(echo ${{ steps.get_file_changes.outputs.files_added }} |
tr -s ' ' '\n' |
grep -E '^dbt/models.*[.]sql$' |
tr -s '\n' ' ')
)"

- name: Lint dbt models
id: sqlfluff_json
if: steps.get_files_to_lint.outputs.lintees != ''
shell: bash -l {0}
run: sqlfluff lint --format github-annotation --annotation-level failure --nofail ${{ steps.get_files_to_lint.outputs.lintees }} > annotations.json
- name: Annotate
uses: yuzutech/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
title: "SQLFluff Lint"
input: "./annotations.json"
5 changes: 5 additions & 0 deletions macros/create_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% macro create_schema(relation) %}
{%- call statement('create_schema') -%}
create schema if not exists {{ relation.without_identifier() }} with managed access
{% endcall %}
{% endmacro %}
2 changes: 1 addition & 1 deletion models/marts/core/dim_customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ with customer as (
nation as (

select * from {{ ref('stg_tpch_nations') }}
),
),
region as (

select * from {{ ref('stg_tpch_regions') }}
Expand Down
2 changes: 1 addition & 1 deletion models/marts/core/dim_parts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ with part as (
final as (
select
part_key,
manufacturer,
manufacturer ,
name,
brand as brand,
type,
Expand Down
8 changes: 7 additions & 1 deletion models/staging/tpch/stg_tpch_nations.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{{
config(
schema='managed_access_test'
)
}}
with source as (

select * from {{ source('tpch', 'nation') }}
Expand All @@ -11,7 +16,8 @@ renamed as (
n_nationkey as nation_key,
n_name as name,
n_regionkey as region_key,
n_comment as comment
n_comment as comment,
'{{env_var('DBT_ENV_TYPE')}}' as env_type

from source

Expand Down
Loading