Skip to content

Commit a63343f

Browse files
authored
Merge branch 'main' into di-447-amend-dq-tests-for-housing
2 parents dae6183 + a9ff9a5 commit a63343f

25 files changed

+272
-550
lines changed

docker/sql-to-parquet/entrypoint.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,18 @@ echo "Snapshot Id - $SNAPSHOT_ID"
1919
FILENAME="liberator_dump_${DATE}"
2020
DBNAME="liberator"
2121

22-
MYSQL_CONN_PARAMS="--user=${MYSQL_USER} --password=${MYSQL_PASS} --host=${MYSQL_HOST}"
22+
echo "Retrieving pem file..."
23+
wget -O /tmp/rds-combined-ca-bundle.pem https://truststore.pki.rds.amazonaws.com/eu-west-2/eu-west-2-bundle.pem
2324

24-
SSL_MODE=${MYSQL_SSL_MODE:-""}
25-
OTHER_FLAGS=${MYSQL_OTHER_FLAGS:-""}
25+
MYSQL_CONN_PARAMS="--user=${MYSQL_USER} --password=${MYSQL_PASS} --host=${MYSQL_HOST} --ssl-ca=/tmp/rds-combined-ca-bundle.pem"
2626

27-
if [ -n "$SSL_MODE" ]; then
28-
MYSQL_CONN_PARAMS="$MYSQL_CONN_PARAMS --ssl-mode=$SSL_MODE"
29-
echo "SSL Mode set to $SSL_MODE"
30-
fi
27+
OTHER_FLAGS=${MYSQL_OTHER_FLAGS:-""}
3128

3229
if [ -n "$OTHER_FLAGS" ]; then
3330
MYSQL_CONN_PARAMS="$MYSQL_CONN_PARAMS $OTHER_FLAGS"
3431
echo "Additional MySQL flags: $OTHER_FLAGS"
3532
fi
3633

37-
echo "MYSQL connection params: $MYSQL_CONN_PARAMS"
38-
3934
echo "Deleting old snapshots in database..."
4035
python3 delete_db_snapshots_in_db.py
4136

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
notifications-python-client==10.0.0
1+
notifications-python-client==10.0.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
numpy==2.1.3
1+
numpy==2.2.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
gspread==6.1.4
22
oauth2client==4.1.3
3-
google-api-python-client==2.154.0
3+
google-api-python-client==2.156.0
44
yagmail==0.15.293
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
urllib3==2.2.3
1+
urllib3==2.3.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
s3fs==2024.10.0
1+
s3fs==2024.12.0

