Relation

Struct Relation 

Source
pub struct Relation<'a> {
    pub name: Cow<'a, str>,
    pub arguments: Option<Arguments<'a>>,
    pub columns: Vec<Value<'a>>,
    pub emit: Option<&'a EmitKind>,
    pub advanced_extension: Option<&'a AdvancedExtension>,
    pub children: Vec<Option<Relation<'a>>>,
}

Fields§

§name: Cow<'a, str>§arguments: Option<Arguments<'a>>

Arguments to the relation, if any.

  • None means this relation does not take arguments, and the argument section is omitted entirely.
  • Some(args) with both vectors empty means the relation takes arguments, but none are provided; this will print as _ => ....
  • Some(args) with non-empty vectors will print as usual, with positional arguments first, then named arguments, separated by commas.
§columns: Vec<Value<'a>>

The columns emitted by this relation, pre-emit - the ‘direct’ column output.

§emit: Option<&'a EmitKind>

The emit kind, if any. If none, use the columns directly.

§advanced_extension: Option<&'a AdvancedExtension>

The advanced extension (enhancement and/or optimizations) attached to this relation, if any. Mirrors the advanced_extension field carried by standard relation types in the protobuf (Read, Filter, Project, etc…) Extension relations (ExtensionLeaf, ExtensionSingle, ExtensionMulti) do not carry this field and always set it to None.

§children: Vec<Option<Relation<'a>>>

The input relations.

Implementations§

Source§

impl Relation<'_>

Source

pub fn write_header<S: Scope, W: Write>(&self, ctx: &S, w: &mut W) -> Result

Write the single header line for this relation, e.g. Filter[$0 => $0]. Does not write a trailing newline; callers are responsible for any newline that follows (either from adv_ext or from the next child).

Source

pub fn write_children<S: Scope, W: Write>(&self, ctx: &S, w: &mut W) -> Result

Write each child relation at one indent level deeper than ctx. Each child is preceded by a newline.

Source§

impl<'a> Relation<'a>

Source

pub fn emitted(&self) -> usize

Source§

impl<'a> Relation<'a>

Source

fn from_read<S: Scope>(rel: &'a ReadRel, _ctx: &S) -> Self

Source§

impl<'a> Relation<'a>

Source

pub fn input_refs(&self) -> Vec<Value<'a>>

Create a vector of values that are references to the emitted outputs of this relation. “Emitted” here meaning the outputs of this relation after the emit kind has been applied.

This is useful for relations like Filter and Limit whose direct outputs are primarily those of its children (direct here meaning before the emit has been applied).

Source

pub fn convert_children<S: Scope>( refs: Vec<Option<&'a Rel>>, ctx: &S, ) -> (Vec<Option<Relation<'a>>>, usize)

Convert a vector of relation references into their structured form.

Returns a list of children (with None for ones missing), and a count of input columns.

Source§

impl<'a> Relation<'a>

Source

fn from_filter<S: Scope>(rel: &'a FilterRel, ctx: &S) -> Self

Source

fn from_project<S: Scope>(rel: &'a ProjectRel, ctx: &S) -> Self

Source

pub fn from_rel<S: Scope>(rel: &'a Rel, ctx: &S) -> Self

Source

fn from_extension_leaf<S: Scope>(rel: &'a ExtensionLeafRel, ctx: &S) -> Self

Source

fn from_extension_single<S: Scope>(rel: &'a ExtensionSingleRel, ctx: &S) -> Self

Source

fn from_extension_multi<S: Scope>(rel: &'a ExtensionMultiRel, ctx: &S) -> Self

Source

fn from_extension<S: Scope>( ext_type: &'static str, decoded: Result<(String, ExtensionArgs), ExtensionError>, child_refs: Vec<Option<&'a Rel>>, ctx: &S, ) -> Self

Source

fn from_aggregate<S: Scope>(rel: &'a AggregateRel, ctx: &S) -> Self

Convert an AggregateRel to a Relation for textification.

The conversion follows this logic:

  1. Arguments: Group-by expressions (as Value::Expression)
  2. Columns: All possible outputs in order:
    • First: Group-by field references (Value::Reference)
    • Then: Aggregate function measures (Value::AggregateFunction)
  3. Emit: Uses the relation’s emit mapping to select which outputs to display
  4. Children: The input relation
Source

fn get_grouping_sets( rel: &'a AggregateRel, ) -> (Vec<Value<'a>>, Vec<Vec<Value<'a>>>)

Source§

impl<'a> Relation<'a>

Source

fn from_sort<S: Scope>(rel: &'a SortRel, ctx: &S) -> Self

Source

fn from_fetch<S: Scope>(rel: &'a FetchRel, ctx: &S) -> Self

Source§

impl<'a> Relation<'a>

Source

fn from_join<S: Scope>(rel: &'a JoinRel, ctx: &S) -> Self

Trait Implementations§

Source§

impl Textify for Relation<'_>

Source§

fn name() -> &'static str

Source§

fn textify<S: Scope, W: Write>(&self, ctx: &S, w: &mut W) -> Result

Auto Trait Implementations§

§

impl<'a> Freeze for Relation<'a>

§

impl<'a> RefUnwindSafe for Relation<'a>

§

impl<'a> Send for Relation<'a>

§

impl<'a> Sync for Relation<'a>

§

impl<'a> Unpin for Relation<'a>

§

impl<'a> UnwindSafe for Relation<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.