Skip to content

Commit 0b6edab

Browse files
charlie-costanzoerikamov
authored andcommitted
revise casting in intermediate ridership models
1 parent 1bd2be3 commit 0b6edab

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

warehouse/models/intermediate/ntd/int_ntd__monthly_ridership_with_adjustments_upt.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ WITH
2727
),
2828

2929
int_ntd__monthly_ridership_with_adjustments_upt AS (
30-
SELECT format("%05d", cast(cast(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
30+
SELECT FORMAT("%05d", CAST(CAST(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
3131
legacy_ntd_id,
3232
agency,
3333
reporter_type,
34-
split(period, '_')[offset(2)] AS period_year,
35-
split(period, '_')[offset(1)] AS period_month,
34+
SAFE_CAST(SPLIT(period, '_')[OFFSET(2)] AS INT64) AS period_year,
35+
SPLIT(period, '_')[OFFSET(1)] AS period_month,
3636
uza_name,
37-
format("%05d", cast(uace_cd AS INT64)) AS uace_cd,
37+
FORMAT("%05d", CAST(uace_cd AS INT64)) AS uace_cd,
3838
mode,
3939
mode_type_of_service_status,
4040
_3_mode,

warehouse/models/intermediate/ntd/int_ntd__monthly_ridership_with_adjustments_voms.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ WITH
2727
),
2828

2929
int_ntd__monthly_ridership_with_adjustments_voms AS (
30-
SELECT format("%05d", cast(cast(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
30+
SELECT FORMAT("%05d", CAST(CAST(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
3131
legacy_ntd_id,
3232
agency,
3333
reporter_type,
34-
split(period, '_')[offset(2)] AS period_year,
35-
split(period, '_')[offset(1)] AS period_month,
34+
SAFE_CAST(SPLIT(period, '_')[OFFSET(2)] AS INT64) AS period_year,
35+
SPLIT(period, '_')[OFFSET(1)] AS period_month,
3636
uza_name,
37-
format("%05d", cast(uace_cd AS INT64)) AS uace_cd,
37+
FORMAT("%05d", CAST(uace_cd AS INT64)) AS uace_cd,
3838
mode,
3939
mode_type_of_service_status,
4040
_3_mode,

warehouse/models/intermediate/ntd/int_ntd__monthly_ridership_with_adjustments_vrh.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ WITH
2727
),
2828

2929
int_ntd__monthly_ridership_with_adjustments_vrh AS (
30-
SELECT format("%05d", cast(cast(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
30+
SELECT FORMAT("%05d", CAST(CAST(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
3131
legacy_ntd_id,
3232
agency,
3333
reporter_type,
34-
split(period, '_')[offset(2)] AS period_year,
35-
split(period, '_')[offset(1)] AS period_month,
34+
SAFE_CAST(SPLIT(period, '_')[OFFSET(2)] AS INT64) AS period_year,
35+
SPLIT(period, '_')[OFFSET(1)] AS period_month,
3636
uza_name,
37-
format("%05d", cast(uace_cd AS INT64)) AS uace_cd,
37+
FORMAT("%05d", CAST(uace_cd AS INT64)) AS uace_cd,
3838
mode,
3939
mode_type_of_service_status,
4040
_3_mode,

warehouse/models/intermediate/ntd/int_ntd__monthly_ridership_with_adjustments_vrm.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ WITH
2727
),
2828

2929
int_ntd__monthly_ridership_with_adjustments_vrm AS (
30-
SELECT format("%05d", cast(cast(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
30+
SELECT FORMAT("%05d", CAST(CAST(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
3131
legacy_ntd_id,
3232
agency,
3333
reporter_type,
34-
split(period, '_')[offset(2)] AS period_year,
35-
split(period, '_')[offset(1)] AS period_month,
34+
SAFE_CAST(SPLIT(period, '_')[OFFSET(2)] AS INT64) AS period_year,
35+
SPLIT(period, '_')[OFFSET(1)] AS period_month,
3636
uza_name,
37-
format("%05d", cast(uace_cd AS INT64)) AS uace_cd,
37+
FORMAT("%05d", CAST(uace_cd AS INT64)) AS uace_cd,
3838
mode,
3939
mode_type_of_service_status,
4040
_3_mode,

0 commit comments

Comments
 (0)