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

Dedicated dynamic path query syntax in VRL #67

Open
JeanMertz opened this issue May 3, 2022 · 1 comment
Open

Dedicated dynamic path query syntax in VRL #67

JeanMertz opened this issue May 3, 2022 · 1 comment
Labels
type: feature A value-adding code addition that introduce new functionality. vrl: compiler Changes to the compiler vrl: parser Changes to the syntax parser

Comments

@JeanMertz
Copy link
Contributor

This issue got spun out from this comment.

Dynamic field access in VRL is currently supported through the get function.

We want to remove this function in favour of dedicated syntax to achieve the same result.

Specifically, we would like to allow this:

idx = 12
bar = "baz"
.foo."{{bar}}"[idx]

That is, we'll use string-templating (see vectordotdev/vector#8467) to allow dynamic fields, and allow variables (that must resolve to a number) inside [...] for array indexing.

@JeanMertz JeanMertz added the type: feature A value-adding code addition that introduce new functionality. label May 3, 2022
@JeanMertz
Copy link
Contributor Author

One thing I realized, is that there's one feature of the get function, which isn't covered by this dynamic path lookup syntax, which is support for dynamically sized arrays for nested path access.

That is, this works:

{ "my_path": ["foo", "bar", 0], "foo": { "bar": [{"baz": true }] } }
path = push!(.my_path, "baz")

get!(., path)
true

This can't be achieved using the syntax proposed in this issue. There are ways to make this work, but I'll have to think some more on what the most promising approach would be. It might also be the case that this is something we don't want to support right now, maybe?

@JeanMertz JeanMertz added vrl: syntax Changes to the syntax vrl: compiler Changes to the compiler vrl: parser Changes to the syntax parser and removed vrl: syntax Changes to the syntax labels Jun 7, 2022
@fuchsnj fuchsnj transferred this issue from vectordotdev/vector Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A value-adding code addition that introduce new functionality. vrl: compiler Changes to the compiler vrl: parser Changes to the syntax parser
Projects
None yet
Development

No branches or pull requests

1 participant