Skip to content

Commit

Permalink
Merge pull request #669 from ccao-data/jeancochrane/materialized-mode…
Browse files Browse the repository at this point in the history
…l-shared-input-view

Materialize `model.vw_pin_shared_input` view to speed up daily dbt builds
  • Loading branch information
jeancochrane authored Dec 11, 2024
2 parents dc41cf4 + 936b145 commit 96b6bab
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions dbt/models/model/model.vw_pin_shared_input.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@ consistency. Missing data is filled with the following steps:
2. Current data is filled BACKWARD to account for missing historical data.
Again, this is only for things unlikely to change
WARNING: This is a very heavy view. Don't use it for anything other than making
extracts for modeling
This view is "materialized" (made into a table) daily in order to improve
query performance and reduce data queried by Athena. The materialization
is triggered by sqoop-bot (runs after Sqoop grabs iasWorld data)
*/
{{
config(
materialized='table',
partitioned_by=['meta_year'],
bucketed_by=['meta_pin'],
bucket_count=1
)
}}

WITH uni AS (

SELECT
Expand Down Expand Up @@ -179,7 +189,6 @@ exemption_features AS (
SELECT
uni.pin AS meta_pin,
uni.pin10 AS meta_pin10,
uni.year AS meta_year,
uni.class AS meta_class,
uni.triad_name AS meta_triad_name,
uni.triad_code AS meta_triad_code,
Expand Down Expand Up @@ -384,7 +393,10 @@ SELECT
vwpf.nearest_neighbor_2_pin10,
vwpf.nearest_neighbor_2_dist_ft,
vwpf.nearest_neighbor_3_pin10,
vwpf.nearest_neighbor_3_dist_ft
vwpf.nearest_neighbor_3_dist_ft,

-- Year should be listed last, for partitioning
uni.year AS meta_year

FROM uni
LEFT JOIN {{ ref('location.vw_pin10_location_fill') }} AS vwlf
Expand Down

0 comments on commit 96b6bab

Please sign in to comment.