Datasets:

Modalities:
Tabular
Text
Formats:
parquet
Libraries:
Datasets
Dask
License:
File size: 8,705 Bytes
e7528ab
 
 
 
 
 
 
 
 
aeaab5e
e7528ab
 
 
 
 
07de18f
e7528ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f2dad7
e7528ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f2dad7
e7528ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
---
license: apache-2.0
---
# Access FSQ OS Places
 
With Foursquare’s Open Source Places, you can access free data to accelerate geospatial innovation and insights. View the [Places OS Data Schemas](https://docs.foursquare.com/data-products/docs/places-os-data-schema) for a full list of available attributes.

## Prerequisites

In order to access Foursquare's Open Source Places data, you will need to download the following files:

- Parquet Files:
  - **Places** - [release/dt=2024-11-19/places/parquet](https://huggingface.co./datasets/foursquarelabsadmin/fsq-open-src-places-test/tree/main/release/dt%3D2024-11-19/places/parquet)
  - **Categories** - [release/dt=2024-11-19/categories/parquet](https://huggingface.co./datasets/foursquarelabsadmin/fsq-open-src-places-test/tree/main/release/dt%3D2024-11-19/categories/parquet)

Hugging Face provides the following [download options](https://huggingface.co./docs/hub/datasets-downloading).

## Example Queries

The following are examples on how to query FSQ Open Source Places using Athena and Spark:

- Filter [Categories](https://docs.foursquare.com/data-products/docs/categories#places-open-source--propremium-flat-file) by the parent level
- Filter out [non-commercial venues](#non-commercial-categories-table) 
- Find open and recently active POI

### Filter by Parent Level Category

**Presto/Athena**
```sql Presto/Athena
WITH places_exploded_categories AS (
  -- Unnest categories array
  SELECT fsq_place_id,
         cid as fsq_category_id
  FROM places p
  CROSS JOIN UNNEST(p.fsq_category_ids) AS t(cid) 
),
 distinct_places AS (
  SELECT 
       DISTINCT(fsq_place_id) -- Get distinct ids to reduce duplicates from cross join
  FROM places_exploded_categories p
  JOIN categories c -- Join to categories to filter on Level 2 Category
  ON p.fsq_category_id = c.category_id 
  WHERE c.level2_category_id = '4d4b7105d754a06374d81259' -- Restaurants
)
SELECT * FROM places
WHERE fsq_place_id IN (SELECT fsq_place_id FROM distinct_places)

```
**SparkSQL**
```sql SparkSQL
WITH places_exploded_categories AS (
  -- Unnest categories array
  SELECT fsq_place_id, 
         name, 
         explode(fsq_category_ids) as fsq_category_id 
  FROM places
),
 distinct_places AS (
  SELECT 
	DISTINCT(fsq_place_id) -- Get distinct ids to reduce duplicates from explode function
  FROM places_exploded_categories p 
  JOIN categories c -- Join to categories to filter on Level 2 Category
  ON p.fsq_category_id = c.category_id 
  WHERE c.level2_category_id = '4d4b7105d754a06374d81259' -- Restaurants
)
SELECT * FROM places
WHERE fsq_place_id IN (SELECT fsq_place_id FROM distinct_places)
```
### Filter out Non-Commercial Categories
**Presto/Athena**
```sql Presto/Athena
SELECT * FROM places 
WHERE arrays_overlap(fsq_category_ids, ARRAY['4bf58dd8d48988d1f0931735'	-- Airport Gate 
'62d587aeda6648532de2b88c'	-- Beer Festival 
'4bf58dd8d48988d12b951735'	-- Bus Line 
'52f2ab2ebcbc57f1066b8b3b'	-- Christmas Market 
'50aa9e094b90af0d42d5de0d'	-- City 
'5267e4d9e4b0ec79466e48c6'	-- Conference 
'5267e4d9e4b0ec79466e48c9'	-- Convention 
'530e33ccbcbc57f1066bbff7'	-- Country 
'5345731ebcbc57f1066c39b2'	-- County 
'63be6904847c3692a84b9bb7'	-- Entertainment Event 
'4d4b7105d754a06373d81259'	-- Event 
'5267e4d9e4b0ec79466e48c7'	-- Festival 
'4bf58dd8d48988d132951735'	-- Hotel Pool 
'52f2ab2ebcbc57f1066b8b4c'	-- Intersection 
'50aaa4314b90af0d42d5de10'	-- Island 
'58daa1558bbb0b01f18ec1fa'	-- Line 
'63be6904847c3692a84b9bb8'	-- Marketplace 
'4f2a23984b9023bd5841ed2c'	-- Moving Target 
'5267e4d9e4b0ec79466e48d1'	-- Music Festival 
'4f2a25ac4b909258e854f55f'	-- Neighborhood 
'5267e4d9e4b0ec79466e48c8'	-- Other Event 
'52741d85e4b0d5d1e3c6a6d9'	-- Parade 
'4bf58dd8d48988d1f7931735'	-- Plane 
'4f4531504b9074f6e4fb0102'	-- Platform 
'4cae28ecbf23941eb1190695'	-- Polling Place 
'4bf58dd8d48988d1f9931735'	-- Road 
'5bae9231bedf3950379f89c5'	-- Sporting Event 
'530e33ccbcbc57f1066bbff8'	-- State 
'530e33ccbcbc57f1066bbfe4'	-- States and Municipalities 
'52f2ab2ebcbc57f1066b8b54'	-- Stoop Sale 
'5267e4d8e4b0ec79466e48c5'	-- Street Fair 
'53e0feef498e5aac066fd8a9'	-- Street Food Gathering 
'4bf58dd8d48988d130951735'	-- Taxi 
'530e33ccbcbc57f1066bbff3'	-- Town 
'5bae9231bedf3950379f89c3'	-- Trade Fair 
'4bf58dd8d48988d12a951735'	-- Train 
'52e81612bcbc57f1066b7a24'	-- Tree 
'530e33ccbcbc57f1066bbff9'	-- Village
]) = false
```
**SparkSQL**
```sql SparkSQL
SELECT * 
FROM places
WHERE arrays_overlap(fsq_category_ids, array('4bf58dd8d48988d1f0931735'	-- Airport Gate 
'62d587aeda6648532de2b88c'	-- Beer Festival 
'4bf58dd8d48988d12b951735'	-- Bus Line 
'52f2ab2ebcbc57f1066b8b3b'	-- Christmas Market 
'50aa9e094b90af0d42d5de0d'	-- City 
'5267e4d9e4b0ec79466e48c6'	-- Conference 
'5267e4d9e4b0ec79466e48c9'	-- Convention 
'530e33ccbcbc57f1066bbff7'	-- Country 
'5345731ebcbc57f1066c39b2'	-- County 
'63be6904847c3692a84b9bb7'	-- Entertainment Event 
'4d4b7105d754a06373d81259'	-- Event 
'5267e4d9e4b0ec79466e48c7'	-- Festival 
'4bf58dd8d48988d132951735'	-- Hotel Pool 
'52f2ab2ebcbc57f1066b8b4c'	-- Intersection 
'50aaa4314b90af0d42d5de10'	-- Island 
'58daa1558bbb0b01f18ec1fa'	-- Line 
'63be6904847c3692a84b9bb8'	-- Marketplace 
'4f2a23984b9023bd5841ed2c'	-- Moving Target 
'5267e4d9e4b0ec79466e48d1'	-- Music Festival 
'4f2a25ac4b909258e854f55f'	-- Neighborhood 
'5267e4d9e4b0ec79466e48c8'	-- Other Event 
'52741d85e4b0d5d1e3c6a6d9'	-- Parade 
'4bf58dd8d48988d1f7931735'	-- Plane 
'4f4531504b9074f6e4fb0102'	-- Platform 
'4cae28ecbf23941eb1190695'	-- Polling Place 
'4bf58dd8d48988d1f9931735'	-- Road 
'5bae9231bedf3950379f89c5'	-- Sporting Event 
'530e33ccbcbc57f1066bbff8'	-- State 
'530e33ccbcbc57f1066bbfe4'	-- States and Municipalities 
'52f2ab2ebcbc57f1066b8b54'	-- Stoop Sale 
'5267e4d8e4b0ec79466e48c5'	-- Street Fair 
'53e0feef498e5aac066fd8a9'	-- Street Food Gathering 
'4bf58dd8d48988d130951735'	-- Taxi 
'530e33ccbcbc57f1066bbff3'	-- Town 
'5bae9231bedf3950379f89c3'	-- Trade Fair 
'4bf58dd8d48988d12a951735'	-- Train 
'52e81612bcbc57f1066b7a24'	-- Tree 
'530e33ccbcbc57f1066bbff9'	-- Village
)) = false
```

### Find Open and Recently Active POI
**Presto/Athena**
```sql Presto/Athena
SELECT * FROM places p 
WHERE p.date_closed IS NULL
    AND DATE(p.date_refreshed) >= DATE_ADD('day', -365, current_date);
```
**SparkSQL**
```sql SparkSQL
SELECT * FROM places p
WHERE p.date_closed IS NULL
    AND p.date_refreshed >= DATE_SUB(current_date(), 365);
```

## Appendix

### Non-Commercial Categories Table

| Category Name             | Category ID              |
| :------------------------ | :----------------------- |
| Airport Gate              | 4bf58dd8d48988d1f0931735 |
| Beer Festival             | 62d587aeda6648532de2b88c |
| Bus Line                  | 4bf58dd8d48988d12b951735 |
| Christmas Market          | 52f2ab2ebcbc57f1066b8b3b |
| City                      | 50aa9e094b90af0d42d5de0d |
| Conference                | 5267e4d9e4b0ec79466e48c6 |
| Convention                | 5267e4d9e4b0ec79466e48c9 |
| Country                   | 530e33ccbcbc57f1066bbff7 |
| County                    | 5345731ebcbc57f1066c39b2 |
| Entertainment Event       | 63be6904847c3692a84b9bb7 |
| Event                     | 4d4b7105d754a06373d81259 |
| Festival                  | 5267e4d9e4b0ec79466e48c7 |
| Hotel Pool                | 4bf58dd8d48988d132951735 |
| Intersection              | 52f2ab2ebcbc57f1066b8b4c |
| Island                    | 50aaa4314b90af0d42d5de10 |
| Line                      | 58daa1558bbb0b01f18ec1fa |
| Marketplace               | 63be6904847c3692a84b9bb8 |
| Moving Target             | 4f2a23984b9023bd5841ed2c |
| Music Festival            | 5267e4d9e4b0ec79466e48d1 |
| Neighborhood              | 4f2a25ac4b909258e854f55f |
| Other Event               | 5267e4d9e4b0ec79466e48c8 |
| Parade                    | 52741d85e4b0d5d1e3c6a6d9 |
| Plane                     | 4bf58dd8d48988d1f7931735 |
| Platform                  | 4f4531504b9074f6e4fb0102 |
| Polling Place             | 4cae28ecbf23941eb1190695 |
| Road                      | 4bf58dd8d48988d1f9931735 |
| State                     | 530e33ccbcbc57f1066bbff8 |
| States and Municipalities | 530e33ccbcbc57f1066bbfe4 |
| Stopp Sale                | 52f2ab2ebcbc57f1066b8b54 |
| Street Fair               | 5267e4d8e4b0ec79466e48c5 |
| Street Food Gathering     | 53e0feef498e5aac066fd8a9 |
| Taxi                      | 4bf58dd8d48988d130951735 |
| Town                      | 530e33ccbcbc57f1066bbff3 |
| Trade Fair                | 5bae9231bedf3950379f89c3 |
| Train                     | 4bf58dd8d48988d12a951735 |
| Tree                      | 52e81612bcbc57f1066b7a24 |
| Village                   | 530e33ccbcbc57f1066bbff9 |