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

List helper functions #751

Open
chancez opened this issue Jun 22, 2023 · 0 comments
Open

List helper functions #751

chancez opened this issue Jun 22, 2023 · 0 comments

Comments

@chancez
Copy link
Contributor

chancez commented Jun 22, 2023

Change
I'm looking at whether or not CEL could be used as a DSL for an existing gRPC based query API. For a query API, we may need to operate on a list of objects and perform various operations. Some macros like filter, exists, and map already exist for some use-cases, and I would like to see if we could add additional functions that operate on lists.

Example

  • myList.slice(start, end) could slice a list, much like in Go or Python via: mylist[start:end].
  • myList.first(n) could take the first elements from a list.
  • myList.last(n) could take the last elements from a list.

Any many more could be considered, but at the moment, these 3 are the first ones I'm thinking about.

Alternatives considered

This could be handled outside of CEL, but being able to manipulate lists would be very useful for using CEL in a query language.

I wrote a quick MVP of list.slice here: master...chancez:cel-go:pr/chancez/slice_function

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

No branches or pull requests

1 participant