-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueries.py
96 lines (93 loc) · 2.38 KB
/
queries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
insert_residential_details = """INSERT INTO stg_parcel_residential_details(
parcel_id,
card,
class,
grade,
cdu,
style,
acres,
year_built_effective_year,
remodeled_year,
base_area,
finished_bsmt_area,
number_of_stories,
exterior_wall,
basement,
physical_condition,
heating,
heat_fuel_type,
heating_system,
attic_code,
fireplaces,
parking,
total_rooms,
full_baths,
half_baths,
total_fixtures,
additional_fixtures,
bed_rooms,
family_room,
living_units)
VALUES (
'{parcel_id}',
'{card}',
'{class_input}',
'{grade}',
'{cdu}',
'{style}',
'{acres}',
'{year_built_effective_year}',
'{remodeled_year}',
'{base_area}',
'{finished_bsmt_area}',
'{number_of_stories}',
'{exterior_wall}',
'{basement}',
'{physical_condition}',
'{heating}',
'{heat_fuel_type}',
'{heating_system}',
'{attic_code}',
'{fireplaces}',
'{parking}',
'{total_rooms}',
'{full_baths}',
'{half_baths}',
'{total_fixtures}',
'{additional_fixtures}',
'{bed_rooms}',
'{family_room}',
'{living_units}'
)"""
insert_parcel_site_details = """INSERT INTO stg_parcel_site_details(
parcel_id,
site_location,
legal_description,
municipality,
school_district,
property_type)
VALUES (
'{parcel_id}',
'{site_location}',
'{legal_description}',
'{municipality}',
'{school_district}',
'{property_type}'
)"""
get_missing_data = {
'residential_details': """SELECT P.PARCEL_ID
FROM DIM_PARCEL P
LEFT JOIN dim_parcel_residential_details FPD ON FPD.ID = P.ID
GROUP BY P.PARCEL_ID
HAVING COUNT(FPD.ID) = 0
ORDER BY P.PARCEL_ID DESC""",
'parcel_site_details': """call public.sp_update_dim_parcel_all();
truncate stg_parcel_site_details;
SELECT P.PARCEL_ID
FROM DIM_PARCEL P
LEFT JOIN (select distinct parcel_id from stg_parcel_site_details) sd
on sd.parcel_id = p.parcel_id
WHERE municipality is null
and sd.parcel_id is null
ORDER BY P.PARCEL_ID DESC;"""
}