Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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 prefix length of an IPv4 or IPv6 CIDR block.
Syntax
ip_prefix_length ( cidr )
Arguments
cidr: ASTRINGorBINARYvalue representing a valid IPv4 or IPv6 CIDR block.
Returns
An INTEGER representing the prefix length of the CIDR block.
The function returns NULL if the input is NULL.
Error conditions
- If the input is not a valid CIDR block, the function returns INVALID_CIDR_BLOCK.
Examples
> SELECT ip_prefix_length('192.168.1.1/24');
24
> SELECT ip_prefix_length('2001:db8::1/64');
64
> SELECT ip_prefix_length('::ffff:192.0.2.1/96');
96
> SELECT ip_prefix_length(X'C0A8010118');
24
> SELECT ip_prefix_length(NULL);
NULL
> SELECT ip_prefix_length('192.168.1.5');
Error: INVALID_CIDR_BLOCK