Struct mentat_query_algebrizer::ConjoiningClauses
[−]
[src]
pub struct ConjoiningClauses { pub empty_because: Option<EmptyBecause>, pub from: Vec<SourceAlias>, pub computed_tables: Vec<ComputedTable>, pub wheres: ColumnIntersection, pub column_bindings: BTreeMap<Variable, Vec<QualifiedAlias>>, pub input_variables: BTreeSet<Variable>, pub known_types: BTreeMap<Variable, ValueTypeSet>, pub extracted_types: BTreeMap<Variable, QualifiedAlias>, // some fields omitted }
A ConjoiningClauses
(CC) is a collection of clauses that are combined with JOIN
.
The topmost form in a query is a ConjoiningClauses
.
- Ordinary pattern clauses turn into
FROM
parts andWHERE
parts using=
. - Predicate clauses turn into the same, but with other functions.
- Function clauses turn into
WHERE
parts using function-specific comparisons. not
turns intoNOT EXISTS
withWHERE
clauses inside the subquery to bind it to the outer variables, or adds simpleWHERE
clauses to the outer clause.not-join
is similar, but with explicit binding.or
turns into a collection ofUNION
s inside a subquery, or a simple alternation.or
's documentation states that all clauses must include the same vars, but that's an over-simplification: all clauses must refer to the external unification vars. The entireUNION
-set isJOIN
ed to any surrounding expressions per therule-vars
clause, or the intersection of the vars in the two sides of theJOIN
.
Not yet done:
- Function clauses with bindings turn into:
- Subqueries. Perhaps less efficient? Certainly clearer.
- Projection expressions, if only used for output.
- Inline expressions?
Fields
empty_because: Option<EmptyBecause>
Some
if this set of clauses cannot yield results in the context of the current schema.
from: Vec<SourceAlias>
A vector of source/alias pairs used to construct a SQL FROM
list.
computed_tables: Vec<ComputedTable>
A vector of computed tables (typically subqueries). The index into this vector is used as
an identifier in a DatomsTable::Computed(c)
table reference.
wheres: ColumnIntersection
A list of fragments that can be joined by AND
.
column_bindings: BTreeMap<Variable, Vec<QualifiedAlias>>
A map from var to qualified columns. Used to project.
input_variables: BTreeSet<Variable>
A list of variables mentioned in the enclosing query's :in clause. These must all be bound before the query can be executed. TODO: clarify what this means for nested CCs.
known_types: BTreeMap<Variable, ValueTypeSet>
A map from var to type. Whenever a var maps unambiguously to two different types, it cannot
yield results, so we don't represent that case here. If a var isn't present in the map, it
means that its type is not known in advance.
Usually that state should be represented by ValueTypeSet::Any
.
extracted_types: BTreeMap<Variable, QualifiedAlias>
A mapping, similar to column_bindings
, but used to pull type tags out of the store at runtime.
If a var isn't unit in known_types
, it should be present here.
Methods
impl ConjoiningClauses
[src]
pub fn bind_value(&mut self, var: &Variable, value: TypedValue)
[src]
Be careful with this. It'll overwrite existing bindings.
pub fn bound_value(&self, var: &Variable) -> Option<TypedValue>
[src]
pub fn is_value_bound(&self, var: &Variable) -> bool
[src]
pub fn value_bindings(&self, variables: &BTreeSet<Variable>) -> VariableBindings
[src]
pub fn value_bound_variables(&self) -> VariableIterator
[src]
Return an iterator over the variables externally bound to values.
pub fn value_bound_variable_set(&self) -> BTreeSet<Variable>
[src]
Return a set of the variables externally bound to values.
pub fn known_type(&self, var: &Variable) -> Option<ValueType>
[src]
Return a single ValueType
if the given variable is known to have a precise type.
Returns None
if the type of the variable is unknown.
Returns None
if the type of the variable is known but not precise -- "double
or integer" isn't good enough.
pub fn known_type_set(&self, var: &Variable) -> ValueTypeSet
[src]
pub fn is_known_empty(&self) -> bool
[src]
Trait Implementations
impl PartialEq for ConjoiningClauses
[src]
fn eq(&self, other: &ConjoiningClauses) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for ConjoiningClauses
[src]
impl Debug for ConjoiningClauses
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Default for ConjoiningClauses
[src]
Basics.
fn default() -> ConjoiningClauses
[src]
Returns the "default value" for a type. Read more