-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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]: add SliceToMap function #35412
[pkg/ottl]: add SliceToMap function #35412
Conversation
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
@@ -84,12 +94,29 @@ func Test_e2e_editors(t *testing.T) { | |||
m.PutStr("test.foo.flags", "pass") | |||
m.PutStr("test.foo.slice.0", "val") | |||
m.PutStr("test.foo.nested.test", "pass") | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evan-bradley @TylerHelmuth - This is not related to the function implemented in this PR, but after adding a slice of nested objects to the test attributes I found that the flatten
function seems to not flatten the attributes of nested objects within a slice, but rather leaves the objects within the slice unchanged - is this intended or is this a bug in that function?
Also, when setting the depth
to 0
(as in the test case below), slices at the top level of the input of the flatten function will still be flattened.
Please let me know if this behavior is intended or if this may be a bug - If it's the latter, I can create an issue for that and work on a fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These sound like bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These sound like bugs to me, too. Could you file an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the functionality looks correct to me. Just a few nits
Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Thanks a lot for the review @djaglowski ! I have updated the PR with the suggested changes now |
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
pkg/ottl/ottlfuncs/README.md
Outdated
|
||
`SliceToMap(target, keyPath, Optional[valuePath])` | ||
|
||
The `SliceToMap` converter converts a slice of objects to a map. The name of the keys for the map entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we describe how this could be used to address slice items? I think we should highlight the fact that this allows limited list manipulation in OTTL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a small sample for how the converted map could be used afterwards now.
Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Description: This PR adds a function that converts slices to maps, as described in the linked issue. Currently still WIP, but creating a draft PR already to show how this could be implemented and used
Link to tracking Issue: #35256
Testing: Added unit and end to end tests
Documentation: Added description for the new function in the readme file