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

[pkg/ottl] Conflict resolution strategy for set function #32020

Closed
wants to merge 12 commits into from

Conversation

michalpristas
Copy link
Contributor

Description:
Added conflict resolution strategy option for set function.
Available behaviors are:

  • upsert: Is the default behavior. This setting results in creating field in case it's missing or updating existing value.
  • update: This setting updates only existing value. In case value is missing no action is taken.
  • insert: Creates a new field in case it's not present. In case field is already present no action is taken.
  • fail: Similar to insert creates a field in case it's missing but returns an error otherwise.

ending up with following signature: set(target, value, [Optional] conflict_resolution_strategy) making sure current signature still works.

Link to tracking Issue:
#31808

Testing:
Mostly updated unit test to cover new functionalities, verify current behavior is kept as default and UT for testing default values behavior for cases when field is present but unset or containing zero value

Documentation:
updated pkg/ottl/ottlfuncs/README.md

}, nil
}

func isDefaultValue(val any) bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have something better for this please let me know. i see following pattern repeated for many use cases

@michalpristas michalpristas changed the title [pkg/ottl] conflicts resolution strategy for set function [pkg/ottl] Conflict resolution strategy for set function Mar 28, 2024
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TylerHelmuth
Copy link
Member

I am currently stuck on this thought we're discussing in the issue. Since OTTL can use Where clauses to handle conflict, I want to make sure the ergonomics of the conflict resolution is better than the Where clause.

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 27, 2024
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants