|
6 | 6 | 'sql': """SELECT * FROM "housing-refined-zone"."tenure_reshape" where import_date=(select max(import_date) from "housing-refined-zone"."tenure_reshape") and description in ('Secure', 'Introductory', 'Mesne Profit Ac', 'Non-Secure') and (endoftenuredate is null or substr(endoftenuredate, 1, 11) = '1900-01-01')""", |
7 | 7 | 'id_field': 'tenancy_id'}, |
8 | 8 | 'contacts_reshape': { |
9 | | - 'sql': """SELECT id, targetid, substr(createdat, 1, 10) as createdat, contacttype, subtype, value, substr(lastmodified, 1, 10) as lastmodified, targettype, isactive, person_id, import_date FROM "housing-refined-zone"."contacts_reshape" where import_date=(select max(import_date) from "housing-refined-zone"."contacts_reshape") and isactive=True""", |
| 9 | + 'sql': """SELECT |
| 10 | + DATE_FORMAT(from_iso8601_timestamp(createdat), '%Y-%b-%d') AS createdat, |
| 11 | + contacttype, |
| 12 | + subtype, |
| 13 | + cast(value as varchar) as contact_value, |
| 14 | + DATE_FORMAT(from_iso8601_timestamp(lastmodified), '%Y-%b-%d') AS lastmodified, |
| 15 | + targettype, |
| 16 | + person_id, |
| 17 | + import_year, |
| 18 | + import_month, |
| 19 | + import_day, |
| 20 | + import_date |
| 21 | + FROM "housing-refined-zone"."contacts_reshape" |
| 22 | + where targettype = 'person' |
| 23 | + and import_date = (select max(import_date) from "housing-refined-zone"."contacts_reshape")""", |
10 | 24 | 'id_field': 'id'}, |
11 | 25 | 'housing_homeowner_record_sheet': { |
12 | 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")""", |
13 | 27 | 'id_field': 'property_no'}, |
14 | 28 | 'housing_dwellings_list': { |
15 | | - 'sql': """SELECT * FROM "housing-raw-zone"."housing_dwellings_list" where import_date=(select max(import_date) from "housing-raw-zone"."housing_homeowner_record_sheet")""", |
| 29 | + 'sql': """SELECT |
| 30 | + cast(property_dwelling_reference_number as varchar) as property_dwelling_reference_number, |
| 31 | + cast(llpg as varchar) as llpg, |
| 32 | + cast(estate_reference_number as varchar) as estate_reference_number, |
| 33 | + estate_name, |
| 34 | + block_name_as_per_naming_convention_procedure as block_name, |
| 35 | + cast(block_reference_number as varchar) as block_reference_number, |
| 36 | + sub_block_name, |
| 37 | + cast(sub_block_reference as varchar) as sub_block_reference, |
| 38 | + block_total_stories, |
| 39 | + block_typology_based_on_dwelling_type_defined_list as block_typology, |
| 40 | + building_heights_h1, |
| 41 | + communal_heat_network, |
| 42 | + dwelling_front_door_access_floor_level, |
| 43 | + dwelling_no_of_bedrooms, |
| 44 | + fra_block, |
| 45 | + no_of_floors_within_dwelling, |
| 46 | + registered_building, |
| 47 | + year_built_block |
| 48 | + FROM "housing-raw-zone"."housing_dwellings_list" where import_date = (select max(import_date) from "housing-raw-zone"."housing_dwellings_list")""", |
16 | 49 | 'id_field': 'property_dwelling_reference_number'}, |
17 | 50 | 'assets_reshape': { |
18 | | - 'sql': """SELECT * FROM "housing-refined-zone"."assets_reshape" where import_date=(select max(import_date) from "housing-refined-zone"."assets_reshape") and assettype = 'Dwelling'""", |
| 51 | + 'sql': """select |
| 52 | + cast(assetid as varchar) as assetid, |
| 53 | + assettype, |
| 54 | + cast(uprn as varchar) as uprn, |
| 55 | + owner as property_owner, |
| 56 | + agent, |
| 57 | + iscouncilproperty, |
| 58 | + istmomanaged, |
| 59 | + managingorganisation, |
| 60 | + cast(managingorganisationid as varchar) as managingorganisationid, |
| 61 | + totalblockfloors, |
| 62 | + floorno, |
| 63 | + numberoflifts, |
| 64 | + numberoflivingrooms, |
| 65 | + numberofkitchens, |
| 66 | + numberofbedrooms, |
| 67 | + numberofbedspaces, |
| 68 | + numberofshowers, |
| 69 | + numberoffloors, |
| 70 | + numberofdoublebeds, |
| 71 | + numberofsinglebeds, |
| 72 | + numberofbathrooms, |
| 73 | + yearconstructed, |
| 74 | + hascommunalareas, |
| 75 | + hasprivatekitchen, |
| 76 | + hasprivatebathroom, |
| 77 | + hasrampaccess, |
| 78 | + isstepfree, |
| 79 | + hasstairs, |
| 80 | + heating, |
| 81 | + numberofcots, |
| 82 | + windowtype, |
| 83 | + estate_name, |
| 84 | + cast(estate_id as varchar) as estate_id, |
| 85 | + import_year, |
| 86 | + import_month, |
| 87 | + import_day, |
| 88 | + import_date |
| 89 | + FROM "housing-refined-zone"."assets_reshape" where import_date = (select max(import_date) from "housing-refined-zone"."assets_reshape") |
| 90 | + and assettype in ('BoilerHouse','BoosterPump','CleanersFacilities','CombinedHeatAndPowerUnit','CommunityHall','Concierge','Dwelling','LettableNonDwelling','Lift','NA','NBD','OutBuilding','TravellerSite')""", |
19 | 91 | 'id_field': 'asset_id'}, |
20 | 92 | 'matenancyagreement': { |
21 | 93 | '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")""", |
|
0 commit comments