lambdas/vonage_api_ingestion/Pipfile.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
"""
2+
Only need to change the table name and the query prototyped on the Athena UI
3+
by replacing table_name and query_on_athena
4+
Note: python file name should be the same as the table name
5+
"""
6+
7+
from scripts.helpers.athena_helpers import create_update_table_with_partition
8+
from scripts.helpers.helpers import get_glue_env_var
9+
10+
environment = get_glue_env_var("environment")
11+
12+
# The target table in liberator refined zone
13+
table_name = "Parking_interim_cycle_hangar_waiting_list"
14+
15+
# The exact same query prototyped in pre-prod(stg) or prod Athena
16+
query_on_athena = """
17+
/*********************************************************************************
18+
Parking_interim_cycle_hangar_waiting_list
19+
20+
Process the interim cycle hangar waiting list (supplied by Michael W) to add
21+
additional fields (telephone Number, etc).
22+
23+
23/12/2024 - Create SQL
24+
*********************************************************************************/
25+
With Interim_Wait as (
26+
SELECT
27+
distinct forename
28+
,surname
29+
,email
30+
,party_id_to
31+
,party_id
32+
,cast(uprn as decimal) as uprn
33+
,address1
34+
,address2
35+
,post_code
36+
,x
37+
,y
38+
,lat
39+
,long
40+
FROM "parking-raw-zone".interim_cycle_wait_list
41+
WHERE import_date = (select max(import_date)
42+
from "parking-raw-zone".interim_cycle_wait_list)),
43+
44+
/*** Obtain the llpg data ***/
45+
FULL_LLPG as (
46+
SELECT * From "parking-refined-zone".spatially_enriched_liberator_permit_llpg
47+
WHERE import_Date = format_datetime(current_date, 'yyyyMMdd')
48+
AND address1 not like '%STREET RECORD%'),
49+
50+
STREET_LLPG as (
51+
SELECT * From "parking-refined-zone".spatially_enriched_liberator_permit_llpg
52+
WHERE import_Date = format_datetime(current_date, 'yyyyMMdd')
53+
AND address1 like '%STREET RECORD%'),
54+
55+
/*** Obtain the Party details, where available ***/
56+
Party as (
57+
SELECT
58+
*
59+
From "dataplatform-stg-liberator-raw-zone".liberator_licence_party
60+
WHERE import_Date = format_datetime(current_date, 'yyyyMMdd')),
61+
62+
/*** obtain the emails (from Tom) of those parties that are NOT interested in a Hangar***/
63+
unsubscribed_emails as (
64+
SELECT *,
65+
ROW_NUMBER() OVER ( PARTITION BY email_address ORDER BY email_address DESC) row1
66+
FROM "parking-raw-zone".parking_parking_cycle_hangar_unsubscribed_emails
67+
WHERE import_Date = format_datetime(current_date, 'yyyyMMdd'))
68+
69+
SELECT
70+
A.*, cast(D.telephone_number as varchar) as Telephone_Number, C.address2 as Street, B.housing_estate, E.email_address,
71+
72+
format_datetime(CAST(CURRENT_TIMESTAMP AS timestamp),
73+
'yyyy-MM-dd HH:mm:ss') AS import_date_timestamp,
74+
75+
format_datetime(current_date, 'yyyy') AS import_year,
76+
format_datetime(current_date, 'MM') AS import_month,
77+
format_datetime(current_date, 'dd') AS import_day,
78+
format_datetime(current_date, 'yyyyMMdd') AS import_date
79+
80+
FROM Interim_Wait as A
81+
LEFT JOIN FULL_LLPG as B ON A.uprn = B.UPRN
82+
LEFT JOIN STREET_LLPG as C ON B.USRN = C.USRN
83+
LEFT JOIN Party as D ON A.party_id = D.business_party_id
84+
LEFT JOIN unsubscribed_emails as E ON upper(ltrim(rtrim(A.email))) = upper(ltrim(rtrim(E.email_address)))
85+
AND row1 = 1
86+
"""
87+
88+
create_update_table_with_partition(
89+
environment=environment, query_on_athena=query_on_athena, table_name=table_name
90+
)

scripts/jobs/parking/parking_cedar_payments.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
6262
SELECT
6363
cc, subj,analysis, trandate,
6464
CASE
65-
When trandate like '%/%'Then CAST(substr(trandate, 7, 4)||'-'||substr(trandate, 4,2)||'-'||'01' as date)
65+
When trandate like '%/%' Then
66+
CAST(substr(trandate, 7, 4)||'-'||substr(trandate, 4,2)||'-'||'01' as date)
67+
When substr(trandate, 1, 4) like '%-%' Then
68+
CAST(substr(trandate, 7, 4)||'-'||substr(trandate, 4,2)||'-'||'01' as date)
6669
ELSE cast(concat(substr(Cast(trandate as varchar(10)),1, 7), '-01') as date)
6770
END as PayMonthYear,
6871
description, o_description, cast(financialvalue as decimal(10,2)) as financialvalue

scripts/requirements.build.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
setuptools
22
wheel
33
boto3
4-
redshift-connector==2.1.4 # used to connect with redshift
4+
redshift-connector==2.1.5 # used to connect with redshift

0 commit comments

Comments
 (0)