Skip to content

Commit 9bd4477

Browse files
committed
Additional amended sql queries to only include key columns and rows for homeownership and also amend id fields
1 parent 4f0ff38 commit 9bd4477

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

scripts/helpers/housing_gx_dq_inputs.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'id_field': 'tenancy_id'},
88
'contacts_reshape': {
99
'sql': """SELECT
10+
id,
1011
DATE_FORMAT(from_iso8601_timestamp(createdat), '%Y-%b-%d') AS createdat,
1112
contacttype,
1213
subtype,
@@ -23,7 +24,21 @@
2324
and import_date = (select max(import_date) from "housing-refined-zone"."contacts_reshape")""",
2425
'id_field': 'id'},
2526
'housing_homeowner_record_sheet': {
26-
'sql': """SELECT * FROM "housing-raw-zone"."housing_homeowner_record_sheet" where import_date=(select max(import_date) from "housing-raw-zone"."housing_homeowner_record_sheet")""",
27+
'sql': """SELECT
28+
property_no,
29+
date_of_ownership,
30+
tenancy,
31+
managing_agent_name_address,
32+
managing_agent_phone_number,
33+
managing_agent_email,
34+
rtb_date,
35+
managing_agent_name,
36+
import_year,
37+
import_month,
38+
import_day,
39+
import_date
40+
FROM "housing-raw-zone"."housing_homeowner_record_sheet"
41+
where import_date = (select max(import_date) from "housing-raw-zone"."housing_homeowner_record_sheet")""",
2742
'id_field': 'property_no'},
2843
'housing_dwellings_list': {
2944
'sql': """SELECT
@@ -88,7 +103,7 @@
88103
import_date
89104
FROM "housing-refined-zone"."assets_reshape" where import_date = (select max(import_date) from "housing-refined-zone"."assets_reshape")
90105
and assettype in ('BoilerHouse','BoosterPump','CleanersFacilities','CombinedHeatAndPowerUnit','CommunityHall','Concierge','Dwelling','LettableNonDwelling','Lift','NA','NBD','OutBuilding','TravellerSite')""",
91-
'id_field': 'asset_id'},
106+
'id_field': 'assetid'},
92107
'matenancyagreement': {
93108
'sql': """SELECT *, substr(cast(eot as varchar), 1, 10) as eot_parsed, substr(cast(cot as varchar), 1, 10) as cot_parsed FROM "housing-raw-zone"."sow2b_dbo_matenancyagreement" where import_date=(select max(import_date) FROM "housing-raw-zone"."sow2b_dbo_matenancyagreement")""",
94109
'id_field': 'tag_ref'},

0 commit comments

Comments
 (0)