Skip to content
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

Function to split an IP prefix into subnets (#2) #23656

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matt-calder
Copy link
Contributor

@matt-calder matt-calder commented Sep 15, 2024

Description

This change introduces a function ip_prefix_subnets that, given an input ip_prefix and a subnet prefix_length, splits the IP prefix into subnets of the input prefix length. The functions return an array of new prefixes of the new input prefix length.

This is a new but identical PR to #23515 that I couldn't not figure out how to recover after a botched attempt to merge and squash.

This is a complimentary sister function to the ip_prefix_collapse function.

Motivation and Context

This change addresses issue 23514.

Impact

This change introduces a new user-facing function ip_prefix_subnets.

Test Plan

Unit tests

mvn clean install -Dtest=TestIpPrefixFunctions -Dmaven.javadoc.skip=true -DskipUI -T1C -fn -pl presto-main

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
== RELEASE NOTES ==

General Changes
* Add function :func:`ip_prefix_subnets` that splits the input prefix into subnets the size of the new prefix length. ... :pr:`23656`

elharo
elharo previously approved these changes Sep 15, 2024
steveburnett
steveburnett previously approved these changes Sep 16, 2024
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (docs)

Pull branch, local doc build, looks good. Thanks!

@@ -52,6 +52,8 @@ public final class IpPrefixFunctions
{
private static final BigInteger TWO = BigInteger.valueOf(2);

private static final Block emptyBlock = IPPREFIX.createBlockBuilder(null, 0).build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally use all upper case for static constants

kaikalur
kaikalur previously approved these changes Sep 19, 2024
NikhilCollooru
NikhilCollooru previously approved these changes Sep 19, 2024
@matt-calder matt-calder reopened this Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants