Skip to content

Commit

Permalink
incremental settings like source table (#3672)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanychu90 authored Feb 4, 2025
1 parent eb402ff commit 66999d7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions warehouse/models/mart/gtfs/fct_vehicle_locations_grouped.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
materialized='incremental',
incremental_strategy='insert_overwrite',
partition_by = {
'field': 'service_date',
'field': 'dt',
'data_type': 'date',
'granularity': 'day',
},
cluster_by=['service_date', 'base64_url'],
cluster_by=['dt', 'base64_url'],
on_schema_change='append_new_columns'
)
}}

WITH fct_vehicle_locations AS (
SELECT
key,
dt,
gtfs_dataset_key,
base64_url,
gtfs_dataset_name,
Expand Down Expand Up @@ -88,6 +89,7 @@ keys_grouped AS (
vp_grouper AS (
SELECT
fct_vehicle_locations.key,
fct_vehicle_locations.dt,
fct_vehicle_locations.gtfs_dataset_key,
fct_vehicle_locations.base64_url,
fct_vehicle_locations.gtfs_dataset_name,
Expand All @@ -111,6 +113,7 @@ vp_grouper AS (
fct_grouped_locations AS (
SELECT
MIN(vp_grouper.key) AS key,
vp_grouper.dt,
vp_grouper.gtfs_dataset_key,
vp_grouper.base64_url,
vp_grouper.gtfs_dataset_name,
Expand All @@ -127,7 +130,7 @@ fct_grouped_locations AS (
ELSE MIN(vp_grouper.vp_direction)
END AS vp_direction,
FROM vp_grouper
GROUP BY gtfs_dataset_key, base64_url, gtfs_dataset_name, schedule_gtfs_dataset_key, service_date, trip_instance_key, vp_group
GROUP BY dt, gtfs_dataset_key, base64_url, gtfs_dataset_name, schedule_gtfs_dataset_key, service_date, trip_instance_key, vp_group
)

SELECT * FROM fct_grouped_locations

0 comments on commit 66999d7

Please sign in to comment.