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

Append values to lists in an event #4129

Closed
oeyh opened this issue Feb 14, 2024 · 2 comments · Fixed by #4143
Closed

Append values to lists in an event #4129

oeyh opened this issue Feb 14, 2024 · 2 comments · Fixed by #4143
Labels
enhancement New feature or request
Milestone

Comments

@oeyh
Copy link
Collaborator

oeyh commented Feb 14, 2024

Is your feature request related to a problem? Please describe.
Append is a common operation for lists. As a Data Prepper user, I would like to be able to append values to a list in the event.

Describe the solution you'd like
add_entries processor can be enhanced to achieve this by adding an append_if_key_exists option:

    - add_entries:
        entries:
          - key: "fruits"
            value: "banana"
            append_if_key_exists: true

Example1:
Input:

{"fruits": "apple"}

output:

{"fruits": ["apple", "banana"]}

Example2:
Input:

{"fruits": ["apple", "watermelon"]}

output:

{"fruits": ["apple", "watermelon", "banana"]}

Describe alternatives you've considered (Optional)
A separate list_append processor.

Additional context
#3967

@oeyh oeyh added untriaged enhancement New feature or request and removed untriaged labels Feb 14, 2024
@dlvenable
Copy link
Member

@oeyh , What is the default behavior now? I tend to think that this behavior should be the default unless overwrite_if_key_exists is set to true.

@oeyh
Copy link
Collaborator Author

oeyh commented Feb 15, 2024

@oeyh , What is the default behavior now? I tend to think that this behavior should be the default unless overwrite_if_key_exists is set to true.

@dlvenable Currently, the value will not be added if the key exists and overwrite_if_key_exists is not set.

@dlvenable dlvenable added this to the v2.7 milestone Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

2 participants