Skip to content

Commit 7e05c61

Browse files
authored
Merge branch 'main' into di-471-improvements-to-dq-outputs
2 parents a8a3d9c + c47c1c0 commit 7e05c61

File tree

4 files changed

+90
-67
lines changed

4 files changed

+90
-67
lines changed

scripts/jobs/parking/parking_correspondence_performance_records_with_pcn_downtime.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
6161
16/06/2022 - Created
6262
21/04/2023 - added teams data from google spreadsheet load - https://docs.google.com/spreadsheets/d/1zxZXX1_qU9NW93Ug1JUy7aXsnTz45qIj7Zftmi9trbI/edit?usp=sharing
6363
02/10/2023 - modified to union data into one output for Downtime data gathered from Google form https://forms.gle/bB53jAayiZ2Ykwjk6
64-
64+
06/11/2024 - updated date formats in downtime data as source google sheet changed to yyyy-mm-dd HH:MM:ss from d/m/y
6565
*/
6666
/*Teams data from google spreadsheet load - https://docs.google.com/spreadsheets/d/1zxZXX1_qU9NW93Ug1JUy7aXsnTz45qIj7Zftmi9trbI/edit?usp=sharing*/
6767
With team as (
@@ -342,38 +342,38 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
342342
,liberator_system_username
343343
,liberator_system_id
344344
,cast(import_datetime as string) import_datetime
345-
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60) > 1440 then 1 else 0 end as string) as multiple_downtime_days_flag
346-
,cast(unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')) as string) as response_secs
347-
,cast(Case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' then (unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 end as string) as response_mins
348-
,cast(Case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' then (unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/3600 end as string) as response_hours
345+
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60) > 1440 then 1 else 0 end as string) as multiple_downtime_days_flag
346+
,cast(unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')) as string) as response_secs
347+
,cast(Case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' then (unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 end as string) as response_mins
348+
,cast(Case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' then (unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/3600 end as string) as response_hours
349349
350350
/*Downtime calendar days*/
351-
,cast(Case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' then datediff( cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date) )+1 end as string) as response_days_plus_one -- downtime days plus one calendar day
351+
,cast(Case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' then datediff( cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date) )+1 end as string) as response_days_plus_one -- downtime days plus one calendar day
352352
353353
/*Downtime non working mins*/
354-
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 948
355-
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) < 1440 then 948 end as string) as downtime_total_non_working_mins_with_lunch --if greater than 1440 mins then (days + 1) * 948 "
356-
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 1008
357-
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) < 1440 then 1008 end as string) as downtime_total_non_working_mins --if greater than 1440 mins then (days + 1) * 1008 "
354+
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 948
355+
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) < 1440 then 948 end as string) as downtime_total_non_working_mins_with_lunch --if greater than 1440 mins then (days + 1) * 948 "
356+
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 1008
357+
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) < 1440 then 1008 end as string) as downtime_total_non_working_mins --if greater than 1440 mins then (days + 1) * 1008 "
358358
359359
/*Downtime working mins*/
360-
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 492
361-
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) < 1440 then 492 end as string) as downtime_total_working_mins_with_lunch -- 492 mins = 8hrs 12 mins working day including lunch"
362-
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 432
363-
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) < 1440 then 432 end as string) as downtime_total_working_mins --432 mins = 7hrs 12mins working hours"
360+
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 492
361+
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) < 1440 then 492 end as string) as downtime_total_working_mins_with_lunch -- 492 mins = 8hrs 12 mins working day including lunch"
362+
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 432
363+
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) < 1440 then 432 end as string) as downtime_total_working_mins --432 mins = 7hrs 12mins working hours"
364364
365365
/*Downtime working mins net (less downtime mins)*/
366-
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 492
367-
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) < 1440 then 492 - /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) end as string) as downtime_total_working_mins_with_lunch_net -- 492 mins = 8hrs 12 mins working day including lunch less downtime"
368-
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 432
369-
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) < 1440 then 432 - (/* downtime mins (response_mins)*/ (unix_timestamp(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss')))/60 ) end as string) as downtime_total_working_mins_net --432 mins = 7hrs 12mins working hours"
366+
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 492
367+
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) < 1440 then 492 - /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) end as string) as downtime_total_working_mins_with_lunch_net -- 492 mins = 8hrs 12 mins working day including lunch less downtime"
368+
,cast(case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) > 1440 then /*response_days_plus_one*/(datediff( cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date) )+1) * 432
369+
When parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' and /* downtime mins (response_mins)*/ ((unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) < 1440 then 432 - (/* downtime mins (response_mins)*/ (unix_timestamp(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss')) - unix_timestamp(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss')))/60 ) end as string) as downtime_total_working_mins_net --432 mins = 7hrs 12mins working hours"
370370
371371
,cast(substr(cast(start_date as string), 12, 5) as string) as start_date_time
372372
,cast(substr(cast(start_date as string), 1, 10) as string) as startdate
373-
,cast(Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,16) as string) as start_date_datetime
373+
,cast(Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,16) as string) as start_date_datetime
374374
,cast(substr(cast(end_date as string), 12, 5) as string) as end_date_time
375375
,cast(substr(cast(end_date as string), 1, 10) as string) as enddate
376-
,cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,16) as string) as end_date_datetime
376+
,cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,16) as string) as end_date_datetime
377377
,'Downtime' as response_status
378378
,cast(current_timestamp as string) as Current_time_stamp
379379
@@ -382,7 +382,7 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
382382
,'' as to_assigned_time
383383
,'' as assigned_in_progress_time
384384
,'' as assigned_response_time
385-
,(cast (cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,16) as timestamp) - cast ( Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,16) as timestamp) as string) ) as response_time --as downtime_duration --line 30
385+
,(cast (cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,16) as timestamp) - cast ( Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,16) as timestamp) as string) ) as response_time --as downtime_duration --line 30
386386
,'' as unassigned_days
387387
,'' as unassigned_days_group
388388
,'' as unassigned_days_kpiTotFiftySixLess
@@ -399,15 +399,15 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
399399
,'' as assignedResponseDays_group
400400
,'' as assignedResponseDays_kpiTotFiftySixLess
401401
,'' as assignedResponseDays_kpiTotFourteenLess
402-
,cast( Case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' then datediff( cast(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,10) as date) ) end as string) as ResponseDays --as downtime_duration in days
402+
,cast( Case when parking_officer_downtime.timestamp not like '' and parking_officer_downtime.timestamp not like '#REF!' then datediff( cast(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date), cast(Substr(cast(to_timestamp(start_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,10) as date) ) end as string) as ResponseDays --as downtime_duration in days
403403
,'' as ResponseDays_group
404404
,'' as ResponseDays_kpiTotFiftySixLess
405405
,'' as ResponseDays_kpiTotFourteenLess
406406
, end_date as Response_generated_at
407407
, start_date as Date_Received
408-
,concat(Substr(cast(to_timestamp(end_date,'dd/MM/yyyy HH:mm:ss') as varchar(30)),1,7), '-01') as MonthYear
408+
,concat(Substr(cast(to_timestamp(end_date,'yyyy-MM-dd HH:mm:ss') as varchar(30)),1,7), '-01') as MonthYear
409409
,'Downtime' as Type
410-
,parking_officer_downtime.downtime as Serviceable -- downtime --,'Downtime' as Serviceable -- downtime
410+
,parking_officer_downtime.Downtime as Serviceable -- downtime
411411
,'' as Service_category
412412
,concat(officer_s_first_name,' ',officer_s_last_name) as Response_written_by --downtime officer full name
413413
,'' as Letter_template
@@ -549,7 +549,8 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
549549
,'' as t_notes
550550
,'' as t_import_date
551551
552-
from parking_officer_downtime where import_date = (select max(import_date) from parking_officer_downtime) and timestamp not like '' and timestamp not like '#REF!'
552+
from parking_officer_downtime where import_date = (select max(import_date) from parking_officer_downtime) and timestamp not like '' and timestamp not like '#REF!'
553+
AND cast(Substr( cast(parking_officer_downtime.timestamp as string) ,1,10) as date) > current_date - interval '13' month --Last 13 months from todays date
553554
--order by timestamp desc
554555
"""
555556
ApplyMapping_node2 = sparkSqlQuery(

0 commit comments

Comments
 (0)