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

Add support for looping over lists in OTTL #37993

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jsuereth
Copy link
Contributor

@jsuereth jsuereth commented Feb 18, 2025

Description

Adds list-comprehension support to OTTL. As of this PR you can successfully write expressions like: [x*2 for x in mylist if x > 0]

Link to tracking issue

Fixes #29289

Testing

  • Basic testing (see this for end to end)
  • Test with existing list-based functions, like append.
  • Create advanced testing scenarios

Documentation

  • Document baseline syntax and usage

Next Steps

Basic scaffolding of Expr[_} that will construct a new Slice using an existing one.
Add simplistic test to verify basics work.

Need to sort through more advanced grammar tests later.
- Hackily construct new Parser for list comprehension evaluation
- Delegate from existing parser to nested context to avoid reflection issues

TODOs
- Robust Testing
- Ensuring we didn't miss other places lists could exist
- Figuring out how to safely deal with recursion of names.
jsuereth and others added 4 commits February 18, 2025 14:51
- Needed new wrapping key/context path features
- Needed hacks on context inference and path parsing for loop expressions
- Gunked up visitor pattern for List compmrehensions

Got test working end to end...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pkg/ottl] Determine approach to looping
1 participant