-
Notifications
You must be signed in to change notification settings - Fork 9
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 session context to evaluation #446
Conversation
89bf8d5
to
20d255c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #446 +/- ##
==========================================
+ Coverage 79.10% 79.21% +0.11%
==========================================
Files 65 66 +1
Lines 17517 17721 +204
Branches 17517 17721 +204
==========================================
+ Hits 13856 14037 +181
- Misses 3091 3116 +25
+ Partials 570 568 -2 ☔ View full report in Codecov by Sentry. |
20d255c
to
10a4b32
Compare
Conformance comparison report
Number passing in both: 5731 Number failing in both: 612 Number passing in Base (00924f2) but now fail: 0 Number failing in Base (00924f2) but now pass: 0 |
&self.sys | ||
} | ||
|
||
fn user_context(&self, name: &str) -> Option<&(dyn Any)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way this API can output a generic C
instead of a Option<&dyn Any>
? I'd really like to implement these traits myself and just return a type that I choose, instead of going through a Option<&dyn Any>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is, I don't see how.
Making it a generic parameter of the SessionContext
would mean that any and all extensions that are loaded would need to be able to deal with that single type.
partiql-eval/src/eval/mod.rs
Outdated
pub bindings: MapBindings<Value>, | ||
|
||
pub sys: SystemContext, | ||
pub user: HashMap<String, &'a (dyn Any)>, // TODO: Unicase the keys? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll probably define our own context type, but for the most flexibility, this should be &'a (dyn Any + 'a)
to support types that contain lifetimes themselves (e.g. &'a Foo<'a>
- else you can only store something that is &'a Foo<'static>
).
...This doesn't seem to just work however. I think the user_context
method on the SessionContext trait needs to be updated as well
fn user_context<'b>(&'b self, name: &str) -> Option<&'b (dyn Any + 'b)> {}
There might be some other hoops that need to be jumped through as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any
is defined as
pub trait Any: 'static {...}
(See https://doc.rust-lang.org/std/any/trait.Any.html)
So you can't add a + 'a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this won't work for us then. Do you have some time to talk about this in person tomorrow?
I think I've worked out a way around this problem actually - let's still sync up tomorrow if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with one suggestion
Co-authored-by: Arash Maymandi <[email protected]>
Fixes #388
Adds both a system-level and a user-level session context to the evaluation context. Also plumbs the context through to
BaseTableExpr
used inpartiql_catalog::Extension
s.There is a lot of fiddly lifetime management and testing changes, as well as some slight trait refactors.
It's probably easiest to start with
partiql/tests/user_context.rs
to see what kinds of things are possible,partiql-catalog/src/context.rs
for the new context traits, andpartiql-eval/src/eval/mod.rs
for how it's used in evaluation.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.