diff --git a/.vscode/settings.json b/.vscode/settings.json index 236981053..a82add75e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,8 +17,7 @@ "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 -} +} \ No newline at end of file diff --git a/data/nyc_parking_violations.db b/data/nyc_parking_violations.db index 19e587528..a7fded200 100644 Binary files a/data/nyc_parking_violations.db and b/data/nyc_parking_violations.db differ diff --git a/data/prod_nyc_parking_violations.db b/data/prod_nyc_parking_violations.db index 9a2bd4ad7..63b1348b8 100644 Binary files a/data/prod_nyc_parking_violations.db and b/data/prod_nyc_parking_violations.db differ diff --git a/nyc_parking_violations/dbt_project.yml b/nyc_parking_violations/dbt_project.yml index ec48605d3..1118ac748 100644 --- a/nyc_parking_violations/dbt_project.yml +++ b/nyc_parking_violations/dbt_project.yml @@ -49,4 +49,4 @@ models: gold: +materialized: table tests: - +store_failures: true + +store_failures: true \ No newline at end of file diff --git a/nyc_parking_violations/models/bronze/bronze_parking_violation_codes.sql b/nyc_parking_violations/models/bronze/bronze_parking_violation_codes.sql index 217a5f263..ef84b5c60 100644 --- a/nyc_parking_violations/models/bronze/bronze_parking_violation_codes.sql +++ b/nyc_parking_violations/models/bronze/bronze_parking_violation_codes.sql @@ -1,7 +1,8 @@ SELECT - code AS violation_code, - definition, - manhattan_96th_st_below, - all_other_areas + code AS violation_code, + definition, + manhattan_96th_st_below, + all_other_areas FROM - parking_violation_codes + parking_violation_codes + \ No newline at end of file diff --git a/nyc_parking_violations/models/docs/docs_blocks.md b/nyc_parking_violations/models/docs/docs_blocks.md index cd410941a..aa403dff5 100644 --- a/nyc_parking_violations/models/docs/docs_blocks.md +++ b/nyc_parking_violations/models/docs/docs_blocks.md @@ -104,4 +104,4 @@ The total number of tickets issued for a specific violation code. {% docs total_revenue_usd %} The total revenue accumulated from tickets, based on the violation code. This sum is represented in USD. -{% enddocs %} +{% enddocs %} \ No newline at end of file diff --git a/nyc_parking_violations/models/docs/schema.yml b/nyc_parking_violations/models/docs/schema.yml index c1dfcb9fc..0524962a6 100644 --- a/nyc_parking_violations/models/docs/schema.yml +++ b/nyc_parking_violations/models/docs/schema.yml @@ -185,4 +185,4 @@ models: - name: registration_state description: '{{ doc("registration_state") }}' - name: ticket_count - description: '{{ doc("ticket_count") }}' + description: '{{ doc("ticket_count") }}' \ No newline at end of file diff --git a/nyc_parking_violations/models/example/first_model.sql b/nyc_parking_violations/models/example/first_model.sql index 942e472df..2370069ae 100644 --- a/nyc_parking_violations/models/example/first_model.sql +++ b/nyc_parking_violations/models/example/first_model.sql @@ -1 +1,2 @@ -SELECT * FROM parking_violation_codes \ No newline at end of file +SELECT * +FROM parking_violation_codes \ No newline at end of file diff --git a/nyc_parking_violations/models/example/ref_model.sql b/nyc_parking_violations/models/example/ref_model.sql index 9bb4f51c6..9c4afe923 100644 --- a/nyc_parking_violations/models/example/ref_model.sql +++ b/nyc_parking_violations/models/example/ref_model.sql @@ -1,4 +1,4 @@ SELECT COUNT(*) FROM - {{ref('first_model')}} + {{ref('first_model')}} \ No newline at end of file diff --git a/nyc_parking_violations/profiles.yml b/nyc_parking_violations/profiles.yml index cabe18c54..43875bcb4 100644 --- a/nyc_parking_violations/profiles.yml +++ b/nyc_parking_violations/profiles.yml @@ -8,5 +8,5 @@ nyc_parking_violations: # note that path is slightly different as GitHub actions # start in the root directory and not in the # nyc_parking_violations directory - path: './data/prod_nyc_parking_violations.db' + path: '../data/prod_nyc_parking_violations.db' target: dev \ No newline at end of file diff --git a/nyc_parking_violations/tests/violation_codes_revenue.sql b/nyc_parking_violations/tests/violation_codes_revenue.sql index 091ddfdd4..7ae627963 100644 --- a/nyc_parking_violations/tests/violation_codes_revenue.sql +++ b/nyc_parking_violations/tests/violation_codes_revenue.sql @@ -1,4 +1,4 @@ -{{ config(severity = 'warn') }} +{{ config(severity = 'warn')}} SELECT violation_code, @@ -8,4 +8,4 @@ FROM GROUP BY violation_code HAVING - NOT(total_revenue_usd >= 1) + NOT(total_revenue_usd >= 1) \ No newline at end of file diff --git a/run_sql_queries_here.ipynb b/run_sql_queries_here.ipynb index f7c54e6c9..b49b857f7 100644 --- a/run_sql_queries_here.ipynb +++ b/run_sql_queries_here.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -12,15 +12,178 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
violation_codetotal_revenue_usd
0410.0
\n", + "
" + ], + "text/plain": [ + " violation_code total_revenue_usd\n", + "0 41 0.0" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sql_query = '''\n", + "select * from \"nyc_parking_violations\".\"main_dbt_test__audit\".\"violation_codes_revenue\"\n", + "'''\n", + "\n", + "with duckdb.connect('data/nyc_parking_violations.db') as con:\n", + " display(con.sql(sql_query).df())" + ] + }, + { + "cell_type": "code", + "execution_count": 4, "metadata": {}, "outputs": [], + "source": [ + "sql_query_import_1 = '''\n", + "CREATE OR REPLACE TABLE parking_violation_codes AS\n", + "SELECT *\n", + "FROM read_csv_auto(\n", + " 'data/dof_parking_violation_codes.csv',\n", + " normalize_names=True\n", + ")\n", + "'''\n", + "sql_query_import_2 = '''\n", + "CREATE OR REPLACE TABLE parking_violations_2023 AS\n", + "SELECT *\n", + "FROM read_csv_auto(\n", + " 'data/parking_violations_issued_fiscal_year_2023_sample.csv',\n", + " normalize_names=True\n", + ")\n", + "'''\n", + "\n", + "with duckdb.connect('data/prod_nyc_parking_violations.db') as con:\n", + " con.sql(sql_query_import_1)\n", + " con.sql(sql_query_import_2)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
name
0bronze_parking_violation_codes
1bronze_parking_violations
2gold_ticket_metrics
3gold_vehicles_metrics
4parking_violation_codes
5parking_violations_2023
6silver_violation_tickets
7silver_violation_vehicles
\n", + "
" + ], + "text/plain": [ + " name\n", + "0 bronze_parking_violation_codes\n", + "1 bronze_parking_violations\n", + "2 gold_ticket_metrics\n", + "3 gold_vehicles_metrics\n", + "4 parking_violation_codes\n", + "5 parking_violations_2023\n", + "6 silver_violation_tickets\n", + "7 silver_violation_vehicles" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "sql_query = '''\n", "show tables\n", "'''\n", "\n", - "with duckdb.connect('data/nyc_parking_violations.db') as con:\n", + "with duckdb.connect('data/prod_nyc_parking_violations.db') as con:\n", " display(con.sql(sql_query).df())" ] }