Akanksha-kedia opened a new pull request, #18828: URL: https://github.com/apache/pinot/pull/18828
## Summary Adds `isPrivateIp(ip)` scalar function to `IpAddressFunctions`, completing the IP address function suite. ### What it does Returns `true` if the IP address belongs to any private or reserved range: | Range | Description | |---|---| | `10.0.0.0/8` | RFC 1918 private | | `172.16.0.0/12` | RFC 1918 private | | `192.168.0.0/16` | RFC 1918 private | | `127.0.0.0/8` | IPv4 loopback | | `169.254.0.0/16` | IPv4 link-local | | `::1` | IPv6 loopback | | `fe80::/10` | IPv6 link-local | | `fc00::/7` | IPv6 ULA (covers `fd00::/8`) | ### SQL usage ```sql -- Filter out internal traffic SELECT * FROM access_logs WHERE isPrivateIp(client_ip) = false -- Classify traffic origin SELECT client_ip, isPrivateIp(client_ip) AS is_internal, ipFamily(client_ip) AS ip_version FROM network_events -- Both camelCase and snake_case are registered SELECT is_private_ip(src_ip) FROM firewall_logs ``` ### Implementation notes - Registered under both `isPrivateIp` and `is_private_ip` for SQL compatibility - Uses `isLoopback()` / `isLinkLocal()` from the `inet.ipaddr` library for loopback and link-local ranges; hardcoded CIDR constants for RFC 1918 and IPv6 ULA - Constants are initialised once at class load (static block); no per-call allocation - Rejects CIDR notation (e.g., `10.0.0.0/8`) with a clear `IllegalArgumentException` - No new dependencies — uses existing `com.github.seancfoley:ipaddress` ## Tests 8 new test methods covering: - Each RFC 1918 range and its boundaries (`172.32.0.1` correctly returns `false`) - IPv4/IPv6 loopback - IPv4/IPv6 link-local - IPv6 ULA (`fc00::/7` — both `fc` and `fd` prefixes) - Public addresses that must return `false` (8.8.8.8, 1.1.1.1, 2001:db8::1) - Invalid inputs: CIDR notation, malformed strings `mvn test -pl pinot-common -Dtest=IpAddressFunctionsTest` — **45 tests, 0 failures** -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
