הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Applies to:
Databricks Runtime 18.2 and above
Important
This feature is in Beta. Workspace admins can control access to this feature from the Previews page. See Manage Azure Databricks previews.
Returns the canonical binary representation of an IP address or CIDR block.
Syntax
ip_as_binary ( ip_or_cidr )
Arguments
ip_or_cidr: ASTRINGorBINARYvalue representing an IPv4 or IPv6 address or CIDR block.
Returns
A BINARY representing the canonical binary form of the IP address or CIDR block. IPv4 addresses are represented as 4 bytes, IPv6 addresses as 16 bytes, and CIDR blocks include an additional byte for the prefix length.
The function returns NULL if the input is NULL.
Error conditions
- If the input is not a valid IP address or CIDR block, the function returns INVALID_IP_ADDRESS_OR_CIDR_BLOCK.
Examples
> SELECT hex(ip_as_binary('192.168.1.1'));
C0A80101
> SELECT hex(ip_as_binary('2001:db8::1'));
20010DB8000000000000000000000001
> SELECT hex(ip_as_binary('192.168.1.5/24'));
C0A8010018
> SELECT hex(ip_as_binary(X'C0A80101'));
C0A80101
> SELECT ip_as_binary(NULL);
NULL
> SELECT ip_as_binary('invalid.ip');
Error: INVALID_IP_ADDRESS_OR_CIDR_BLOCK