[query] Implement pull expressions in queries #92
Labels
No labels
A-build
A-cli
A-core
A-design
A-edn
A-ffi
A-query
A-sdk
A-sdk-android
A-sdk-ios
A-sync
A-transact
A-views
A-vocab
P-Android
P-desktop
P-iOS
bug
correctness
dependencies
dev-ergonomics
discussion
documentation
duplicate
enhancement
enquiry
good first bug
good first issue
help wanted
hygiene
in progress
invalid
question
ready
size
speed
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: greg/mentat#92
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Datomic splits query logic between a relatively simple "find" part, to narrow down to a set of bindings, and a relatively expressive "pull" part that fans out to retrieve data.
This separation is useful: these are two different concerns, and one of the tricky parts of complex SQL is untangling navigation and refinement from retrieval.
It's also how Datomic most naturally expresses optional values — they're simply missing from the pulled output. Optional values inside
find
aren't possible; the closest you can get isget-else
(#308).Pull expressions can be arbitrarily complex: recursive up to a fixed or arbitrary depth; returning a limited number of results; reversed; nested; and fetching component values even when attributes are not known in advance.
Additionally, pull results are structured: they don't fit easily into the standard rel/coll/scalar
TypedValue
model.Simple pull queries like:
can compile to a particular kind of projector and a SQL query like:
Clearly it's infeasible to produce a single SQL query for a pull query like:
which might return something like:
For these queries we need to compile the pull expression into a collection of parameterized queries which can be prepared and run with bindings from the main
find
query. These results can be processed and combined with the simple bindings.Work in this issue will consist of:
Just tackling the simplest case will be useful.