Skip to content

Instantly share code, notes, and snippets.

View mbyrne00's full-sized avatar

Matt Byrne mbyrne00

View GitHub Profile
@matsukaz
matsukaz / 01.README.md
Last active September 27, 2021 11:07
Find a geolocation of an IP address in BigQuery

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