0

I need to parse IPs from the 1st table i have (domain) and match it to a range of integer representation and match the IP from domain to the country in IP_location on BigQuery

SELECT domain.IP, IP_location.Country
FROM   [webs.domain]
JOIN   [webs.IP_location]
       ON PARSE_IP(rdns.IP) >= IP_location.integer_start 
       AND PARSE_IP(rdns.IP) <= IP_location.integer_end;

When i used this query, i got an error

Error: ON clause must be AND of = comparisons of one field name from each table, with all field names prefixed with table name.

Jeugasce
  • 197
  • 1
  • 3
  • 11
  • 1
    Check this out... http://stackoverflow.com/questions/19618105/geoip-calculation-in-bigquery-performance. – N.N. Jan 28 '14 at 09:09

1 Answers1

0

In general, the way to do a join on an inequality as you've described is to do a CROSS JOIN with a WHERE clause.

SELECT domain.IP, location.Country
FROM   [webs.domain] domain
CROSS JOIN [webs.IP_location] location
WHERE PARSE_IP(domain.IP) >= location.integer_start 
  AND PARSE_IP(domain.IP) <= location.integer_end;

Note you might want use CROSS JOIN EACH if this query runs out of resources. Also, I tweaked your query slightly, since the PARSE_IP call was using rdns.IP, I assumed you meant domain.IP.

Jordan Tigani
  • 26,089
  • 4
  • 60
  • 63