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

remap-lang: allow negative indexing into arrays #5546

Closed
JeanMertz opened this issue Dec 15, 2020 · 1 comment · Fixed by #6353
Closed

remap-lang: allow negative indexing into arrays #5546

JeanMertz opened this issue Dec 15, 2020 · 1 comment · Fixed by #6353
Assignees
Labels
domain: vrl Anything related to the Vector Remap Language needs: more demand Needs more demand before work can begin, +1 or comment to support. type: enhancement A value-adding code change that enhances its existing functionality.

Comments

@JeanMertz
Copy link
Contributor

JeanMertz commented Dec 15, 2020

given this:

{ "foo": ["bar", "baz"] }

This works:

.foo[0] // "bar"
.foo[1] // "baz"

This does not:

.foo[-1] // "baz"
.foo[-2] // "bar"

There is no technical reason we can't implement this, but the language grammar does not support negative index numbers at the moment.

This was either a deliberate choice to reduce language complexity, or just something we haven't got to yet (I don't know the answer).

Regardless, people seem to run into this limitation (see https://discord.com/channels/742820443487993987/746070591097798688/787115063500472331), so it's worth considering supporting negative indexing in path queries.

@JeanMertz JeanMertz added type: enhancement A value-adding code change that enhances its existing functionality. needs: more demand Needs more demand before work can begin, +1 or comment to support. domain: vrl Anything related to the Vector Remap Language labels Dec 15, 2020
@binarylogic binarylogic added this to the 2021-01-18 Tabula E-Rasa milestone Jan 15, 2021
@JeanMertz JeanMertz assigned JeanMertz and unassigned StephenWakely Jan 25, 2021
@asymmetric
Copy link

Is this documented? I couldn't find any mention of negative indexes in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: vrl Anything related to the Vector Remap Language needs: more demand Needs more demand before work can begin, +1 or comment to support. type: enhancement A value-adding code change that enhances its existing functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants