forked from OvertureMaps/data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathathena_setup_queries.sql
More file actions
176 lines (150 loc) · 5.52 KB
/
athena_setup_queries.sql
File metadata and controls
176 lines (150 loc) · 5.52 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
------------------------------------------------------------------------
-- Set up the Overture Maps data tables in Amazon Athena on AWS
------------------------------------------------------------------------
-- The below Athena SQL queries will create tables in your AWS account's
-- data catalog pointing directly to data hosted on Overture's S3
-- bucket. You can then query Overture data directly from Athena without
-- needing to copy it.
--
-- 💡 TIP: Athena only allows one SQL statement to be run at a time, so
-- highlight and run each SQL query separately.
-- 💡 TIP: Overture's S3 bucket is located in the us-west-2 AWS region,
-- so use Athena in us-west-2 for best performance.
------------------------------------------------------------------------
-- October 2023 Release:
CREATE EXTERNAL TABLE `overture_2023_10_19_alpha_0`(
`categories` struct<main:string,alternate:array<string>>,
`level` int,
`socials` array<string>,
`subtype` string,
`numfloors` int,
`entityid` string,
`class` string,
`sourcetags` map<string,string>,
`localitytype` string,
`emails` array<string>,
`drivingside` string,
`adminlevel` int,
`road` string,
`isocountrycodealpha2` string,
`isosubcountrycode` string,
`updatetime` string,
`wikidata` string,
`confidence` double,
`defaultlanguage` string,
`brand` struct<names:struct<common:array<struct<value:string,language:string>>,official:array<struct<value:string,language:string>>,alternate:array<struct<value:string,language:string>>,short:array<struct<value:string,language:string>>>,wikidata:string>,
`addresses` array<struct<freeform:string,locality:string,postCode:string,region:string,country:string>>,
`names` struct<common:array<struct<value:string,language:string>>,official:array<struct<value:string,language:string>>,alternate:array<struct<value:string,language:string>>,short:array<struct<value:string,language:string>>>,
`isintermittent` boolean,
`connectors` array<string>,
`surface` string,
`version` int,
`phones` array<string>,
`id` string,
`geometry` binary,
`context` string,
`height` double,
`maritime` boolean,
`sources` array<struct<property:string,dataset:string,recordId:string,confidence:double>>,
`websites` array<string>,
`issalt` boolean,
`bbox` struct<minx:double,maxx:double,miny:double,maxy:double>)
PARTITIONED BY (
`theme` string,
`type` string)
STORED AS PARQUET
LOCATION
's3://overturemaps-us-west-2/release/2023-10-19-alpha.0'
-- =====================================================================
-- The below queries are for the July 2023 Data Release
-- Admins theme
-- =====================================================================
CREATE EXTERNAL TABLE `admins`(
`id` string,
`updateTime` string,
`version` int,
`names` map<string,array<map<string,string>>>,
`adminLevel` int,
`maritime` string,
`subType` string,
`localityType` string,
`context` string,
`isoCountryCodeAlpha2` string,
`isoSubCountryCode` string,
`defaultLanugage` string,
`drivingSide` string,
`sources` array<map<string,string>>,
`bbox` struct<minX:double,maxX:double,minY:double,maxY:double>,
`geometry` binary)
PARTITIONED BY (
`type` string)
STORED AS PARQUET
LOCATION
's3://overturemaps-us-west-2/release/2023-10-19-alpha.0/theme=admins'
MSCK REPAIR TABLE `admins`
-- =====================================================================
-- Buildings theme
-- =====================================================================
CREATE EXTERNAL TABLE `buildings`(
`id` string,
`updateTime` string,
`version` int,
`names` map<string,array<map<string,string>>>,
`level` int,
`height` double,
`numFloors` int,
`class` string,
`sources` array<map<string,string>>,
`bbox` struct<minX:double,maxX:double,minY:double,maxY:double>,
`geometry` binary)
PARTITIONED BY (
`type` varchar(8))
STORED AS PARQUET
LOCATION
's3://overturemaps-us-west-2/release/2023-10-19-alpha.0/theme=buildings'
MSCK REPAIR TABLE `buildings`
-- =====================================================================
-- Places theme
-- =====================================================================
CREATE EXTERNAL TABLE `places`(
`id` string,
`updateTime` string,
`version` int,
`names` map<string,array<map<string,string>>>,
`categories` struct<main:string,alternate:array<string>>,
`confidence` double,
`websites` array<string>,
`socials` array<string>,
`emails` array<string>,
`phones` array<string>,
`brand` struct<names:map<string,array<map<string,string>>>,wikidata:string>,
`addresses` array<map<string,string>>,
`sources` array<map<string,string>>,
`bbox` struct<minX:double,maxX:double,minY:double,maxY:double>,
`geometry` binary)
PARTITIONED BY (
`type` varchar(5))
STORED AS PARQUET
LOCATION
's3://overturemaps-us-west-2/release/2023-10-19-alpha.0/theme=places'
MSCK REPAIR TABLE `places`
-- =====================================================================
-- Transportation theme
-- =====================================================================
CREATE EXTERNAL TABLE `transportation`(
`id` string,
`updateTime` timestamp,
`version` int,
`level` int,
`subType` varchar(4),
`connectors` array<string>,
`road` string,
`sources` array<map<string,string>>,
`bbox` struct<minX:double,maxX:double,minY:double,maxY:double>,
`geometry` binary)
PARTITIONED BY (
`type` varchar(9))
STORED AS PARQUET
LOCATION
's3://overturemaps-us-west-2/release/2023-10-19-alpha.0/theme=transportation'
MSCK REPAIR TABLE `transportation`