Skip to content

Cherry-pick IP UDF changes from main (#618 #981) #2465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
19 changes: 19 additions & 0 deletions ydb/docs/en/core/yql/reference/yql-core/udf/list/ip.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ The `Ip` module supports both the IPv4 and IPv6 addresses. By default, they are
**List of functions**

* ```Ip::FromString(String{Flags:AutoMap}) -> String?``` - From a human-readable representation to a binary representation.
* ```Ip::SubnetFromString(String{Flags:AutoMap}) -> String?``` - From a human-readable representation of subnet to a binary representation.
* ```Ip::ToString(String{Flags:AutoMap}) -> String?``` - From a binary representation to a human-readable representation.
* ```Ip::SubnetToString(String{Flags:AutoMap}) -> String?``` - From a binary representation of subnet to a human-readable representation.
* ```Ip::IsIPv4(String?) -> Bool```
* ```Ip::IsIPv6(String?) -> Bool```
* ```Ip::IsEmbeddedIPv4(String?) -> Bool```
* ```Ip::ConvertToIPv6(String{Flags:AutoMap}) -> String```: IPv6 remains unchanged, and IPv4 becomes embedded in IPv6
* ```Ip::GetSubnet(String{Flags:AutoMap}, [Uint8?]) -> String```: The second argument is the subnet size, by default it's 24 for IPv4 and 64 for IPv6
* ```Ip::GetSubnetByMask(String{Flags:AutoMap}, String{Flags:AutoMap}) -> String```: The first argument is the base address, the second argument is the bit mask of a desired subnet.
* ```Ip::SubnetMatch(String{Flags:AutoMap}, String{Flags:AutoMap}) -> Bool```: The first argument is a subnet, the second argument is a subnet or an address.


**Examples**

Expand All @@ -25,5 +30,19 @@ SELECT
Ip::FromString("213.180.193.3")
)
); -- "213.180.193.0"

SELECT
Ip::SubnetMatch(
Ip::SubnetFromString("192.168.0.1/16"),
Ip::FromString("192.168.1.14"),
); -- true

SELECT
Ip::ToString(
Ip::GetSubnetByMask(
Ip::FromString("192.168.0.1"),
Ip::FromString("255.255.0.0")
)
); -- "192.168.0.0"
```

18 changes: 18 additions & 0 deletions ydb/docs/ru/core/yql/reference/yql-core/udf/list/ip.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
**Список функций**

* ```Ip::FromString(String{Flags:AutoMap}) -> String?``` - из человекочитаемого представления в бинарное
* ```Ip::SubnetFromString(String{Flags:AutoMap}) -> String?``` - из человекочитаемого представления подсети в бинарное
* ```Ip::ToString(String{Flags:AutoMap}) -> String?``` - из бинарного представления в человекочитаемое
* ```Ip::SubnetToString(String{Flags:AutoMap}) -> String?``` - из бинарного представления подсети в человекочитаемое
* ```Ip::IsIPv4(String?) -> Bool```
* ```Ip::IsIPv6(String?) -> Bool```
* ```Ip::IsEmbeddedIPv4(String?) -> Bool```
* ```Ip::ConvertToIPv6(String{Flags:AutoMap}) -> String``` - IPv6 остается без изменений, а IPv4 становится embedded в IPv6
* ```Ip::GetSubnet(String{Flags:AutoMap}, [Uint8?]) -> String``` - во втором аргументе размер подсети, по умолчанию 24 для IPv4 и 64 для IPv6
* ```Ip::GetSubnetByMask(String{Flags:AutoMap}, String{Flags:AutoMap}) -> String``` - во втором аргументе битовая маска подсети
* ```Ip::SubnetMatch(String{Flags:AutoMap}, String{Flags:AutoMap}) -> Bool``` - в первом аргументе подсеть, во втором аргументе подсеть или адрес

**Примеры**

Expand All @@ -24,4 +28,18 @@ SELECT
Ip::FromString("213.180.193.3")
)
); -- "213.180.193.0"

SELECT
Ip::SubnetMatch(
Ip::SubnetFromString("192.168.0.1/16"),
Ip::FromString("192.168.1.14"),
); -- true

SELECT
Ip::ToString(
Ip::GetSubnetByMask(
Ip::FromString("192.168.0.1"),
Ip::FromString("255.255.0.0")
)
); -- "192.168.0.0"
```
Loading