-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from cagov/bottleneck_extent_ba
Bottleneck extent (spatial)
- Loading branch information
Showing
3 changed files
with
164 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 34 additions & 32 deletions
66
...orm/models/intermediate/performance/int_performance__station_metrics_agg_five_minutes.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
{{ config( | ||
materialized="incremental", | ||
cluster_by=["sample_date"], | ||
unique_key=["station_id", "sample_date", "sample_timestamp"], | ||
snowflake_warehouse = get_snowflake_refresh_warehouse(big="XL") | ||
) }} | ||
|
||
with detector_agg_five_minutes as ( | ||
select * | ||
from {{ ref('int_imputation__detector_imputed_agg_five_minutes') }} | ||
where {{ make_model_incremental('sample_date') }} | ||
), | ||
|
||
station_aggregated_speed as ( | ||
select | ||
station_id, | ||
sample_date, | ||
sample_timestamp, | ||
any_value(freeway) as freeway, | ||
any_value(direction) as direction, | ||
any_value(station_type) as station_type, | ||
any_value(absolute_postmile) as absolute_postmile, | ||
any_value(district) as district, | ||
sum(sample_ct) as sample_ct, | ||
sum(volume_sum) as volume_sum, | ||
avg(occupancy_avg) as occupancy_avg, | ||
sum(volume_sum * speed_five_mins) / nullifzero(sum(volume_sum)) as speed_five_mins | ||
from detector_agg_five_minutes | ||
group by station_id, sample_date, sample_timestamp | ||
) | ||
|
||
select * from station_aggregated_speed | ||
{{ config( | ||
materialized="incremental", | ||
on_schema_change="append_new_columns", | ||
cluster_by=["sample_date"], | ||
unique_key=["station_id", "sample_date", "sample_timestamp"], | ||
snowflake_warehouse = get_snowflake_refresh_warehouse(big="XL") | ||
) }} | ||
|
||
with detector_agg_five_minutes as ( | ||
select * | ||
from {{ ref('int_imputation__detector_imputed_agg_five_minutes') }} | ||
where {{ make_model_incremental('sample_date') }} | ||
), | ||
|
||
station_aggregated_speed as ( | ||
select | ||
station_id, | ||
sample_date, | ||
sample_timestamp, | ||
any_value(freeway) as freeway, | ||
any_value(direction) as direction, | ||
any_value(station_type) as station_type, | ||
any_value(absolute_postmile) as absolute_postmile, | ||
any_value(district) as district, | ||
any_value(length) as length, | ||
sum(sample_ct) as sample_ct, | ||
sum(volume_sum) as volume_sum, | ||
avg(occupancy_avg) as occupancy_avg, | ||
sum(volume_sum * speed_five_mins) / nullifzero(sum(volume_sum)) as speed_five_mins | ||
from detector_agg_five_minutes | ||
group by station_id, sample_date, sample_timestamp | ||
) | ||
|
||
select * from station_aggregated_speed |