Skip to content

Chapter_01 #23

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 4 commits into
base: main
Choose a base branch
from
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: 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.
30 changes: 30 additions & 0 deletions logs/dbt.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
12:57:41.758111 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'start', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7f8bf2c9ded0>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7f8bf32fe7a0>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7f8bf32fe830>]}


============================== 12:57:41.763008 | 393c32eb-99cd-4973-9d79-593f73111543 ==============================
12:57:41.763008 [info ] [MainThread]: Running with dbt=1.6.1
12:57:41.763672 [debug] [MainThread]: running dbt with arguments {'printer_width': '80', 'indirect_selection': 'eager', 'write_json': 'True', 'log_cache_events': 'False', 'partial_parse': 'True', 'cache_selected_only': 'False', 'warn_error': 'None', 'fail_fast': 'False', 'version_check': 'True', 'log_path': 'logs', 'debug': 'False', 'profiles_dir': '/home/vscode/.dbt', 'use_colors': 'True', 'use_experimental_parser': 'False', 'no_print': 'None', 'quiet': 'False', 'warn_error_options': 'WarnErrorOptions(include=[], exclude=[])', 'invocation_command': 'dbt init', 'static_parser': 'True', 'log_format': 'default', 'target_path': 'None', 'introspect': 'True', 'send_anonymous_usage_stats': 'True'}
12:57:41.764209 [warn ] [MainThread]: [ConfigFolderDirectory]: Unable to parse dict {'dir': PosixPath('/home/vscode/.dbt')}
12:57:41.764640 [info ] [MainThread]: Creating dbt configuration folder at
12:58:12.987765 [debug] [MainThread]: Starter project path: /home/vscode/.local/lib/python3.10/site-packages/dbt/include/starter_project
12:58:12.992225 [info ] [MainThread]:
Your new dbt project "nyc_parking_violations" was created!

For more information on how to configure the profiles.yml file,
please consult the dbt documentation here:

https://docs.getdbt.com/docs/configure-your-profile

One more thing:

Need help? Don't hesitate to reach out to us via GitHub issues or on Slack:

https://community.getdbt.com/

Happy modeling!

12:58:12.993020 [info ] [MainThread]: Setting up your profile.
12:58:23.034904 [info ] [MainThread]: No sample profile found for duckdb.
12:58:23.035841 [debug] [MainThread]: Command `dbt init` succeeded at 12:58:23.035704 after 41.28 seconds
12:58:23.036276 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'end', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7f8bf2c9ded0>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7f8bf4f97c10>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7f8bf09c11b0>]}
12:58:23.036746 [debug] [MainThread]: Flushing usage events
4 changes: 0 additions & 4 deletions nyc_parking_violations/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
.user.yml
target/
dbt_packages/
logs/
1 change: 1 addition & 0 deletions nyc_parking_violations/.user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
id: 9c234971-2fb3-44bd-a034-481bb90bf9fc
52 changes: 0 additions & 52 deletions nyc_parking_violations/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,52 +0,0 @@

# Name your project! Project names should contain only lowercase characters
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: 'nyc_parking_violations'
version: '1.0.0'
config-version: 2

# This setting configures which "profile" dbt uses for this project.
profile: 'nyc_parking_violations'

# These configurations specify where dbt should look for different types of files.
# The `model-paths` config, for example, states that models in this project can be
# found in the "models/" directory. You probably won't need to change these!
model-paths: ["models"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]

clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_packages"


# Configuring models
# Full documentation: https://docs.getdbt.com/docs/configuring-models

# In this example config, we tell dbt to build all models in the example/
# directory as views. These settings can be overridden in the individual model
# files using the `{{ config(...) }}` macro.
models:
nyc_parking_violations:
# Config indicated by + and applies to all files under models/example/
example:
+materialized: ephemeral
bronze:
+materialized: view
silver:
silver_parking_violation_codes:
+materialized: ephemeral
silver_parking_violations:
+materialized: ephemeral
silver_violation_tickets:
+materialized: view
silver_violation_vehicles:
+materialized: view
gold:
+materialized: table
tests:
+store_failures: true
107 changes: 107 additions & 0 deletions nyc_parking_violations/models/docs/docs_block.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{% docs violation_code %}
Code representing the specific parking violation.
{% enddocs %}

{% docs definition %}
Description of the violation for a respective code.
{% enddocs %}

{% docs manhattan_96th_st_below %}
The fee in $USD for a violation on or below Manhattan 96th Street.
{% enddocs %}

{% docs all_other_areas %}
The fee in $USD for a violation not on or below Manhattan 96th Street.
{% enddocs %}

