Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
}
---

### Description
## Description

Use CRC32 to compute the result.

### Syntax
## Syntax
```sql
CRC32( <str> )
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Description

Computes a singed 64-bit MurmurHash3 hash value. The unsigned version refer to [murmur_hash3_u64_v2](./murmur-hash3-u64-v2.md)
Computes a signed 64-bit MurmurHash3 hash value. The unsigned version refer to [murmur_hash3_u64_v2](./murmur-hash3-u64-v2.md)

The difference from `MURMUR_HASH3_64` is: this version reuses the 128-bit processing function of MurmurHash3, outputting only the first 64-bit hash value, which is consistent with the [standard library](https://mmh3.readthedocs.io/en/latest/api.html#mmh3.hash64) implementation.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Calculate 64-bit murmur3 hash value

The difference from `MURMUR_HASH3_64_V2` is: This version is specifically optimized for 64-bit output, with slightly better performance than the v2 version, but is inconsistent with the [standard library](https://mmh3.readthedocs.io/en/latest/api.html#mmh3.hash64) implementation.

-Note: After testing, the performance of `xxhash_64` is about twice that of `murmur_hash3_64`, so when calculating hash values, it is recommended to use `xxhash_64` instead of `murmur_hash3_64`.
- Note: After testing, the performance of `xxhash_64` is about twice that of `murmur_hash3_64`, so when calculating hash values, it is recommended to use `xxhash_64` instead of `murmur_hash3_64`.


## Syntax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Description

Computes an unsigned 64-bit MurmurHash3 hash value, returned as LARGEINT type. The unsigned version refer to [murmur_hash3_64_v2](./murmur-hash3-64-v2.md)
Computes an unsigned 64-bit MurmurHash3 hash value, returned as LARGEINT type. The signed version refer to [murmur_hash3_64_v2](./murmur-hash3-64-v2.md)

This function reuses the implementation of `MURMUR_HASH3_64_V2` and masks the result to unsigned 64-bit range (0 to 2^64-1), which is consistent with the [standard library](https://mmh3.readthedocs.io/en/latest/api.html#mmh3.hash64) implementation when interpreted as unsigned.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

Calculate the 32-bit xxhash value of the input string or binary.

-Note: When calculating hash values, it is recommended to use `xxhash_32` instead of `murmur_hash3_32`.

## Syntax

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Calculates the 64-bit xxhash value of the input string or binary.

-Note: After testing, the performance of `xxhash_64` is about twice that of `murmur_hash3_64`, so when calculating hash values, it is recommended to use `xxhash_64` instead of `murmur_hash3_64`.
- Note: After testing, the performance of `xxhash_64` is about twice that of `murmur_hash3_64`, so when calculating hash values, it is recommended to use `xxhash_64` instead of `murmur_hash3_64`.

## Syntax

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## cut_ipv6

## Description
Cuts a specified number of bytes from the end of an IPv6 address based on its type (IPv4-mapped or pure IPv6), and returns the truncated IPv6 address string.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## ipv4_cidr_to_range

## Description
Calculates the minimum and maximum IPv4 addresses for a network segment based on an IPv4 address and CIDR prefix length, returning a struct containing two IPv4 addresses.

Expand Down Expand Up @@ -38,33 +36,33 @@ Return Value Meaning:
Calculate address range for /24 network segment.
```sql
SELECT ipv4_cidr_to_range(INET_ATON('192.168.1.1'), 24) as range;
+----------------------------------------+
| range |
+----------------------------------------+
+------------------------------------------------+
| range |
+------------------------------------------------+
| {"min": "192.168.1.0", "max": "192.168.1.255"} |
+----------------------------------------+
+------------------------------------------------+
```

Calculate address range for /16 network segment.
```sql
SELECT ipv4_cidr_to_range(INET_ATON('10.0.0.1'), 16) as range;
+----------------------------------------+
| range |
+----------------------------------------+
+----------------------------------------------+
| range |
+----------------------------------------------+
| {"min": "10.0.0.0", "max": "10.255.255.255"} |
+----------------------------------------+
+----------------------------------------------+
```

Access specific fields in the struct.
```sql
SELECT
ipv4_cidr_to_range(INET_ATON('172.16.1.1'), 24).min as min_ip,
ipv4_cidr_to_range(INET_ATON('172.16.1.1'), 24).max as max_ip;
+-------------+-------------+
| min_ip | max_ip |
+-------------+-------------+
| 172.16.1.0 | 172.16.1.255 |
+-------------+-------------+
+------------+--------------+
| min_ip | max_ip |
+------------+--------------+
| 172.16.1.0 | 172.16.1.255 |
+------------+--------------+
```

CIDR prefix out of range throws an exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## ipv4_string_to_num_or_default

## Description
Takes a string containing an IPv4 address in A.B.C.D format (dot-separated decimal numbers). Returns a BIGINT representing the numeric value of the corresponding IPv4 address in network byte order (big endian).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## ipv4_string_to_num

## Description
Takes a string containing an IPv4 address in A.B.C.D format (dot-separated decimal numbers). Returns the numeric value of the corresponding IPv4 address in network byte order (big endian).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## ipv4_to_ipv6

## Description
Converts an IPv4 address to an IPv6 address. The converted IPv6 address is an IPv4-mapped address in the format `::ffff:IPv4`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## ipv6_cidr_to_range

## Description
Calculates the minimum and maximum IPv6 addresses for a network segment based on an IPv6 address and CIDR prefix length, returning a struct containing two IPv6 addresses.

Expand Down Expand Up @@ -39,33 +37,33 @@ Return Value Meaning:
Calculate address range for /64 network segment.
```sql
SELECT ipv6_cidr_to_range(INET6_ATON('2001:db8::1'), 64) as range;
+----------------------------------------+
| range |
+----------------------------------------+
+---------------------------------------------------------------+
| range |
+---------------------------------------------------------------+
| {"min": "2001:db8::", "max": "2001:db8::ffff:ffff:ffff:ffff"} |
+----------------------------------------+
+---------------------------------------------------------------+
```

Calculate address range for /48 network segment.
```sql
SELECT ipv6_cidr_to_range(INET6_ATON('2001:db8:1::1'), 48) as range;
+----------------------------------------+
| range |
+----------------------------------------+
| {"min": "2001:db8:1::", "max": "2001:db8:1:ffff:ffff:ffff:ffff"} |
+----------------------------------------+
+---------------------------------------------------------------------+
| range |
+---------------------------------------------------------------------+
| {"min": "2001:db8:1::", "max": "2001:db8:1:ffff:ffff:ffff:ffff:ffff"} |
+---------------------------------------------------------------------+
```

Access specific fields in the struct.
```sql
SELECT
ipv6_cidr_to_range(INET6_ATON('2001:db8::1'), 64).min as min_ip,
ipv6_cidr_to_range(INET6_ATON('2001:db8::1'), 64).max as max_ip;
+-------------+----------------------------------+
| min_ip | max_ip |
+-------------+----------------------------------+
| 2001:db8:: | 2001:db8::ffff:ffff:ffff:ffff |
+-------------+----------------------------------+
+------------+-------------------------------+
| min_ip | max_ip |
+------------+-------------------------------+
| 2001:db8:: | 2001:db8::ffff:ffff:ffff:ffff |
+------------+-------------------------------+
```

CIDR prefix out of range throws an exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

## Description
Takes an IPv6 address in binary format of type String. Returns the string of this address in text format.
- The IPv4 address mapped by IPv6 starts with ::ffff:111.222.33.
- The IPv4 address mapped by IPv6 starts with ::ffff:111.222.33.44.

## Alias
- INET6_NTOA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
{
"title": "IPV6_STRING_TO_NUM_OR_DEFAULT",
"language": "en",
"description": "The reverse function of IPv6NumToString, it accepts an IP address string and returns the IPv6 address in binary format."
"description": "The reverse function of IPV6_NUM_TO_STRING, it accepts an IP address string and returns the IPv6 address in binary format."
}
---

## ipv6_string_to_num_or_default

## Description
The reverse function of IPv6NumToString, it accepts an IP address string and returns the IPv6 address in binary format.
The reverse function of IPV6_NUM_TO_STRING, it accepts an IP address string and returns the IPv6 address in binary format.

## Syntax
```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
{
"title": "IPV6_STRING_TO_NUM_OR_NULL | Ip Functions",
"language": "en",
"description": "The reverse function of IPv6NumToString, it takes an IP address String and returns an IPv6 address in binary format.",
"description": "The reverse function of IPV6_NUM_TO_STRING, it takes an IP address String and returns an IPv6 address in binary format.",
"sidebar_label": "IPV6_STRING_TO_NUM_OR_NULL"
}
---

