Skip to content

[pkg/ottl] New function SubSlice #40482

Open
@kaisecheng

Description

@kaisecheng

Component(s)

pkg/ottl

Is your feature request related to a problem? Please describe.

Currently, OTTL does not have a function to sub-slice a slice with a given start and end indices slice[start:end].

Describe the solution you'd like

  1. Add SubSlice(target, start, end) converter and returns a new slice.
    target : any type of slice
    start : the starting index of the sublist (inclusive)
    end : the ending index of the sublist (exclusive)

  2. Support Go's slice expressions syntax in ottl
    target[start:end]
    target[:end]
    target[start:]
    Following go slice expression, start and end can not be negative integer

Supporting (1) would be very helpful, (2) is cool to have it.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions