Skip to main content

IS_IPV4_STRING

Description​

Determine whether an IPv4-type address is a valid IPv4 address.

Syntax​

IS_IPV4_STRING(<ipv4_str>)

Parameters​

ParameterDescription
<ipv4_str>An IPv4 address of type String

Return Value​

If it is a correctly formatted and valid IPv4 address, return true; On the contrary, return false.

  • If input is NULL, the function returns NULL.

Example​

CREATE TABLE `test_is_ipv4_string` (
`id` int,
`ip_v4` string
) ENGINE=OLAP
DISTRIBUTED BY HASH(`id`) BUCKETS 4
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);

insert into test_is_ipv4_string values(0, NULL), (1, '0.0.0.'), (2, ''), (3, '.'), (4, '255.255.255.255');

select id, ip_v4, is_ipv4_string(ip_v4) from test_is_ipv4_string order by id;
+------+-----------------+-----------------------+
| id | ip_v4 | is_ipv4_string(ip_v4) |
+------+-----------------+-----------------------+
| 0 | NULL | NULL |
| 1 | 0.0.0. | 0 |
| 2 | | 0 |
| 3 | . | 0 |
| 4 | 255.255.255.255 | 1 |
+------+-----------------+-----------------------+