{% docs summons_number %}
Unique identifier for each summons issued for a parking violation.
{% enddocs %}

{% docs registration_state %}
The state where the vehicle is registered.
{% enddocs %}

{% docs plate_type %}
The type of license plate.
{% enddocs %}

{% docs issue_date %}
The date when the summons was issued.
{% enddocs %}

{% docs vehicle_body_type %}
The body type of the vehicle involved in the violation.
{% enddocs %}

{% docs vehicle_make %}
The make or brand of the vehicle.
{% enddocs %}

{% docs issuing_agency %}
The agency that issued the summons.
{% enddocs %}

{% docs vehicle_expiration_date %}
The date when the vehicle's registration expires.
{% enddocs %}

{% docs violation_location %}
General location where the violation occurred.
{% enddocs %}

{% docs violation_precinct %}
Precinct where the violation was identified.
{% enddocs %}

{% docs issuer_precinct %}
Precinct of the officer or official who issued the summons.
{% enddocs %}

{% docs issuer_code %}
Unique code identifying the issuer.
{% enddocs %}

{% docs issuer_command %}
Command or unit of the issuer.
{% enddocs %}

{% docs issuer_squad %}
Squad detail for the issuer.
{% enddocs %}

{% docs violation_time %}
Time when the violation occurred.
{% enddocs %}

{% docs violation_county %}
County where the violation took place.
{% enddocs %}

{% docs violation_legal_code %}
Legal code associated with the violation.
{% enddocs %}

{% docs vehicle_color %}
Color of the vehicle involved in the violation.
{% enddocs %}

{% docs vehicle_year %}
Manufacturing year of the vehicle.
{% enddocs %}

{% docs fee_usd %}
The fee charged for a parking violation, specified in USD. This fee varies depending on the location of the violation.
{% enddocs %}

{% docs is_manhattan_96th_st_below %}
A boolean value indicating whether the violation occurred in Manhattan on or below 96th Street.
{% enddocs %}

{% docs ticket_count %}
The total number of tickets issued for a specific violation code.
{% enddocs %}

{% docs total_revenue_usd %}
The total revenue accumulated from tickets, based on the violation code. This sum is represented in USD.
{% enddocs %}
188 changes: 0 additions & 188 deletions nyc_parking_violations/models/docs/schema.yml
Original file line number Diff line number Diff line change
@@ -1,188 +0,0 @@
models:
- name: bronze_parking_violation_codes
description: Raw data representing the violation codes and their fees.
columns:
- name: violation_code
description: '{{ doc("violation_code") }}'
- name: definition
description: '{{ doc("definition") }}'
- name: manhattan_96th_st_below
description: '{{ doc("manhattan_96th_st_below") }}'
- name: all_other_areas
description: '{{ doc("all_other_areas") }}'

- name: bronze_parking_violations
description: Raw data related to parking violations in 2023, encompassing various details about each violation.
columns:
- name: summons_number
description: '{{ doc("summons_number") }}'
tests:
- unique
- not_null
- generic_not_null
- name: registration_state
description: '{{ doc("registration_state") }}'
- name: plate_type
description: '{{ doc("plate_type") }}'
- name: issue_date
description: '{{ doc("issue_date") }}'
- name: violation_code
description: '{{ doc("violation_code") }}'
- name: vehicle_body_type
description: '{{ doc("vehicle_body_type") }}'
- name: vehicle_make
description: '{{ doc("vehicle_make") }}'
- name: issuing_agency
description: '{{ doc("issuing_agency") }}'
- name: vehicle_expiration_date
description: '{{ doc("vehicle_expiration_date") }}'
- name: violation_location
description: '{{ doc("violation_location") }}'
- name: violation_precinct
description: '{{ doc("violation_precinct") }}'
- name: issuer_precinct
description: '{{ doc("issuer_precinct") }}'
- name: issuer_code
description: '{{ doc("issuer_code") }}'
- name: issuer_command
description: '{{ doc("issuer_command") }}'
- name: issuer_squad
description: '{{ doc("issuer_squad") }}'
- name: violation_time
description: '{{ doc("violation_time") }}'
- name: violation_county
description: '{{ doc("violation_county") }}'
- name: violation_legal_code
description: '{{ doc("violation_legal_code") }}'
- name: vehicle_color
description: '{{ doc("vehicle_color") }}'
- name: vehicle_year
description: '{{ doc("vehicle_year") }}'

