TO_IP
snowflake UDF converts the integer equivalent value of an IPv4 address to its IPv4 string format.
Often time it is easy to run IP address operations through their integer or hexadecimal equivalent values. However, after running those operations, to publish a report or to ingest the data into other systems, you need to convert them back to their IP address format. The TO_IP
UDF takes in the integer value of IPv4 addresses and converts it back to their IP format.
One IPv4 IP address integer value
Input IP address:
469720341
Code:
SELECT ipinfo.public.to_ip('469720341') as IPv4
Output:
Multiple IPv4 IP Addresses integer value
Input IP address:
2239136096
241969668
2956524755
1996262039
2157726077
80431965
401579153
1153651306
1288949318
268842728
Code:
SELECT ipinfo.public.to_ip(ip) as IPv4
FROM logs
Output:
Relevant Docs
- Snowflake UDF: TO_IP6 - Convert IPv6 Hex Value to its IPv6 string equivalent
- Snowflake UDF: TO_INT - Convert IPv4 to its integer and IPv6 to its hexadecimal equivalent