Last active
February 4, 2019 14:21
-
-
Save JoaoCarabetta/aa4972267a8010364c955c6e64e07eb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE waze.polygons_geo | |
WITH ( | |
external_location = 's3://...', | |
format = 'Parquet') AS | |
WITH dataset AS ( | |
SELECT | |
polygons | |
FROM waze.polygons) | |
SELECT | |
pol.polygon, | |
pol.polygon_slug, | |
pol.url_base, | |
ST_Polygon(concat( | |
'polygon ((', | |
array_join( | |
transform( | |
split(pol.polygon, ';'), | |
l -> replace(l, ',', ' ') | |
),','),'))')) as polygon_geo | |
FROM dataset | |
CROSS JOIN UNNEST(polygons) as t(pol) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
* | |
FROM test.main | |
WHERE polygon_slug IN ( | |
SELECT polygon_slug | |
FROM (SELECT | |
polygon_slug, | |
st_intersects(polygon_geo, | |
st_polygon('polygon ((-96.984 19.583, -96.974 19.498, 96.875 19.589))')) as inte | |
FROM polygons) WHERE inte = true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment