Skip to content

feat(stdlib): add range function - #1994

Open
lchabert wants to merge 2 commits into
vectordotdev:mainfrom
lchabert:feat/range-function
Open

lchabert wants to merge 2 commits into
vectordotdev:mainfrom
lchabert:feat/range-function

Conversation

@lchabert

Copy link
Copy Markdown

Summary

Adds a range(start, end, [step = 1]) function that returns the integers from start (inclusive) to end (exclusive), like Python's range.

  • step can be negative: range!(5, 0, -1) returns [5, 4, 3, 2, 1].
  • An empty range returns [].
  • It errors if step is zero, or if the result would have more than 100,000 elements, to protect against memory exhaustion. The limit is a fixed constant for now; happy to change the value or make it an argument if you prefer.
  • The function is always fallible.

Use case from the issue: expanding compact integer sets such as "500..512" or "1-4094":

bounds = split(string!(.ids), "..")
.ids = range!(to_int!(bounds[0]), to_int!(bounds[1]) + 1)

How did you test this PR?

  • Unit tests in src/stdlib/range.rs: ascending, step, negative step, empty ranges, values near i64::MAX, zero step, too large.
  • cargo run -p vrl-tests (includes the 4 doc examples).
  • cargo fmt --check and cargo clippy --workspace --all-targets --all-features -- -D warnings.
  • Docs regenerated with make generate-docs.

Does this PR include user-facing changes?

  • Yes. Please add a changelog fragment based on
    our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

References

Generated with Claude Opus 5.5.

Add `range(start, end, [step])`, which returns the integers from `start`
(inclusive) to `end` (exclusive). `step` defaults to 1 and can be
negative. It errors when `step` is zero or when the result would exceed
100,000 elements.

Closes vectordotdev#1993

Generated with Claude Opus 5.5
@lchabert
lchabert requested review from a team as code owners October 14, 2026 06:54
@github-actions github-actions Bot added the docs review on hold PR is pending a docs team review label Oct 14, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T18:21:09.446038Z 7f2fd3e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs review on hold PR is pending a docs team review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a range function to generate integer arrays

2 participants