-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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++) { |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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')
?
Added:
bool IsCIDR()
to test whether there is a CIDR componentvoid INetFunctions::ExpandCIDR(DataChunk & args, ExpressionState & state, Vector & result)
to perform the CIDR expansiontest_inet_cidr_expansion.test
with IPv4 and IPv6 testsI can make any other changes necessary