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

chore: add CIDR functions, tests, and more documentation for a clean PR #5

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

Conversation

hrbrmstr
Copy link

Added:

  • bool IsCIDR() to test whether there is a CIDR component
  • void INetFunctions::ExpandCIDR(DataChunk & args, ExpressionState & state, Vector & result) to perform the CIDR expansion
  • file: test_inet_cidr_expansion.test with IPv4 and IPv6 tests

I can make any other changes necessary

Copy link
Contributor

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks good - some comments

auto address_data = FlatVector::GetData < hugeint_t > ( * entries[1]);
auto mask_data = FlatVector::GetData < uint16_t > ( * entries[2]);

for (idx_t i = 0; i < args.size(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you format this using the DuckDB clang-format?


# ipv6
query I
SELECT expand_cidr(inet '2001:db8::/126');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test with NULL values?

// Add all addresses in the range
auto current = network;
hugeint_t one(1);
for (hugeint_t j = 0; j < hosts && current.address <= broadcast.address; j = j + one) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add some safeguard to limit this to a certain max amount? e.g. what happens if we run expand_cidr(inet '::/0')?

@Mytherin Mytherin mentioned this pull request Jan 6, 2025
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.

2 participants