Enum ProjectList

Source
pub enum ProjectList {
    Name(Vec<ProjectName>),
    List(Vec<RelExpr>, Vec<(Box<str>, FieldProject)>),
    Limit(Box<ProjectList>, u64),
    Agg(Vec<RelExpr>, AggType, Box<str>, AlgebraicType),
}
Expand description

A projection is the root of any relational expression. This type represents a projection that returns fields.

For example:

select a, b from t

and

select t.a as x from t join s ...

Note that RLS takes a single expression and produces a list of expressions. Hence why these variants take lists rather than single expressions.

Why does RLS take an expression and produce a list?

There may be multiple RLS rules associated to a single table. Semantically these rules represent a UNION over that table, and this corresponds to a UNION in the original expression.

TODO: We should model the UNION explicitly in the physical plan.

Ex.

Let’s say we have the following rules for the users table:

use spacetimedb::client_visibility_filter;
use spacetimedb::Filter;

#[client_visibility_filter]
const USER_FILTER: Filter = Filter::Sql(
    "SELECT users.* FROM users WHERE identity = :sender"
);

#[client_visibility_filter]
const ADMIN_FILTER: Filter = Filter::Sql(
    "SELECT users.* FROM users JOIN admins"
);

The user query

SELECT * FROM users WHERE level > 5

essentially resolves to

SELECT users.*
FROM users
WHERE identity = :sender AND level > 5

UNION ALL

SELECT users.*
FROM users JOIN admins
WHERE users.level > 5

Variants§

Implementations§

Source§

impl ProjectList

Source

pub fn return_table(&self) -> Option<&TableSchema>

Does this expression project a single relvar? If so, we return it’s TableSchema. If not, it projects a list of columns, so we return None.

Source

pub fn return_table_id(&self) -> Option<TableId>

Does this expression project a single relvar? If so, we return it’s TableId. If not, it projects a list of columns, so we return None.

Source

pub fn for_each_return_field(&self, f: impl FnMut(&str, &AlgebraicType))

Iterate over the projected column names and types

Trait Implementations§

Source§

impl Debug for ProjectList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.