-
Notifications
You must be signed in to change notification settings - Fork 219
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
Optimize type conversion functions. #360
Optimize type conversion functions. #360
Conversation
This is great! Correct me if i'm wrong, this implementation would contract the AST from a |
Yahoo! 🎉 |
@glerchundi well, not exactly. The code will convert from |
Ok, thanks anyway :D. Good job! |
@glerchundi I'll eventually get to supporting linting. This will at least tell you that the checked-AST has I have a few more tests that I need to add to catch malformed inputs at optimization time, but then I'll send this out for review. |
I guess it does partially. Currently we're parsing the expression and the walking the AST to build the SQL expression. Having an evaluation process where it executes the corresponding sanity check before proceeding sounds good but it's not enough as we need to continue walking the unmodified AST and taking care of the call expressions in it (like Ideally I would expect We're already doing it but makes the implementation more complicated that I would like it to be. |
Does your decorator implementation in #363 helps converting/contracting |
Hi @glerchundi, #363 is a decorator that participates in an AST walk done before evaluation. It's not really what you're looking for since it doesn't modify the AST; however, what I could do is expose a |
… literals for timestamps, durations. More tests needed
6b363f8
to
38f6450
Compare
PTAL |
That is a fantastic idea @TristonianJones! I'll create an issue asking for exactly that and in case we found a free time slot & we see ourselves with the capacity to make it happen without messing the code we'll send a PR. |
* Optimize type conversion functions. Produces errors on invalid string literals for timestamps, durations. More tests needed * Added more tests and support for dyn to the type-conversion optimization
Unary type-conversion functions with literal arguments should be evaluated
eagerly when the
cel.EvalOptions(cel.OptOptimize)
flag is set. The conversionwill also ensure that if an error is encountered when evaluating these functions,
such as when constructing timestamps or durations from strings, the evaluation
will result in an error in the
env.Program
call.This is not a perfect fix for #359, but it can be used to assist with correctness checks.