Skip to content

Main #55

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Main #55

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: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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.
Original file line number Diff line number Diff line change
@@ -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
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(*)
FROM
{{ref('first_model')}}
FROM
{{ref('first_model')}}
17 changes: 7 additions & 10 deletions nyc_parking_violations/profiles.yml
Original file line number Diff line number Diff line change
@@ -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
dev:
type: duckdb
path: '../data/nyc_parking_violations.db'
prod:
type: duckdb
path: './data/prod_nyc_parking_violations.db'
target: dev
203 changes: 199 additions & 4 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": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -12,17 +12,212 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"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>count_star()</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>97</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" count_star()\n",
"0 97"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sql_query = '''\n",
"show tables\n",
"SELECT * FROM ref_model\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": 11,
"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>registration_state</th>\n",
" <th>ticket_count</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>NJ</td>\n",
" <td>9258</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>PA</td>\n",
" <td>3514</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>FL</td>\n",
" <td>2414</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>CT</td>\n",
" <td>1787</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>GA</td>\n",
" <td>840</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>57</th>\n",
" <td>AB</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>58</th>\n",
" <td>BC</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>59</th>\n",
" <td>NB</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>60</th>\n",
" <td>PE</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>61</th>\n",
" <td>SK</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>62 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" registration_state ticket_count\n",
"0 NJ 9258\n",
"1 PA 3514\n",
"2 FL 2414\n",
"3 CT 1787\n",
"4 GA 840\n",
".. ... ...\n",
"57 AB 1\n",
"58 BC 1\n",
"59 NB 1\n",
"60 PE 1\n",
"61 SK 1\n",
"\n",
"[62 rows x 2 columns]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sql_query = '''\n",
"select * from gold_vehicles_metrics\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": 18,
"metadata": {},
"outputs": [],
"source": [
"import duckdb\n",
"\n",
"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)\n",
"\n"
]
}
],
"metadata": {
Expand Down