-
Notifications
You must be signed in to change notification settings - Fork 13
/
_mart_gtfs_dims.yml
1168 lines (1127 loc) · 46.2 KB
/
_mart_gtfs_dims.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
version: 2
x-common-fields:
- &base64_url
name: base64_url
description: '{{ doc("column_base64_url") }}'
- &warning_duplicate_gtfs_key
name: warning_duplicate_gtfs_key
description: |
Flags rows with a duplicate _gtfs_key; e.g. area_id duplicates would result
in _gtfs_key duplicates within a feed version.
Treat these rows with caution as they can cause fanout when joining on
natural (i.e. GTFS) keys.
This column is tested to be majority false (i.e. sanity-check that most
records are unique).
tests:
- not_null
- dbt_expectations.expect_column_most_common_value_to_be_in_set:
value_set: [false]
top_n: 1
quote_values: false
data_type: "boolean"
# TODO: remove this once we deal with Auburn feed that has tab-delimited files
row_condition: "feed_key != '6368fe701bdd68c4f521751a9a222a10'"
- &schedule_dim_pk
name: key
description: |
Synthetic primary key constructed from `feed_key` and `_line_number`.
This key is intended to identify an actual _row_ in the GTFS source data,
rather than a GTFS entity described in that row. See _gtfs_key as a single
key derived from the "natural" key of the entity.
tests:
- not_null
- unique
- &schedule_dim_gtfs_key
name: _gtfs_key
description: |
Synthetic primary natural key constructed from the model's GTFS
specification uniqueness.
tests:
- not_null
- unique:
# TODO: remove this once we deal with Auburn feed that has
# tab-delimited files and at that point can move the
# &primary_key_tests anchor up to here (until exclusion is dropped,
# this exclusion condition is different because it's for key instead
# of feed_key)
where: "feed_key != '6368fe701bdd68c4f521751a9a222a10'"
- &schedule_dim_gtfs_key_with_dupe_flag
<<: *schedule_dim_gtfs_key
tests:
- not_null
- unique:
# TODO: remove feed_key filter once we deal with Auburn feed that has
# tab-delimited files
where: "NOT warning_duplicate_gtfs_key AND feed_key != '6368fe701bdd68c4f521751a9a222a10'"
- &schedule_dim_dt
name: _dt
description: |
Date of the feed version (i.e. date from _feed_valid_from in UTC); used for
upstream partition elimination.
tests:
- not_null
- &schedule_dim_line_number
name: _line_number
description: |
Line number of this record in the original Schedule file; used for
incremental materialization.
tests:
- not_null
- &feed_key
name: feed_key
description: '{{ doc("gtfs_schedule_feed_key") }}'
tests:
- not_null
- relationships:
to: ref('dim_schedule_feeds')
field: key
models:
- name: dim_schedule_feeds
description: |
Each row is a "feed", representing a unique zipfile version associated with
the same GTFS dataset record that was successfully downloaded and has data
in the warehouse.
When data fails to download, we do not interpolate it unless an identical
zipfile is subsequently downloaded. So for example, say we download
zipfile A from URL X on January 1, then the download or unzip operation
fails for any reason on January 2, and then we download zipfile A from
URL X again on January 3. If you check this table on January 3 before the
new data has appeared in the warehouse, it will show zipfile A has expired
on January 2. But once the same zipfile is ingested again, if you check on
January 4, we will show that zipfile A was continuously in effect
January 1-3. The reason for this is that if a new zipfile version B were to
be uploaded on January 3, we would want to correctly say that we don't know
what was in effect on January 2.
This table should be used to understand "versions" of constituent data like
routes, trips, etc.
tests:
- dbt_utils.mutually_exclusive_ranges:
lower_bound_column: _valid_from
upper_bound_column: _valid_to
partition_by: base64_url
gaps: required
columns:
- name: key
description: |
Synthetic primary key constructed from `base64_url` and `_valid_from`.
tests:
- unique:
# TODO: remove this once we deal with Auburn feed that has
# tab-delimited files and at that point can move the
# &primary_key_tests anchor up to here (until exclusion is dropped,
# this exclusion condition is different because it's for key instead
# of feed_key)
where: "key != '6368fe701bdd68c4f521751a9a222a10'"
- not_null
- *base64_url
- name: download_success
description: '{{ doc("column_download_success") }}'
- name: unzip_success
description: '{{ doc("column_unzip_success") }}'
- name: zipfile_extract_md5hash
description: '{{ doc("column_zipfile_md5_hash") }}'
- name: _valid_from
description: '{{ doc("column_valid_from") }}'
- name: _valid_to
description: '{{ doc("column_valid_to") }}'
- name: _is_current
description: '{{ doc("column_is_current") }}'
- name: feed_timezone
description: '{{ doc("gtfs_schedule_feed_timezone") }}'
tests:
- not_null
- *schedule_dim_dt
- name: dim_agency
description: |
Each row is a cleaned row from an agency.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#agencytxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: agency_id
description: '{{ doc("gtfs_agency__agency_id") }}'
- name: agency_name
description: '{{ doc("gtfs_agency__agency_name") }}'
tests: ¬_null_warn_99_threshold
- dbt_utils.not_null_proportion:
at_least: 0.99
severity: warn
- name: agency_url
description: '{{ doc("gtfs_agency__agency_url") }}'
tests: *not_null_warn_99_threshold
- name: agency_timezone
description: '{{ doc("gtfs_agency__agency_timezone") }}'
tests: ¬_null_warn
- not_null:
# TODO: remove feed_key filter once we deal with Auburn feed that has
# tab-delimited files
where: "feed_key != '6368fe701bdd68c4f521751a9a222a10'"
config:
severity: warn
- name: agency_lang
description: '{{ doc("gtfs_agency__agency_lang") }}'
- name: agency_phone
description: '{{ doc("gtfs_agency__agency_phone") }}'
- name: agency_fare_url
description: '{{ doc("gtfs_agency__agency_fare_url") }}'
- name: agency_email
description: '{{ doc("gtfs_agency__agency_email") }}'
- &_feed_valid_from
name: _feed_valid_from
description: |
Should not be used; exists to faciliate incremental materialization.
- &feed_timezone_no_tests
name: feed_timezone
description: '{{ doc("gtfs_schedule_feed_timezone") }}'
- name: dim_areas
description: |
Each row is a cleaned row from an areas.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/schedule/reference/#areastxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: area_id
description: '{{ doc("gtfs_areas__area_id") }}'
tests: ¬_null_error
- not_null:
# TODO: remove feed_key filter once we deal with Auburn feed that has
# tab-delimited files
where: "feed_key != '6368fe701bdd68c4f521751a9a222a10'"
- name: area_name
description: '{{ doc("gtfs_areas__area_name") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_attributions
description: |
Each row is a cleaned row from an attributions.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#attributionstxt.
columns:
- *schedule_dim_pk
- <<: *schedule_dim_gtfs_key
tests:
- not_null
- unique:
where: "NOT warning_duplicate_gtfs_key AND feed_key != '6368fe701bdd68c4f521751a9a222a10'"
# attribution_id is optional in the GTFS spec, so the flag is present
# on most/all rows
- <<: *warning_duplicate_gtfs_key
tests:
- not_null
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: attribution_id
description: '{{ doc("gtfs_attributions__attribution_id") }}'
- name: agency_id
description: '{{ doc("gtfs_attributions__agency_id") }}'
- name: route_id
description: '{{ doc("gtfs_attributions__route_id") }}'
- name: trip_id
description: '{{ doc("gtfs_attributions__trip_id") }}'
- name: organization_name
description: '{{ doc("gtfs_attributions__organization_name") }}'
tests: *not_null_warn
- name: is_producer
description: '{{ doc("gtfs_attributions__is_producer") }}'
- name: is_operator
description: '{{ doc("gtfs_attributions__is_operator") }}'
- name: is_authority
description: '{{ doc("gtfs_attributions__is_authority") }}'
- name: attribution_url
description: '{{ doc("gtfs_attributions__attribution_url") }}'
- name: attribution_email
description: '{{ doc("gtfs_attributions__attribution_email") }}'
- name: attribution_phone
description: '{{ doc("gtfs_attributions__attribution_phone") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_fare_attributes
description: |
Each row is a cleaned row from a fare_attributes.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#fare_attributestxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- name: fare_id
description: '{{ doc("gtfs_fare_attributes__fare_id") }}'
tests: *not_null_error
- name: price
description: '{{ doc("gtfs_fare_attributes__price") }}'
tests: *not_null_warn
- name: currency_type
description: '{{ doc("gtfs_fare_attributes__currency_type") }}'
tests: *not_null_warn
- name: payment_method
description: '{{ doc("gtfs_fare_attributes__payment_method") }}'
tests: *not_null_warn
- name: transfers
description: '{{ doc("gtfs_fare_attributes__transfers") }}'
tests: *not_null_warn
- name: agency_id
description: '{{ doc("gtfs_fare_attributes__agency_id") }}'
- name: transfer_duration
description: '{{ doc("gtfs_fare_attributes__transfer_duration") }}'
- *base64_url
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_fare_leg_rules
description: |
Each row is a cleaned row from a fare_leg_rules.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/schedule/reference/#fare_leg_rulestxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: leg_group_id
description: '{{ doc("gtfs_fare_leg_rules__leg_group_id") }}'
- name: network_id
description: '{{ doc("gtfs_fare_leg_rules__network_id") }}'
- name: from_area_id
description: '{{ doc("gtfs_fare_leg_rules__from_area_id") }}'
- name: to_area_id
description: '{{ doc("gtfs_fare_leg_rules__to_area_id") }}'
- name: fare_product_id
description: '{{ doc("gtfs_fare_leg_rules__fare_product_id") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_fare_media
description: |
Each row is a cleaned row from a fare_media.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/schedule/reference/#fare_mediatxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: fare_media_id
description: '{{ doc("gtfs_fare_media__fare_media_id") }}'
- name: fare_media_name
description: '{{ doc("gtfs_fare_media__fare_media_name") }}'
- name: fare_media_type
description: '{{ doc("gtfs_fare_media__fare_media_type") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_fare_products
description: |
Each row is a cleaned row from a fare_products.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/schedule/reference/#fare_productstxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: fare_product_id
description: '{{ doc("gtfs_fare_products__fare_product_id") }}'
tests: *not_null_error
- name: fare_product_name
description: '{{ doc("gtfs_fare_products__fare_product_name") }}'
- name: fare_media_id
description: '{{ doc("gtfs_fare_products__fare_media_id") }}'
- name: amount
description: '{{ doc("gtfs_fare_products__amount") }}'
tests: *not_null_warn_99_threshold
- name: currency
description: '{{ doc("gtfs_fare_products__currency") }}'
tests: *not_null_warn_99_threshold
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_fare_rules
description: |
Each row is a cleaned row from a fare_rules.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#fare_rulestxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key_with_dupe_flag
- *warning_duplicate_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: fare_id
description: '{{ doc("gtfs_fare_rules__fare_id") }}'
tests: *not_null_error
- name: route_id
description: '{{ doc("gtfs_fare_rules__route_id") }}'
- name: origin_id
description: '{{ doc("gtfs_fare_rules__origin_id") }}'
- name: destination_id
description: '{{ doc("gtfs_fare_rules__destination_id") }}'
- name: contains_id
description: '{{ doc("gtfs_fare_rules__contains_id") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_fare_transfer_rules
description: |
Each row is a cleaned row from a fare_transfer_rules.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/schedule/reference/#fare_transfer_rulestxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key_with_dupe_flag
- *warning_duplicate_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: from_leg_group_id
description: '{{ doc("gtfs_fare_transfer_rules__from_leg_group_id") }}'
- name: to_leg_group_id
description: '{{ doc("gtfs_fare_transfer_rules__to_leg_group_id") }}'
- name: transfer_count
description: '{{ doc("gtfs_fare_transfer_rules__transfer_count") }}'
- name: duration_limit
description: '{{ doc("gtfs_fare_transfer_rules__duration_limit") }}'
- name: duration_limit_type
description: '{{ doc("gtfs_fare_transfer_rules__duration_limit_type") }}'
- name: fare_transfer_type
description: '{{ doc("gtfs_fare_transfer_rules__fare_transfer_type") }}'
tests: *not_null_warn_99_threshold
- name: fare_product_id
description: '{{ doc("gtfs_fare_transfer_rules__fare_product_id") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_feed_info
description: |
Each row is a cleaned row from a feed_info.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#feed_infotxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key_with_dupe_flag
- *warning_duplicate_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: feed_publisher_name
description: '{{ doc("gtfs_feed_info__feed_publisher_name") }}'
tests: *not_null_warn
- name: feed_publisher_url
description: '{{ doc("gtfs_feed_info__feed_publisher_url") }}'
tests: *not_null_warn_99_threshold
- name: feed_lang
description: '{{ doc("gtfs_feed_info__feed_lang") }}'
tests: *not_null_warn_99_threshold
- name: default_lang
description: '{{ doc("gtfs_feed_info__default_lang") }}'
- name: feed_start_date
description: '{{ doc("gtfs_feed_info__feed_start_date") }}'
- name: feed_end_date
description: '{{ doc("gtfs_feed_info__feed_end_date") }}'
- name: feed_version
description: '{{ doc("gtfs_feed_info__feed_version") }}'
- name: feed_contact_email
description: '{{ doc("gtfs_feed_info__feed_contact_email") }}'
- name: feed_contact_url
description: '{{ doc("gtfs_feed_info__feed_contact_url") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_frequencies
description: |
Each row is a cleaned row from a frequencies.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#frequenciestxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: trip_id
description: '{{ doc("gtfs_frequencies__trip_id") }}'
tests: *not_null_error
- name: start_time
description: '{{ doc("gtfs_frequencies__start_time") }}'
tests: *not_null_warn
- name: end_time
description: '{{ doc("gtfs_frequencies__end_time") }}'
tests: *not_null_warn
- name: headway_secs
description: '{{ doc("gtfs_frequencies__headway_secs") }}'
tests: *not_null_warn
- name: exact_times
description: '{{ doc("gtfs_frequencies__exact_times") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: start_time_interval
description: |
This is a calculated field that does not appear directly in GTFS.
It converts `start_time` to a BigQuery INTERVAL type,
which allows us to treat the field as a duration after twelve hours
before noon (usually midnight) and thus handle times past the following
midnight (like `25:40:00`).
See: https://gtfs.org/schedule/reference/#field-types for how GTFS
defines its "Time" type.
- name: end_time_interval
description: |
This is a calculated field that does not appear directly in GTFS.
It converts `end_time` to a BigQuery INTERVAL type,
which allows us to treat the field as a duration after twelve hours
before noon (usually midnight) and thus handle times past the following
midnight (like `25:40:00`).
See: https://gtfs.org/schedule/reference/#field-types for how GTFS
defines its "Time" type.
- name: start_time_sec
description: |
This is a calculated field that does not come from GTFS - it is not
a timestamp and can't be treated as such.
Represents `start_time` as a total number of seconds
after twelve hours before noon (usually midnight) of the first day of
the given trip.
For example, `start_time = 21:30:45` would lead to
`start_time_sec = 21 * 3,600 + 30 * 60 + 45 * 1 = 77,445`.
This allows us to perform duration calculations and handle timestamps
that wrap past midnight like `25:40:00`, which are allowed in GTFS.
- name: end_time_sec
description: |
This is a calculated field that does not come from GTFS - it is not
a timestamp and can't be treated as such.
Represents `end_time` as a total number of seconds
after twelve hours before noon (usually midnight) of the first day of
the given trip.
For example, `end_time = 21:30:45` would lead to
`end_time_sec = 21 * 3,600 + 30 * 60 + 45 * 1 = 77,445`.
This allows us to perform duration calculations and handle timestamps
that wrap past midnight like `25:40:00`, which are allowed in GTFS.
- name: dim_levels
description: |
Each row is a cleaned row from a levels.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#levelstxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: level_id
description: '{{ doc("gtfs_levels__level_id") }}'
tests: *not_null_error
- name: level_index
description: '{{ doc("gtfs_levels__level_index") }}'
tests: *not_null_warn
- name: level_name
description: '{{ doc("gtfs_levels__level_name") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_pathways
description: |
Each row is a cleaned row from a pathways.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#pathwaystxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: pathway_id
description: '{{ doc("gtfs_pathways__pathway_id") }}'
tests: *not_null_error
- name: from_stop_id
description: '{{ doc("gtfs_pathways__from_stop_id") }}'
tests: *not_null_error
- name: to_stop_id
description: '{{ doc("gtfs_pathways__to_stop_id") }}'
tests: *not_null_error
- name: pathway_mode
description: '{{ doc("gtfs_pathways__pathway_mode") }}'
tests: *not_null_warn
- name: is_bidirectional
description: '{{ doc("gtfs_pathways__is_bidirectional") }}'
tests: *not_null_warn
- name: length
description: '{{ doc("gtfs_pathways__length") }}'
- name: traversal_time
description: '{{ doc("gtfs_pathways__traversal_time") }}'
- name: stair_count
description: '{{ doc("gtfs_pathways__stair_count") }}'
- name: max_slope
description: '{{ doc("gtfs_pathways__max_slope") }}'
- name: min_width
description: '{{ doc("gtfs_pathways__min_width") }}'
- name: signposted_as
description: '{{ doc("gtfs_pathways__signposted_as") }}'
- name: reversed_signposted_as
description: '{{ doc("gtfs_pathways__reversed_signposted_as") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_routes
description: |
Each row is a cleaned row from a routes.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#routestxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: route_id
description: '{{ doc("gtfs_routes__route_id") }}'
tests: *not_null_error
- name: agency_id
description: '{{ doc("gtfs_routes__agency_id") }}'
- name: route_short_name
description: '{{ doc("gtfs_routes__route_short_name") }}'
- name: route_long_name
description: '{{ doc("gtfs_routes__route_long_name") }}'
- name: route_desc
description: '{{ doc("gtfs_routes__route_desc") }}'
- name: route_type
description: '{{ doc("gtfs_routes__route_type") }}'
tests: *not_null_warn
- name: route_url
description: '{{ doc("gtfs_routes__route_url") }}'
- name: route_color
description: '{{ doc("gtfs_routes__route_color") }}'
- name: route_text_color
description: '{{ doc("gtfs_routes__route_text_color") }}'
- name: route_sort_order
description: '{{ doc("gtfs_routes__route_sort_order") }}'
- name: continuous_pickup
description: '{{ doc("gtfs_routes__continuous_pickup") }}'
- name: continuous_drop_off
description: '{{ doc("gtfs_routes__continuous_drop_off") }}'
- name: network_id
description: '{{ doc("gtfs_routes__network_id") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_shapes
description: |
Each row is a cleaned row from a shapes.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#shapestxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: shape_id
description: '{{ doc("gtfs_shapes__shape_id") }}'
tests: *not_null_error
- name: shape_pt_lat
description: '{{ doc("gtfs_shapes__shape_pt_lat") }}'
tests: *not_null_warn
meta:
metabase.semantic_type: type/Latitude
ckan.type: FLOAT
ckan.length: 6
ckan.precision: 3
- name: shape_pt_lon
description: '{{ doc("gtfs_shapes__shape_pt_lon") }}'
tests: *not_null_warn
meta:
metabase.semantic_type: type/Longitude
ckan.type: FLOAT
ckan.length: 7
ckan.precision: 3
- name: shape_pt_sequence
description: '{{ doc("gtfs_shapes__shape_pt_sequence") }}'
tests: *not_null_warn
- name: shape_dist_traveled
description: '{{ doc("gtfs_shapes__shape_dist_traveled") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_stop_areas
description: |
Each row is a cleaned row from a stop_areas.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/schedule/reference/#stop_areastxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: area_id
description: '{{ doc("gtfs_stop_areas__area_id") }}'
tests: *not_null_error
- name: stop_id
description: '{{ doc("gtfs_stop_areas__stop_id") }}'
tests: *not_null_error
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_stops
description: |
Each row is a cleaned row from a stops.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#stopstxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key_with_dupe_flag
- *warning_duplicate_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: stop_id
description: '{{ doc("gtfs_stops__stop_id") }}'
tests: ¬_null_error_99_threshold
- dbt_utils.not_null_proportion:
at_least: 0.99
- name: stop_code
description: '{{ doc("gtfs_stops__stop_code") }}'
- name: stop_name
description: '{{ doc("gtfs_stops__stop_name") }}'
- name: tts_stop_name
description: '{{ doc("gtfs_stops__tts_stop_name") }}'
- name: stop_desc
description: '{{ doc("gtfs_stops__stop_desc") }}'
- name: stop_lat
description: '{{ doc("gtfs_stops__stop_lat") }}'
meta:
metabase.semantic_type: type/Latitude
ckan.type: FLOAT
ckan.length: 6
ckan.precision: 3
- name: stop_lon
description: '{{ doc("gtfs_stops__stop_lon") }}'
meta:
metabase.semantic_type: type/Longitude
ckan.type: FLOAT
ckan.length: 7
ckan.precision: 3
- name: zone_id
description: '{{ doc("gtfs_stops__zone_id") }}'
- name: stop_url
description: '{{ doc("gtfs_stops__stop_url") }}'
- name: location_type
description: '{{ doc("gtfs_stops__location_type") }}'
- name: parent_station
description: '{{ doc("gtfs_stops__parent_station") }}'
- name: stop_timezone
description: '{{ doc("gtfs_stops__stop_timezone") }}'
- name: wheelchair_boarding
description: '{{ doc("gtfs_stops__wheelchair_boarding") }}'
- name: level_id
description: '{{ doc("gtfs_stops__level_id") }}'
- name: platform_code
description: '{{ doc("gtfs_stops__platform_code") }}'
- name: pt_geom
description: GEOGPOINT created by the stop latitute and longitude
- name: warning_missing_primary_key
description: |
Rows with `true` in this column are missing a `stop_id`, the primary
key for this table (i.e., `stop_id` was not provided in the raw data).
These rows will fail to join with other tables from their feed because
they cannot be referenced by a foreign key elsewhere.
- name: stop_timezone_coalesced
description: '{{ doc("gtfs_schedule_stop_timezone_coalesced") }}'
tests:
- not_null
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_transfers
description: |
Each row is a cleaned row from a transfers.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#transferstxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key_with_dupe_flag
- *warning_duplicate_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: from_stop_id
description: '{{ doc("gtfs_transfers__from_stop_id") }}'
tests:
- not_null:
error_if: "> 5"
- name: to_stop_id
description: '{{ doc("gtfs_transfers__to_stop_id") }}'
tests:
- not_null:
error_if: "> 5"
- name: transfer_type
description: '{{ doc("gtfs_transfers__transfer_type") }}'
tests: *not_null_warn
- name: min_transfer_time
description: '{{ doc("gtfs_transfers__min_transfer_time") }}'
- name: from_route_id
description: '{{ doc("gtfs_transfers__from_route_id") }}'
- name: to_route_id
description: '{{ doc("gtfs_transfers__to_route_id") }}'
- name: from_trip_id
description: '{{ doc("gtfs_transfers__from_trip_id") }}'
- name: to_trip_id
description: '{{ doc("gtfs_transfers__to_trip_id") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_translations
description: |
Each row is a cleaned row from a translations.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#translationstxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: table_name
description: '{{ doc("gtfs_translations__table_name") }}'
tests: *not_null_warn
- name: field_name
description: '{{ doc("gtfs_translations__field_name") }}'
tests: *not_null_warn
- name: language
description: '{{ doc("gtfs_translations__language") }}'
tests: *not_null_warn
- name: translation
description: '{{ doc("gtfs_translations__translation") }}'
tests: *not_null_warn
- name: record_id
description: '{{ doc("gtfs_translations__record_id") }}'
- name: record_sub_id
description: '{{ doc("gtfs_translations__record_sub_id") }}'
- name: field_value
description: '{{ doc("gtfs_translations__field_value") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_trips
description: |
Each row is a cleaned row from a trips.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#tripstxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key_with_dupe_flag
- *warning_duplicate_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: route_id
description: '{{ doc("gtfs_trips__route_id") }}'
tests: *not_null_error
- name: service_id
description: '{{ doc("gtfs_trips__service_id") }}'
tests: *not_null_error
- name: trip_id
description: '{{ doc("gtfs_trips__trip_id") }}'
tests:
- not_null:
error_if: ">1"
- name: trip_headsign
description: '{{ doc("gtfs_trips__trip_headsign") }}'
- name: trip_short_name
description: '{{ doc("gtfs_trips__trip_short_name") }}'
- name: direction_id
description: '{{ doc("gtfs_trips__direction_id") }}'
- name: block_id
description: '{{ doc("gtfs_trips__block_id") }}'
- name: shape_id
description: '{{ doc("gtfs_trips__shape_id") }}'
- name: wheelchair_accessible
description: '{{ doc("gtfs_trips__wheelchair_accessible") }}'
- name: bikes_allowed
description: '{{ doc("gtfs_trips__bikes_allowed") }}'
- *_feed_valid_from
- *feed_timezone_no_tests
- name: warning_duplicate_gtfs_key
description: |
Rows with `true` in this column have a duplicate primary key; i.e.,
`trip_id` is duplicated within an individual feed
instance and `key` will also be duplicated as a result. Treat these rows
with caution. They will cause fanout in joins.
- name: dim_calendar
description: |
Each row is a cleaned row from a calendar.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#calendartxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: service_id
description: '{{ doc("gtfs_calendar__service_id") }}'
tests: *not_null_error
- name: monday
description: '{{ doc("gtfs_calendar__monday") }}'
tests: *not_null_warn
- name: tuesday
description: '{{ doc("gtfs_calendar__tuesday") }}'
tests: *not_null_warn
- name: wednesday
description: '{{ doc("gtfs_calendar__wednesday") }}'
tests: *not_null_warn
- name: thursday
description: '{{ doc("gtfs_calendar__thursday") }}'
tests: *not_null_warn
- name: friday
description: '{{ doc("gtfs_calendar__friday") }}'
tests: *not_null_warn
- name: saturday
description: '{{ doc("gtfs_calendar__saturday") }}'
tests: *not_null_warn
- name: sunday
description: '{{ doc("gtfs_calendar__sunday") }}'
tests: *not_null_warn
- name: start_date
description: '{{ doc("gtfs_calendar__start_date") }}'
tests: *not_null_warn
- name: end_date
description: '{{ doc("gtfs_calendar__end_date") }}'
tests: *not_null_warn
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_calendar_dates
description: |
Each row is a cleaned row from a calendar_dates.txt file.
Definitions for the original GTFS fields are available at:
https://gtfs.org/reference/static#calendar_datestxt.
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: service_id
description: '{{ doc("gtfs_calendar_dates__service_id") }}'
tests: *not_null_error
- name: date
description: '{{ doc("gtfs_calendar_dates__date") }}'
tests: *not_null_warn
- name: exception_type
description: '{{ doc("gtfs_calendar_dates__exception_type") }}'
tests: *not_null_warn
- *_feed_valid_from
- *feed_timezone_no_tests
- name: dim_stop_times
description: |
Cleaned GTFS schedule stop_times data.
See https://gtfs.org/schedule/reference/#stop_timestxt for specification.
Note that fields associated with GTFS-Flex v2 are only partially supported;
see https://github.com/cal-itp/data-infra/issues/2574 for implementation
status in the Cal-ITP data warehouse and
https://github.com/MobilityData/gtfs-flex/blob/master/spec/reference.md
for the Flex v2 specification.
tests:
- dbt_utils.expression_is_true:
expression: "EXTRACT(DAY FROM arrival_time_interval) = 0"
where: "TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), _feed_valid_from, DAY) <= 3"
- dbt_utils.expression_is_true:
expression: "EXTRACT(DAY FROM departure_time_interval) = 0"
where: "TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), _feed_valid_from, DAY) <= 3"
columns:
- *schedule_dim_pk
- *schedule_dim_gtfs_key_with_dupe_flag
- *warning_duplicate_gtfs_key
- *schedule_dim_dt
- *schedule_dim_line_number
- *feed_key
- *base64_url
- name: trip_id
description: '{{ doc("gtfs_stop_times__trip_id") }}'
tests: *not_null_error
- name: arrival_time
description: '{{ doc("gtfs_stop_times__arrival_time") }}'
- name: departure_time
description: '{{ doc("gtfs_stop_times__departure_time") }}'
- name: stop_id
description: '{{ doc("gtfs_stop_times__stop_id") }}'
tests:
- not_null:
where: "not warning_missing_foreign_key_stop_id"
- name: stop_sequence
description: '{{ doc("gtfs_stop_times__stop_sequence") }}'
tests: *not_null_warn
- name: stop_headsign
description: '{{ doc("gtfs_stop_times__stop_headsign") }}'
- name: pickup_type
description: '{{ doc("gtfs_stop_times__pickup_type") }}'