-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add a way to select only certain fields in VRL #118
Comments
The reason was that it was sufficiently different from other functions (in that it was the only one that had a (hacky) way to provide a variable number of arguments to it, up to a limit of 32) that we wanted to take our time getting that right. It was also discussed that having iteration in the future would make this function obsolete, as you could do this via iteration + |
Aha I see. We could support it with our current compiler with something like:
I realize this differs a bit from This would also be solved by iteration. |
Yeah, I'm not a fan of mixing "fields" (string type) and "paths" (path type) for the approximately same use-case. I'd prefer it if we stick to paths wherever they are needed, but I also reckon there's still some gaps there for that to be a viable solution everywhere.
Indeed. Although there we'd still have the issue that paths are currently evaluated at the call site, so you couldn't do something like |
@jszwedko , in discord you mentioned that current event object can be copied, like:
and then copy can be changed. Tried and faced an issue with this approach:
So looks like new '.' is not the same type of object as an original.
So I want to ask:
Thanks a lot! |
Hi @kkornienko-aparavi , Assignment in VRL creates a copy rather than a reference. That is:
Does that make sense? |
@jszwedko , thanks, I've got an idea about copy, sure. why Or, differently - why this example throws an error: but if the first line is commented out - it works...: |
This is working as designed. The intention is to raise an error when the compiler can determine the exact fields. When you assign The main motivation behind this choice is to avoid accidental data overwrite. Example:
I understand it can be a bit confusing and we should probably improve the error message. cc @fuchsnj (since he's the expert here) |
@pront , thanks a lot for such a detailed explanation! Now it's crystal clear for me. My guess was that {} and . are objects of different types/classes. |
Requested by user in discord: https://discord.com/channels/742820443487993987/764187584452493323/839503742813732884
We had an
only_fields
at one point, but it got backed out. I can't remember why though.The text was updated successfully, but these errors were encountered: