Enhance Batch Queries. Support multiple lifts. #100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #101
The current system that does batch queries makes two big assumptions for any given batch query:
I
).liftQuery
construct.Quite a few refactorings in BatchQueryExecution are needed in order to remove these assumptions mostly centering around BatchQueryExecution but bits in StaticTranslationMacro and dynamic parts of QueryExecution as well.
T
of liftQuery, you need to know what InjectableEagerPlanters (as well as the CaseClass/Scalar Ast value of corresponding to T) to produce from it. Currently this is being as part of the BatchQueryExecution process with the assumption that it is the same as theI
variable which is the output of the batch-query (meaning it is the same as the query[R] part i.e. I is R. However, as we have seen before this cannot be the case. Now, if we know the type inliftQuery[T]
in the BatchQueryExecution process, we can use the T in there instead, however what do you do if the query is dynamic andT
is no longer available due to type-erasure.Instead, we need to summon the InjectableEagerExprs (and CaseClass/ScalarAst) when the liftQuery of the batch-query is called and store them inside the EagerEntitiesPlanter. Hence the
fieldGetters
and thefieldClass
types are added to EagerEntitiesPlanter and are then used in BatchQueryExecution to extract these properites.liftQuery(List(1,2,3))
) needs to be accounted for as well. Since the type information is not as important (since the encoder instance is already available on the resulting EagerListPlanter) we can reconstruct the needed functionality just by synthesizing a fake InjectableEagerPlanter that "injects" each scalar value of the list.?
for every member that it has (same with allIN SET
liftQuery situations).ExprAccumulate
in thefindUnquotes
would recurse into the EagerEntitiesPlanter and find the InjectableEagerPlanters inside hence pulling them out. This is not the desired behavior since these should only be extracted inside of the BatchQueryExecution process. Therefore I modified the ExprAccumulate process to pass an argument whether to recurse or not when a the type of expression that is searched for (e.g.case expr @ PlanterExpr.Uprootable(planter) => planter
in findUnquotes) is found.