This section provides reference information for the IP address-related functions in PlaidCloud Lakehouse.
This is the multi-page printable view of this section. Click here to print.
IP Address Functions
- 1: INET_ATON
- 2: INET_NTOA
- 3: IPV4_NUM_TO_STRING
- 4: IPV4_STRING_TO_NUM
- 5: TRY_INET_ATON
- 6: TRY_INET_NTOA
- 7: TRY_IPV4_NUM_TO_STRING
- 8: TRY_IPV4_STRING_TO_NUM
1 - INET_ATON
Converts an IPv4 address to a 32-bit integer.
Analyze Syntax
func.inet_aton(<ip>)
Analyze Examples
func.inet_aton('1.2.3.4')
┌───────────────────────────────┐
│ func.inet_aton('1.2.3.4') │
├───────────────────────────────┤
│ 16909060 │
└───────────────────────────────┘
SQL Syntax
INET_ATON(<ip>)
Aliases
Return Type
Integer.
SQL Examples
SELECT IPV4_STRING_TO_NUM('1.2.3.4'), INET_ATON('1.2.3.4');
┌──────────────────────────────────────────────────────┐
│ ipv4_string_to_num('1.2.3.4') │ inet_aton('1.2.3.4') │
├───────────────────────────────┼──────────────────────┤
│ 16909060 │ 16909060 │
└──────────────────────────────────────────────────────┘
2 - INET_NTOA
Converts a 32-bit integer to an IPv4 address.
Analyze Syntax
func.inet_ntoa(<int32>)
Analyze Examples
SELECT func.inet_ntoa(16909060)
┌──────────────────────────────┐
│ func.inet_ntoa(16909060) │
├──────────────────────────────┤
│ 1.2.3.4 │
└──────────────────────────────┘
SQL Syntax
INET_NOTA( <int32> )
Aliases
Return Type
String.
SQL Examples
SELECT IPV4_NUM_TO_STRING(16909060), INET_NTOA(16909060);
┌────────────────────────────────────────────────────┐
│ ipv4_num_to_string(16909060) │ inet_ntoa(16909060) │
├──────────────────────────────┼─────────────────────┤
│ 1.2.3.4 │ 1.2.3.4 │
└────────────────────────────────────────────────────┘
3 - IPV4_NUM_TO_STRING
Alias for INET_NTOA.
4 - IPV4_STRING_TO_NUM
Alias for INET_ATON.
5 - TRY_INET_ATON
try_inet_aton function is used to take the dotted-quad representation of an IPv4 address as a string and returns the numeric value of the given IP address in form of an integer.
Analyze Syntax
func.try_inet_aton(<str>)
Analyze Examples
func.try_inet_aton('10.0.5.9')
┌────────────────────────────────┐
│ func.try_inet_aton('10.0.5.9') │
├────────────────────────────────┤
│ 167773449 │
└────────────────────────────────┘
SQL Syntax
TRY_INET_ATON( <str> )
Aliases
Return Type
Integer.
SQL Examples
SELECT TRY_INET_ATON('10.0.5.9'), TRY_IPV4_STRING_TO_NUM('10.0.5.9');
┌────────────────────────────────────────────────────────────────┐
│ try_inet_aton('10.0.5.9') │ try_ipv4_string_to_num('10.0.5.9') │
│ UInt32 │ UInt32 │
├───────────────────────────┼────────────────────────────────────┤
│ 167773449 │ 167773449 │
└────────────────────────────────────────────────────────────────┘
6 - TRY_INET_NTOA
Takes an IPv4 address in network byte order and then returns the address as a dotted-quad string representation.
Analyze Syntax
func.try_inet_ntoa(<integer>)
Analyze Examples
func.try_inet_ntoaA(167773449)
┌───────────────────────────────┐
│ func.try_inet_ntoa(167773449) │
├───────────────────────────────┤
│ 10.0.5.9 │
└───────────────────────────────┘
SQL Syntax
TRY_INET_NTOA( <integer> )
Aliases
Return Type
String.
SQL Examples
SELECT TRY_INET_NTOA(167773449), TRY_IPV4_NUM_TO_STRING(167773449);
┌──────────────────────────────────────────────────────────────┐
│ try_inet_ntoa(167773449) │ try_ipv4_num_to_string(167773449) │
├──────────────────────────┼───────────────────────────────────┤
│ 10.0.5.9 │ 10.0.5.9 │
└──────────────────────────────────────────────────────────────┘
7 - TRY_IPV4_NUM_TO_STRING
Alias for TRY_INET_NTOA.
8 - TRY_IPV4_STRING_TO_NUM
Alias for TRY_INET_ATON.