You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "Akanksha-kedia (via GitHub)" <gi...@apache.org> on 2026/06/22 14:23:03 UTC

[PR] Add isPrivateIp scalar function for classifying private/reserved IP addresses [pinot]

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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add isPrivateIp scalar function for classifying private/reserved IP addresses [pinot]

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 commented on PR #18828:
URL: https://github.com/apache/pinot/pull/18828#issuecomment-4781140335

   Docs PR opened for this change: https://github.com/pinot-contrib/pinot-docs/pull/887


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add isPrivateIp scalar function for classifying private/reserved IP addresses [pinot]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #18828:
URL: https://github.com/apache/pinot/pull/18828#issuecomment-4769881546

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/18828?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `88.23529%` with `2 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 56.96%. Comparing base ([`5526d5b`](https://app.codecov.io/gh/apache/pinot/commit/5526d5b86018bc8d22e10ece356d107dff5e280f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`0541622`](https://app.codecov.io/gh/apache/pinot/commit/05416227838ccc9aae5f552874b2afd0f3711ca1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 13 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/pinot/pull/18828?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...not/common/function/scalar/IpAddressFunctions.java](https://app.codecov.io/gh/apache/pinot/pull/18828?src=pr&el=tree&filepath=pinot-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fcommon%2Ffunction%2Fscalar%2FIpAddressFunctions.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL0lwQWRkcmVzc0Z1bmN0aW9ucy5qYXZh) | 88.23% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/18828?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (5526d5b) and HEAD (0541622). Click for more details.
   > 
   > <details><summary>HEAD has 16 uploads less than BASE</summary>
   >
   >| Flag | BASE (5526d5b) | HEAD (0541622) |
   >|------|------|------|
   >|java-21|5|1|
   >|unittests|2|1|
   >|temurin|5|1|
   >|unittests2|1|0|
   >|integration|3|0|
   >|integration1|1|0|
   >|integration2|1|0|
   >|custom-integration1|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #18828      +/-   ##
   ============================================
   - Coverage     64.82%   56.96%   -7.86%     
   + Complexity     1319        1    -1318     
   ============================================
     Files          3388     2603     -785     
     Lines        210228   152399   -57829     
     Branches      32948    24741    -8207     
   ============================================
   - Hits         136282    86816   -49466     
   + Misses        62978    58209    -4769     
   + Partials      10968     7374    -3594     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration1](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration2](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-21](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.96% <88.23%> (-7.86%)` | :arrow_down: |
   | [temurin](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.96% <88.23%> (-7.86%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.96% <88.23%> (-7.86%)` | :arrow_down: |
   | [unittests1](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.96% <88.23%> (-0.05%)` | :arrow_down: |
   | [unittests2](https://app.codecov.io/gh/apache/pinot/pull/18828/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/pinot/pull/18828?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add isPrivateIp scalar function for classifying private/reserved IP addresses [pinot]

Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang merged PR #18828:
URL: https://github.com/apache/pinot/pull/18828


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add isPrivateIp scalar function for classifying private/reserved IP addresses [pinot]

Posted by "Akanksha-kedia (via GitHub)" <gi...@apache.org>.
Akanksha-kedia commented on PR #18828:
URL: https://github.com/apache/pinot/pull/18828#issuecomment-4769353702

   CC @Jackie-Jiang @KKcorps — this adds `isPrivateIp()` to the existing IP address scalar function suite. Would appreciate a review when you get a chance!


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org