ClickHouse / ClickHouse/ClickHouse

Add function to check if an IPv4/6 is in a list of subnets

Open
#6,808 4 comments 3 reactions 0 assignees View on GitHub
comp-regular-function external feature help wanted
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.