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 network portion of an IPv4 or IPv6 CIDR block in its canonical form.
This function is an alias for ip_network function.
Syntax
ip_network_first ( cidr )
Arguments
cidr: ASTRINGorBINARYvalue representing a valid IPv4 or IPv6 CIDR block.
Returns
The same type as the input (STRING or BINARY), representing the canonical form of the network address.
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_network_first('192.168.1.100/24');
192.168.1.0
> SELECT ip_network_first('10.32.1.5/16');
10.32.0.0
> SELECT ip_network_first('2001:db8::1/32');
2001:db8::
> SELECT ip_network_first('::ffff:192.0.2.128/120');
::ffff:192.0.2.0
> SELECT hex(ip_network_first(X'C0A8016418'));
C0A80100
> SELECT ip_network_first(NULL);
NULL
> SELECT ip_network_first('192.168.1.5');
Error: INVALID_CIDR_BLOCK