Skip to content

[pkg/telemetryquerylanguage] Add list values to the TQL grammar #13391

Closed
@evan-bradley

Description

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

The TQL grammar does not support list values. Variadic arguments are currently supported to be declared by functions and parsed by TQL, but do not actually exist within the grammar. In addition to limiting expressivity, this has a few additional impacts as currently implemented.

There is currently no way to pass multiple sequences to a function in TQL. For example, TQL would presently not be able to parse the following function call:

zip(["one", "three", "five"], ["two", "four", "six"]) // -> ["one", "two", "three", "four", "five, "six"]

Additionally, the current way of parsing arrays does not defend against functions specifying arrays before the last parameter, even if doing so is against current guidance. The following function would compile and run without any complaints from the parser:

function Join(items []string, joiner string) (tql.ExprFunc, error) {
    return func (ctx tql.TransformContext) interface {} {}
}

Describe the solution you'd like

The TQL grammar and parser should be updated to include slices as possible function parameters. Additionally, variadic parameters in Go should be used to implement the current functionality filled by slices in function definitions. Go's reflection library supports determining whether a parameter is variadic.

Describe alternatives you've considered

We could leave slices out of the grammar, but this seems limiting.

Additional context

The processor exploration document calls this out as a feature that would be desirable in the future.

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions