-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
Considering the KeyPath argument was recently made optional (#41390), the SliceToMap function can be changed to also accept non-map elements when both KeyPath and ValuePath arguments are absent.
In addition to that, the function is verifying the slice elements type by ensuring elem.(map[string]any), which makes it to not support other common input types, such as literals (SliceToMap([{"one": 1}, {"two": 2}])), or pcommon.Value.
Describe the solution you'd like
Calling the function as SliceToMap(["a", "b"]) should return {"0": "a", "1": "b"}, as there's no requirement to the slice elements to be a map. Currently, the following error is raised: could not cast element 'a' to map[string]any.
It should also support other common types of elements, such as pcommon.Map and pcommon.Value.
Describe alternatives you've considered
No response
Additional context
No response
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.