This query is to find geolocation of an IP address including latitude, longitude, city and country.
Legacy SQL doesn't support range conditions such as BETWEEN
when using JOIN
, so we need to filter data by WHERE
.
This means if IP address does not match any of the data inside geolite_city_bq_b2b
, records will not be able to receive.
Use Standard SQL if you want to receive records no matter you succeed to find geolocation or not.
Please refer to the following post for more detail.
https://cloudplatform.googleblog.com/2014/03/geoip-geolocation-with-google-bigquery.html
@mbyrne00
Thanks for your information!
Yeah, if you want to treat the record which doesn't match with geo data or just city name was lost as a same data, that nice idea :)
@quindici
Ah,
fh-bigquery.geocode.geolite_city_bq_b2b
may not be maintained any more...I know it's really hard to map geo location from ip address, so I think we should use this query just for reference level data, not the exact place.