diff --git a/.vscode/settings.json b/.vscode/settings.json index 23698105..ca20f958 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 19e58752..b5f81fd0 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 9a2bd4ad..d03e4716 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/.gitignore b/nyc_parking_violations/.gitignore index 9a7943d2..49f147cb 100644 --- a/nyc_parking_violations/.gitignore +++ b/nyc_parking_violations/.gitignore @@ -1,4 +1,4 @@ -.user.yml + target/ dbt_packages/ logs/ diff --git a/nyc_parking_violations/.user.yml b/nyc_parking_violations/.user.yml new file mode 100644 index 00000000..78ee7e39 --- /dev/null +++ b/nyc_parking_violations/.user.yml @@ -0,0 +1 @@ +id: c977a4b5-58c9-46f5-8b95-8b94e46a4940 diff --git a/nyc_parking_violations/dbt_project.yml b/nyc_parking_violations/dbt_project.yml index ec48605d..738215a6 100644 --- a/nyc_parking_violations/dbt_project.yml +++ b/nyc_parking_violations/dbt_project.yml @@ -34,7 +34,7 @@ models: nyc_parking_violations: # Config indicated by + and applies to all files under models/example/ example: - +materialized: ephemeral + +materialized: view bronze: +materialized: view silver: 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 217a5f26..856e8e5e 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,7 @@ 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 diff --git a/nyc_parking_violations/models/docs/docs_blocks.md b/nyc_parking_violations/models/docs/docs_block.md similarity index 99% rename from nyc_parking_violations/models/docs/docs_blocks.md rename to nyc_parking_violations/models/docs/docs_block.md index cd410941..aa403dff 100644 --- a/nyc_parking_violations/models/docs/docs_blocks.md +++ b/nyc_parking_violations/models/docs/docs_block.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/example/ref_model.sql b/nyc_parking_violations/models/example/ref_model.sql index 9bb4f51c..3de28c43 100644 --- a/nyc_parking_violations/models/example/ref_model.sql +++ b/nyc_parking_violations/models/example/ref_model.sql @@ -1,4 +1,3 @@ -SELECT - COUNT(*) -FROM - {{ref('first_model')}} +SELECT COUNT(*) +FROM + {{ref('first_model')}} \ No newline at end of file diff --git a/nyc_parking_violations/profiles.yml b/nyc_parking_violations/profiles.yml index cabe18c5..af3ac5c0 100644 --- a/nyc_parking_violations/profiles.yml +++ b/nyc_parking_violations/profiles.yml @@ -1,12 +1,9 @@ nyc_parking_violations: outputs: - dev: - type: duckdb - path: '../data/nyc_parking_violations.db' - prod: - type: duckdb - # 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' - target: dev \ No newline at end of file + dev: + type: duckdb + path: '../data/nyc_parking_violations.db' + prod: + type: duckdb + path: './data/prod_nyc_parking_violations.db' + target: dev diff --git a/nyc_parking_violations/tests/violation_codes_revenue.sql b/nyc_parking_violations/tests/violation_codes_revenue.sql index 091ddfdd..9426a0ba 100644 --- a/nyc_parking_violations/tests/violation_codes_revenue.sql +++ b/nyc_parking_violations/tests/violation_codes_revenue.sql @@ -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 f7c54e6c..071b501e 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": 1, "metadata": {}, "outputs": [], "source": [ @@ -12,17 +12,216 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, + "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', normalize_names=True\n", + " )\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', normalize_names=True\n", + ")\n", + "'''\n", + "\n", + "with duckdb.connect('data/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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
name
0bronze_parking_violation_codes
1bronze_parking_violations
2first_model
3gold_ticket_metrics
4gold_vehicles_metrics
5parking_violation_codes
6parking_violations_2023
7ref_model
8silver_violation_tickets
9silver_violation_vehicles
\n", + "
" + ], + "text/plain": [ + " name\n", + "0 bronze_parking_violation_codes\n", + "1 bronze_parking_violations\n", + "2 first_model\n", + "3 gold_ticket_metrics\n", + "4 gold_vehicles_metrics\n", + "5 parking_violation_codes\n", + "6 parking_violations_2023\n", + "7 ref_model\n", + "8 silver_violation_tickets\n", + "9 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())" ] + }, + { + "cell_type": "code", + "execution_count": 5, + "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', normalize_names=True\n", + " )\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', 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)" + ] } ], "metadata": {