# IPV6_STRING_TO_NUM_OR_NULL

## Description
The reverse function of IPv6NumToString, it takes an IP address String and returns an IPv6 address in binary format.
The reverse function of IPV6_NUM_TO_STRING, it takes an IP address String and returns an IPv6 address in binary format.

## Alias
- INET6_ATON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
{
"title": "IPV6_STRING_TO_NUM",
"language": "en",
"description": "The reverse function of IPv6NumToString, it accepts an IP address string and returns the IPv6 address in binary format."
"description": "The reverse function of IPV6_NUM_TO_STRING, it accepts an IP address string and returns the IPv6 address in binary format."
}
---

## ipv6_string_to_num

## Description
The reverse function of IPv6NumToString, it accepts an IP address string and returns the IPv6 address in binary format.
The reverse function of IPV6_NUM_TO_STRING, it accepts an IP address string and returns the IPv6 address in binary format.

## Syntax
```sql
Expand All @@ -24,8 +22,7 @@ Return Type: VARCHAR (16-byte binary)

Return Value Meaning:
- Returns the 16-byte binary encoding of IPv6
- Throws an exception when input is NULL
- Throws an exception for invalid IP addresses or `NULL` input
- Throws an exception when the input is NULL or an invalid IP address
- If input is valid IPv4 text, returns equivalent IPv6 address (`::ffff:<ipv4>`)

### Usage Notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## is_ip_address_in_range

## Description
Checks if a specified IP address is within a given CIDR network range. Supports both IPv4 and IPv6 addresses.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## is_ipv4_compat

## Description
Checks if an IPv6 address is an IPv4-compatible address. IPv4-compatible addresses are a special IPv6 address format used to represent IPv4 addresses in IPv6 networks.

Expand All @@ -28,7 +26,7 @@ Return Value Meaning: 1 indicates it is an IPv4-compatible address, 0 indicates
- IPv4-compatible address format is `::IPv4`, where the first 12 bytes are 0 and the last 4 bytes contain the IPv4 address
- Input must be 16-byte IPv6 binary data
- This format is defined in RFC 4291 for IPv6 transition period
- The last 4 bytes cannot be 0, so `::0.0.0.0` is not a valid IPv4-compatible address, as 0.0.0.0 is not an IPv4 unicast address and does not satisfy the RFC 4291 IPv4-Mapped IPv6 Address definition
- The last 4 bytes cannot be 0, so `::0.0.0.0` is not a valid IPv4-compatible address, as 0.0.0.0 is not an IPv4 unicast address and does not satisfy the RFC 4291 IPv4-Compatible IPv6 Address definition
- Returns NULL when input parameter is NULL

## Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## is_ipv4_mapped

## Description
Checks if an IPv6 address is an IPv4-mapped address. IPv4-mapped addresses are a special IPv6 address format used to represent IPv4 addresses in IPv6 networks.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## is_ipv4_string

## Description
Checks if the input string is a valid IPv4 address format. Returns 1 if it is a valid IPv4 address, returns 0 if it is not.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## is_ipv6_string

## Description
Checks if the input string is a valid IPv6 address format. Returns 1 if it is a valid IPv6 address, returns 0 if it is not.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## to_ipv4_or_default

## Description
Takes the string form of an IPv4 address and returns a value of IPv4 type. For invalid input or NULL input, returns the default value `0.0.0.0`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## to_ipv4_or_null

## Description
Takes the string form of an IPv4 address and returns a value of IPv4 type. For invalid input or NULL input, returns NULL.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## to_ipv4

## Description
Takes the string form of an IPv4 address and returns a value of IPv4 type.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## to_ipv6_or_default

## Description
Takes the string form of an IPv6 address and returns a value of IPv6 type. For invalid input or NULL input, returns the default value `::`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## to_ipv6_or_null

## Description
Takes the string form of an IPv6 address and returns a value of IPv6 type. For invalid input or NULL input, returns NULL.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
}
---

## to_ipv6

## Description
Takes the string form of an IPv6 address and returns a value of IPv6 type. The binary form of this value equals the binary form of the return value of the `ipv6_string_to_num` function.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ JSON_ARRAY_IGNORE_NULL([<expression>, ...])

## Usage Notes
- JSON_ARRAY_IGNORE_NULL implementation converts different types of parameters to JSON values by implicitly calling the [`TO_JSON`](./to-json.md) function, so parameters must be types supported by [`TO_JSON`](./to-json.md).
- NULL will be ingored. If you DO want to retain null values in the array, you can use the function [`JSON_ARRAY`](./json-array.md).
- NULL will be ignored. If you DO want to retain null values in the array, you can use the function [`JSON_ARRAY`](./json-array.md).
- If the parameter type is not supported by [`TO_JSON`](./to-json.md), you will get an error. You can first convert that parameter to String type, for example:
```sql
select JSON_ARRAY_IGNORE_NULL(CAST(NOW() as String));
Expand Down
Loading
Loading