google / cel-go

Fast, portable, non-Turing complete expression evaluation with gradual typing (Go)
https://cel.dev
Apache License 2.0
2.24k stars 220 forks source link

Attribute Tracking Through Comprehensions #321

Open jnthntatum opened 4 years ago

jnthntatum commented 4 years ago

Feature request checklist

Change Add support for tracking attributes through comprehensions.

Example var[2].field is declared unknown for expression: var.exists(x, x.field == 'test') I would expect that var[2].field might be returned as an unknown value.

Adding tracking here to keep feature parity with cel-cpp. I'm not sure what the current level of support is in cel-go. Let me know if I can add more detail.

TristonianJones commented 4 years ago

Thanks Jon, the details look fine. Support for unknowns currently stops at comprehensions, but is slightly different from what you might have seen before since the Go implementation optimizes the field selection behavior in addition to building an attribute trail.

It's totally possible to make the change you've suggested and it would have a dramatic speedup on comprehension processing since currently the code will stop evaluation at var when it could actually complete the evaluation. :) Thanks for the report.