diff --git a/.github/workflows/run-dbt.yml b/.github/workflows/run-dbt.yml new file mode 100644 index 000000000..f821d5321 --- /dev/null +++ b/.github/workflows/run-dbt.yml @@ -0,0 +1,38 @@ +# .github/workflows/run-dbt.yml +name: run-dbt + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + # schedule: + # - cron: '0 8 * * *' + +env: + DBT_PROFILES_DIR: ./nyc_parking_violations + DBT_PROJECT_DIR: ./nyc_parking_violations + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Run dbt Prod + run: | + dbt debug + dbt compile --target prod + dbt run --target prod + - name: Test dbt Prod + run: | + dbt test --target prod \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 236981053..ca20f9585 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,7 +17,6 @@ "files.autoSave": "afterDelay", "screencastMode.onlyKeyboardShortcuts": true, "terminal.integrated.fontSize": 18, - "workbench.activityBar.visible": true, "workbench.colorTheme": "Visual Studio Dark", "workbench.fontAliasing": "antialiased", "workbench.statusBar.visible": true diff --git a/data/nyc_parking_violations.db b/data/nyc_parking_violations.db index 19e587528..403780738 100644 Binary files a/data/nyc_parking_violations.db and b/data/nyc_parking_violations.db differ diff --git a/nyc_parking_violations/tests/generic/generic_not_null.sql b/nyc_parking_violations/tests/generic/generic_not_null.sql index e49c2b087..630a7abbd 100644 --- a/nyc_parking_violations/tests/generic/generic_not_null.sql +++ b/nyc_parking_violations/tests/generic/generic_not_null.sql @@ -1,4 +1,4 @@ --- source: https://docs.getdbt.com/guides/best-practices/writing-custom-generic-tests#generic-tests-with-default-config-values +-- source: https://docs.getdbt.com/guides/bedbt st-practices/writing-custom-generic-tests#generic-tests-with-default-config-values {% test generic_not_null(model, column_name) %} select * diff --git a/nyc_parking_violations/tests/viplations_codes_revenue.sql b/nyc_parking_violations/tests/viplations_codes_revenue.sql new file mode 100644 index 000000000..091ddfdd4 --- /dev/null +++ b/nyc_parking_violations/tests/viplations_codes_revenue.sql @@ -0,0 +1,11 @@ +{{ config(severity = 'warn') }} + +SELECT + violation_code, + SUM(fee_usd) AS total_revenue_usd +FROM + {{ref('silver_parking_violation_codes')}} +GROUP BY + violation_code +HAVING + NOT(total_revenue_usd >= 1) diff --git a/run_sql_queries_here.ipynb b/run_sql_queries_here.ipynb index f7c54e6c9..26d09a9fc 100644 --- a/run_sql_queries_here.ipynb +++ b/run_sql_queries_here.ipynb @@ -17,7 +17,7 @@ "outputs": [], "source": [ "sql_query = '''\n", - "show tables\n", + "select * from \"nyc_parking_violations\".\"main_dbt_test__audit\".\"viplations_codes_revenue\"\n", "'''\n", "\n", "with duckdb.connect('data/nyc_parking_violations.db') as con:\n",