From 96421ae79f0d30f4f4bbd6d07164f41c81a2f0ef Mon Sep 17 00:00:00 2001 From: V Date: Tue, 15 Oct 2024 15:59:00 -0700 Subject: [PATCH] fix(gtfs_rt_service_alerts): Changes datatype of active_period to strings to accomodate some bad data --- .../gtfs_rt_v2/rt_v2_service_alerts.yml | 4 ++-- .../gtfs/int_gtfs_rt__service_alerts_fully_unnested.sql | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/airflow/dags/create_external_tables/gtfs_rt_v2/rt_v2_service_alerts.yml b/airflow/dags/create_external_tables/gtfs_rt_v2/rt_v2_service_alerts.yml index 92c85bf696..a84b648f56 100644 --- a/airflow/dags/create_external_tables/gtfs_rt_v2/rt_v2_service_alerts.yml +++ b/airflow/dags/create_external_tables/gtfs_rt_v2/rt_v2_service_alerts.yml @@ -50,9 +50,9 @@ schema_fields: mode: REPEATED fields: - name: start - type: INTEGER + type: STRING - name: end - type: INTEGER + type: STRING - name: informedEntity type: RECORD diff --git a/warehouse/models/intermediate/gtfs/int_gtfs_rt__service_alerts_fully_unnested.sql b/warehouse/models/intermediate/gtfs/int_gtfs_rt__service_alerts_fully_unnested.sql index db61e6b21e..30d324bdee 100644 --- a/warehouse/models/intermediate/gtfs/int_gtfs_rt__service_alerts_fully_unnested.sql +++ b/warehouse/models/intermediate/gtfs/int_gtfs_rt__service_alerts_fully_unnested.sql @@ -28,9 +28,9 @@ int_gtfs_rt__service_alerts_fully_unnested AS ( cause, effect, - -- active periods - unnested_active_period.start AS active_period_start, - unnested_active_period.end AS active_period_end, + -- active periods, converting from STRINGS since some agency has bad data that insn't unnestable as INTs + SAFE_CAST(unnested_active_period.start AS INT) AS active_period_start, + SAFE_CAST(unnested_active_period.end AS INT) AS active_period_end, -- informted entities unnested_informed_entity.agencyId AS agency_id,