ClickHouse / ClickHouse/ClickHouse
Add function to check if an IPv4/6 is in a list of subnets
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 21h 32m
- Merged PRs (30d)
- 515
Description
**Use case**
Using ip_trie, I can check if an IP is in any X subnets
I have no easy way to do a quick CLI query to match ~ 5 subnets without creating a dict
**Describe the solution you'd like**
Something like
`IPmatchNet(ip, [subnet1, subnet2])`
ip being `IPv4` or `IPv6` or `UInt32` or `FixedString(16)`
subnet1 is an IPv6 or IPv4 subnet as string (`192.168.0.0/21`), same as what is accepted by ip_trie
`IPmatchNet` should return the matched subnet so we can use it in `GROUP BY`
Also `IPmatchNet` should handle IPv4 mapped IPv6 (#6806)
**Additional context**
I'm bad at naming, IPmatchNet is just an exemple
Right now `cutIPv6` cuts bytes and not bits, so I can only use it for /24 /16 /8 (for IPv4)
Contributor guide
Assessment
This issue has not been assessed yet.