[query] Algebrize get-else functions #127

Open
opened 2020-08-06 16:55:22 +00:00 by gburd · 0 comments
gburd commented 2020-08-06 16:55:22 +00:00 (Migrated from github.com)

get-else is how Datalog handles optional attributes.

It consists of:

  • A bound entity
  • A cardinality-one attribute
  • A var to bind the value
  • A default value.

We model this as:

  • A check against known bindings for the entity.
  • A check against the schema for cardinality-one.
  • Generating a COALESCE expression with a query inside the projection itself.

Note that this will be messy for queries like:

  [:find ?page ?title
   :where [?page :page/url _]
          [(get-else ?page :page/title "<empty>") ?title]
          [_ :foo/quoted ?title]]

or

          [(some-function ?title)]

— we aren't really establishing a binding, so the subquery will be repeated. The ability to establish a real binding is important, and might need to be addressed by this ticket, now that we're not simply building a proof of concept!

`get-else` is how Datalog handles optional attributes. It consists of: * A bound entity * A cardinality-one attribute * A var to bind the value * A default value. We model this as: * A check against known bindings for the entity. * A check against the schema for cardinality-one. * Generating a `COALESCE` expression with a query inside the projection itself. Note that this will be messy for queries like: ```edn [:find ?page ?title :where [?page :page/url _] [(get-else ?page :page/title "<empty>") ?title] [_ :foo/quoted ?title]] ``` or ```edn [(some-function ?title)] ``` — we aren't really establishing a binding, so the subquery will be repeated. The ability to establish a real binding is important, and might need to be addressed by this ticket, now that we're not simply building a proof of concept!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/mentat#127
No description provided.