My primary goal is to filter out a range of IP addresses in IPv4 format by converting them to integers. So, for example, I'd like to filter an IP range from 192.168.1.1 to 192.168.1.100, but I first need to convert them to integers: 3232235777 to 3232235876.
Is there a way to do this in BigQuery (standard SQL)? I've looked at the BigQuery documentation but my combination of the NET.IP_FROM_STRING()
and NET.IPV4_TO_INT64()
functions keeps throwing this error: No matching signature for function NET.IPV4_TO_INT64 for argument types: STRING.
SELECT addr_str, ip_from_string, FORMAT("0x%X",
NET.IPV4_TO_INT64(ip_from_string)) AS ipv4_to_int64
FROM
(
SELECT addr_str, FORMAT("%T", NET.IP_FROM_STRING(addr_str)) AS ip_from_string
FROM UNNEST(['192.168.1.1','192.168.1.100']) AS addr_str
)