Skip to content

Commit

Permalink
remove session time zone
Browse files Browse the repository at this point in the history
  • Loading branch information
rymarczy committed Dec 13, 2023
1 parent 00e1e2a commit 318f172
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions python_src/src/lamp_py/tableau/jobs/rt_rail.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ def __init__(self) -> None:
remote_parquet_path=f"s3://{os.getenv('PUBLIC_ARCHIVE_BUCKET')}/lamp/tableau/rail/LAMP_ALL_RT_fields.parquet",
)
self.table_query = (
"SET SESSION timezone to 'America/New_York';"
"SELECT"
" date(vt.service_date::text) as service_date"
" , TIMEZONE('UTC', TO_TIMESTAMP(extract(epoch FROM date(vt.service_date::text)) + vt.start_time)) as start_datetime"
" , TIMEZONE('UTC', TO_TIMESTAMP(extract(epoch FROM date(vt.service_date::text)) + vt.static_start_time)) as static_start_datetime"
" , vt.service_date::text::timestamp + make_interval(secs => vt.start_time) as start_datetime"
" , vt.service_date::text::timestamp + make_interval(secs => vt.static_start_time) as static_start_datetime"
" , ve.stop_sequence"
" , ve.canonical_stop_sequence"
" , prev_ve.canonical_stop_sequence as previous_canonical_stop_sequence"
Expand All @@ -41,9 +40,9 @@ def __init__(self) -> None:
" , TIMEZONE('America/New_York', TO_TIMESTAMP(ve.vp_move_timestamp)) as previous_stop_departure_datetime"
" , TIMEZONE('America/New_York', TO_TIMESTAMP(COALESCE(ve.vp_stop_timestamp, ve.tu_stop_timestamp))) as stop_arrival_datetime"
" , TIMEZONE('America/New_York', TO_TIMESTAMP(COALESCE(ve.vp_stop_timestamp, ve.tu_stop_timestamp) + ve.dwell_time_seconds)) as stop_departure_datetime"
" , (ve.vp_move_timestamp - extract(epoch FROM vt.service_date::text::timestamp WITH TIME ZONE AT TIME ZONE 'UTC'))::int as previous_stop_departure_sec"
" , (COALESCE(ve.vp_stop_timestamp, ve.tu_stop_timestamp) - extract(epoch FROM vt.service_date::text::timestamp WITH TIME ZONE AT TIME ZONE 'UTC'))::int as stop_arrival_sec"
" , (COALESCE(ve.vp_stop_timestamp, ve.tu_stop_timestamp) - extract(epoch FROM vt.service_date::text::timestamp WITH TIME ZONE AT TIME ZONE 'UTC') + ve.dwell_time_seconds)::int as stop_departure_sec"
" , (ve.vp_move_timestamp - extract(epoch FROM vt.service_date::text::timestamp WITHOUT TIME ZONE AT TIME ZONE 'America/New_York'))::int as previous_stop_departure_sec"
" , (COALESCE(ve.vp_stop_timestamp, ve.tu_stop_timestamp) - extract(epoch FROM vt.service_date::text::timestamp WITHOUT TIME ZONE AT TIME ZONE 'America/New_York'))::int as stop_arrival_sec"
" , (COALESCE(ve.vp_stop_timestamp, ve.tu_stop_timestamp) - extract(epoch FROM vt.service_date::text::timestamp WITHOUT TIME ZONE AT TIME ZONE 'America/New_York') + ve.dwell_time_seconds)::int as stop_departure_sec"
" , vt.direction_id::int"
" , vt.route_id"
" , vt.branch_route_id"
Expand Down Expand Up @@ -184,7 +183,6 @@ def update_parquet(self, db_manager: DatabaseManager) -> bool:
write_path=db_parquet_path,
schema=self.parquet_schema,
)
db_manager.execute(sa.text("SET SESSION timezone to 'UTC';"))

# update downloaded parquet file with filtered service_date
old_filter = pc.field("service_date") < max_start_date
Expand Down

0 comments on commit 318f172

Please sign in to comment.