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

[feature enhancement] Additional merge strategies #757

Open
prein opened this issue Mar 20, 2024 · 0 comments
Open

[feature enhancement] Additional merge strategies #757

prein opened this issue Mar 20, 2024 · 0 comments
Labels
vrl: stdlib Changes to the standard library

Comments

@prein
Copy link

prein commented Mar 20, 2024

It would be great to be able to control merge function behavior when there are keys with the same name in "to" and "from" objects.
Current behavior for simple values is to use the value from object that enjoys higher precedence.
What I think could be sometimes helpful to be able to do instead:

  • rename the key
  • merge / concatenate the values from both keys
  • store the conflicting keys in some other object

Example:

event:

{
  "json": {
    "msg": "bar"
  },
  "msg": "foo"
}

program:

. = merge!(del(.json), .)

output:

{
    "msg": "foo"
}

changing the precedence
program:

. = merge!(.,del(.json))

output:

{
    "msg": "bar"
}
@prein prein changed the title [feature enhancement] Additional merge startegies [feature enhancement] Additional merge strategies Mar 20, 2024
@jszwedko jszwedko added the vrl: stdlib Changes to the standard library label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vrl: stdlib Changes to the standard library
Projects
None yet
Development

No branches or pull requests

2 participants