- name: silver_parking_violation_codes
description: "This model unifies violation codes, providing a comprehensive view of violations, indicating whether they occurred on/below 96th St in Manhattan or in other areas, along with the respective fees in USD."
columns:
- name: violation_code
description: '{{ doc("violation_code") }}'
- name: definition
description: '{{ doc("definition") }}'
- name: is_manhattan_96th_st_below
description: '{{ doc("is_manhattan_96th_st_below") }}'
- name: fee_usd
description: '{{ doc("fee_usd") }}'

- name: silver_parking_violations
description: "Enhanced view of parking violations, enriched with details and specific indicators such as the flag for violations in Manhattan on or below 96th Street."
columns:
- name: summons_number
description: '{{ doc("summons_number") }}'
- name: registration_state
description: '{{ doc("registration_state") }}'
- name: plate_type
description: '{{ doc("plate_type") }}'
- name: issue_date
description: '{{ doc("issue_date") }}'
- name: violation_code
description: '{{ doc("violation_code") }}'
- name: vehicle_body_type
description: '{{ doc("vehicle_body_type") }}'
- name: vehicle_make
description: '{{ doc("vehicle_make") }}'
- name: issuing_agency
description: '{{ doc("issuing_agency") }}'
- name: vehicle_expiration_date
description: '{{ doc("vehicle_expiration_date") }}'
- name: violation_location
description: '{{ doc("violation_location") }}'
- name: violation_precinct
description: '{{ doc("violation_precinct") }}'
- name: issuer_precinct
description: '{{ doc("issuer_precinct") }}'
- name: issuer_code
description: '{{ doc("issuer_code") }}'
- name: issuer_command
description: '{{ doc("issuer_command") }}'
- name: issuer_squad
description: '{{ doc("issuer_squad") }}'
- name: violation_time
description: '{{ doc("violation_time") }}'
- name: violation_county
description: '{{ doc("violation_county") }}'
- name: violation_legal_code
description: '{{ doc("violation_legal_code") }}'
- name: vehicle_color
description: '{{ doc("vehicle_color") }}'
- name: vehicle_year
description: '{{ doc("vehicle_year") }}'
- name: is_manhattan_96th_st_below
description: '{{ doc("is_manhattan_96th_st_below") }}'

- name: silver_violation_tickets
description: "Consolidated information on parking violations, enriched with associated fee details."
columns:
- name: summons_number
description: '{{ doc("summons_number") }}'
- name: issue_date
description: '{{ doc("issue_date") }}'
- name: violation_code
description: '{{ doc("violation_code") }}'
- name: is_manhattan_96th_st_below
description: '{{ doc("is_manhattan_96th_st_below") }}'
- name: issuing_agency
description: '{{ doc("issuing_agency") }}'
- name: violation_location
description: '{{ doc("violation_location") }}'
- name: violation_precinct
description: '{{ doc("violation_precinct") }}'
- name: issuer_precinct
description: '{{ doc("issuer_precinct") }}'
- name: issuer_code
description: '{{ doc("issuer_code") }}'
- name: issuer_command
description: '{{ doc("issuer_command") }}'
- name: issuer_squad
description: '{{ doc("issuer_squad") }}'
- name: violation_time
description: '{{ doc("violation_time") }}'
- name: violation_county
description: '{{ doc("violation_county") }}'
- name: violation_legal_code
description: '{{ doc("violation_legal_code") }}'

- name: silver_violation_vehicles
description: "Details of the vehicles involved in parking violations."
columns:
- name: summons_number
description: '{{ doc("summons_number") }}'
- name: registration_state
description: '{{ doc("registration_state") }}'
- name: plate_type
description: '{{ doc("plate_type") }}'
- name: vehicle_body_type
description: '{{ doc("vehicle_body_type") }}'
- name: vehicle_make
description: '{{ doc("vehicle_make") }}'
- name: vehicle_expiration_date
description: '{{ doc("vehicle_expiration_date") }}'
- name: vehicle_color
description: '{{ doc("vehicle_color") }}'
- name: vehicle_year
description: '{{ doc("vehicle_year") }}'

- name: gold_ticket_metrics
description: "Aggregated metrics representing the total tickets and revenue by violation code."
columns:
- name: violation_code
description: '{{ doc("violation_code") }}'
- name: ticket_count
description: '{{ doc("ticket_count") }}'
- name: total_revenue_usd
description: '{{ doc("total_revenue_usd") }}'

- name: gold_vehicles_metrics
description: "Aggregated metrics detailing the number of tickets per vehicle, identified by the plate ID."
columns:
- name: registration_state
description: '{{ doc("registration_state") }}'
- name: ticket_count
description: '{{ doc("ticket_count") }}'
Loading