Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/run-dbt-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: run_dbt_prod

on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
Expand Down
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Binary file modified data/nyc_parking_violations.db
Binary file not shown.
Binary file modified data/prod_nyc_parking_violations.db
Binary file not shown.
2 changes: 1 addition & 1 deletion nyc_parking_violations/models/example/first_model.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SELECT * FROM parking_violation_codes
SELECT * FROM parking_violation_codes;
4 changes: 2 additions & 2 deletions nyc_parking_violations/models/example/ref_model.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT
COUNT(*)
COUNT(*)
FROM
{{ref('first_model')}}
{{ref('first_model')}}
8 changes: 7 additions & 1 deletion nyc_parking_violations/profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ nyc_parking_violations:
# start in the root directory and not in the
# nyc_parking_violations directory
path: './data/prod_nyc_parking_violations.db'
target: dev
target: dev

default:
outputs:
dev:
type: duckdb
target: dev
181 changes: 171 additions & 10 deletions run_sql_queries_here.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -12,22 +12,188 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>violation_code</th>\n",
" <th>total_revenue_usd</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>41</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" violation_code total_revenue_usd\n",
"0 41 0.0"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sql_query = '''\n",
"show tables;\n",
"select * from \"nyc_parking_violations\".\"main_dbt_test__audit\".\"violation_codes_revenue\"\n",
"\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": 22,
"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",
"\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": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>bronze_parking_violation_codes</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>bronze_parking_violations</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>gold_ticket_metrics</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>gold_vehicles_metrics</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>parking_violation_codes</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>parking_violations_2023</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>silver_violation_tickets</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>silver_violation_vehicles</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"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())"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -43,12 +209,7 @@
"pygments_lexer": "ipython3",
"version": "3.10.12"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down