メインコンテンツまでスキップ

IP functions

Applies to: check marked yes Databricks Runtime 18.2 and above

Beta

This feature is in Beta. Workspace admins can control access to this feature from the Previews page. See Manage Databricks previews.

IP functions operate on IPv4 and IPv6 addresses and CIDR blocks represented as STRING or BINARY values.

Import Databricks functions to get IP functions (Databricks Runtime)

To import IP functions for Python or Scala in notebooks, use the following commands:

Python
from pyspark.databricks.sql import functions as dbf

List of IP functions

Function

Description

ip_as_binary(ip_or_cidr)

Returns the canonical binary representation of an IP address or CIDR block.

ip_as_string(ip_or_cidr)

Returns the canonical string representation of an IP address or CIDR block.

ip_cidr(cidr)

Returns the canonical representation of an IPv4 or IPv6 CIDR block.

ip_cidr_contains(cidr, needle)

Returns TRUE if an IP address or CIDR block is contained within another CIDR block.

ip_host(ip)

Returns the canonical representation of an IPv4 or IPv6 address.

ip_network(cidr)

Returns the network portion of a CIDR block in its canonical form.

ip_network_first(cidr)

Alias for ip_network.

ip_network_last(cidr)

Returns the last address of a CIDR block in its canonical form.

ip_prefix_length(cidr)

Returns the prefix length of a CIDR block.

ip_version(ip_or_cidr)

Returns the IP version (4 or 6) from an IP address or CIDR block.

try_ip_as_binary(ip_or_cidr)

Returns the canonical binary representation of an IP address or CIDR block, or NULL if invalid.

try_ip_as_string(ip_or_cidr)

Returns the canonical string representation of an IP address or CIDR block, or NULL if invalid.

try_ip_cidr(cidr)

Returns the canonical representation of an IPv4 or IPv6 CIDR block, or NULL if invalid.

try_ip_host(ip)

Returns the canonical representation of an IPv4 or IPv6 address, or NULL if invalid.