mz_repr::relation

Struct RelationDesc

Source
pub struct RelationDesc {
    typ: RelationType,
    metadata: BTreeMap<ColumnIndex, ColumnMetadata>,
}
Expand description

A description of the shape of a relation.

It bundles a RelationType with the name of each column in the relation.

§Examples

A RelationDescs is typically constructed via its builder API:

use mz_repr::{ColumnType, RelationDesc, ScalarType};

let desc = RelationDesc::builder()
    .with_column("id", ScalarType::Int64.nullable(false))
    .with_column("price", ScalarType::Float64.nullable(true))
    .finish();

In more complicated cases, like when constructing a RelationDesc in response to user input, it may be more convenient to construct a relation type first, and imbue it with column names to form a RelationDesc later:

use mz_repr::RelationDesc;

let relation_type = plan_query("SELECT * FROM table");
let names = (0..relation_type.arity()).map(|i| match i {
    0 => "first",
    1 => "second",
    _ => "unknown",
});
let desc = RelationDesc::new(relation_type, names);

Fields§

§typ: RelationType§metadata: BTreeMap<ColumnIndex, ColumnMetadata>

Implementations§

Source§

impl RelationDesc

Source

pub fn builder() -> RelationDescBuilder

Returns a RelationDescBuilder that can be used to construct a RelationDesc.

Source

pub fn empty() -> Self

Constructs a new RelationDesc that represents the empty relation with no columns and no keys.

Source

pub fn is_empty(&self) -> bool

Check if the RelationDesc is empty.

Source

pub fn new<I, N>(typ: RelationType, names: I) -> Self
where I: IntoIterator<Item = N>, N: Into<ColumnName>,

Constructs a new RelationDesc from a RelationType and an iterator over column names.

§Panics

Panics if the arity of the RelationType is not equal to the number of items in names.

Source

pub fn from_names_and_types<I, T, N>(iter: I) -> Self
where I: IntoIterator<Item = (N, T)>, T: Into<ColumnType>, N: Into<ColumnName>,

Source

pub fn concat(self, other: Self) -> Self

Concatenates a RelationDesc onto the end of this RelationDesc.

§Panics

Panics if either self or other have columns that were added at a RelationVersion other than RelationVersion::root or if any columns were dropped.

TODO(parkmycar): Move this method to RelationDescBuilder.

Source

pub fn with_key(self, indices: Vec<usize>) -> Self

Adds a new key for the relation.

Source

pub fn without_keys(self) -> Self

Drops all existing keys.

Source

pub fn with_names<I, N>(self, names: I) -> Self
where I: IntoIterator<Item = N>, N: Into<ColumnName>,

Builds a new relation description with the column names replaced with new names.

§Panics

Panics if the arity of the relation type does not match the number of items in names.

Source

pub fn arity(&self) -> usize

Computes the number of columns in the relation.

Source

pub fn typ(&self) -> &RelationType

Returns the relation type underlying this relation description.

Source

pub fn iter(&self) -> impl Iterator<Item = (&ColumnName, &ColumnType)>

Returns an iterator over the columns in this relation.

Source

pub fn iter_types(&self) -> impl Iterator<Item = &ColumnType>

Returns an iterator over the types of the columns in this relation.

Source

pub fn iter_names(&self) -> impl Iterator<Item = &ColumnName>

Returns an iterator over the names of the columns in this relation.

Source

pub fn iter_similar_names<'a>( &'a self, name: &'a ColumnName, ) -> impl Iterator<Item = &'a ColumnName>

Returns an iterator over the names of the columns in this relation that are “similar” to the provided name.

Source

pub fn get_by_name(&self, name: &ColumnName) -> Option<(usize, &ColumnType)>

Finds a column by name.

Returns the index and type of the column named name. If no column with the specified name exists, returns None. If multiple columns have the specified name, the leftmost column is returned.

Source

pub fn get_name(&self, i: usize) -> &ColumnName

Gets the name of the ith column.

§Panics

Panics if i is not a valid column index.

Source

pub fn get_name_mut(&mut self, i: usize) -> &mut ColumnName

Mutably gets the name of the ith column.

§Panics

Panics if i is not a valid column index.

Source

pub fn get_unambiguous_name(&self, i: usize) -> Option<&ColumnName>

Gets the name of the ith column if that column name is unambiguous.

If at least one other column has the same name as the ith column, returns None. If the ith column has no name, returns None.

§Panics

Panics if i is not a valid column index.

Source

pub fn constraints_met( &self, i: usize, d: &Datum<'_>, ) -> Result<(), NotNullViolation>

Verifies that d meets all of the constraints for the ith column of self.

n.b. The only constraint MZ currently supports in NOT NULL, but this structure will be simple to extend.

Trait Implementations§

Source§

impl Arbitrary for RelationDesc

Source§

type Parameters = ()

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
Source§

type Strategy = BoxedStrategy<RelationDesc>

The type of Strategy used to generate values of type Self.
Source§

fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
Source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Source§

impl Clone for RelationDesc

Source§

fn clone(&self) -> RelationDesc

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RelationDesc

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RelationDesc

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for RelationDesc

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoIterator for RelationDesc

Source§

type Item = (ColumnName, ColumnType)

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = (ColumnName, ColumnType)>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl MzReflect for RelationDesc

Source§

fn add_to_reflected_type_info(rti: &mut ReflectedTypeInfo)

Adds names and types of the fields of the struct or enum to rti. Read more
Source§

impl PartialEq for RelationDesc

Source§

fn eq(&self, other: &RelationDesc) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RustType<ProtoRelationDesc> for RelationDesc

Source§

fn into_proto(&self) -> ProtoRelationDesc

Convert a Self into a Proto value.
Source§

fn from_proto(proto: ProtoRelationDesc) -> Result<Self, TryFromProtoError>

Consume and convert a Proto back into a Self value. Read more
Source§

fn into_proto_owned(self) -> Proto

A zero clone version of Self::into_proto that types can optionally implement, otherwise, the default implementation delegates to Self::into_proto.
Source§

impl Schema2<Row> for RelationDesc

Source§

type ArrowColumn = StructArray

The type of column we decode from, and encoder will finish into.
Source§

type Statistics = OptionStats<StructStats>

Statistics we collect for a schema of this type.
Source§

type Decoder = RowColumnarDecoder

Type that is able to decode values of T from Self::ArrowColumn.
Source§

type Encoder = RowColumnarEncoder

Type that is able to encoder values of T.
Source§

fn decoder(&self, col: Self::ArrowColumn) -> Result<Self::Decoder, Error>

Returns a type that is able to decode instances of T from the provider column.
Source§

fn encoder(&self) -> Result<Self::Encoder, Error>

Returns a type that can encode values of T.
Source§

fn decoder_any(&self, col: &dyn Array) -> Result<Self::Decoder, Error>

Returns a type that is able to decode instances of T from a type erased arrow::array::Array, erroring if the provided array is not Self::ArrowColumn.
Source§

impl Serialize for RelationDesc

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for RelationDesc

Source§

impl StructuralPartialEq for RelationDesc

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, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

fn cast_into(self) -> U

Performs the cast.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> CollectionExt<T> for T
where T: IntoIterator,

Source§

fn into_first(self) -> <T as IntoIterator>::Item

Consumes the collection and returns its first element. Read more
Source§

fn into_last(self) -> <T as IntoIterator>::Item

Consumes the collection and returns its last element. Read more
Source§

fn expect_element<Err>( self, msg_fn: impl FnOnce() -> Err, ) -> <T as IntoIterator>::Item
where Err: Display,

Consumes the collection and returns its only element. Read more
Source§

fn into_element(self) -> <T as IntoIterator>::Item

Consumes the collection and returns its only element. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Hashable for T
where T: Hash,

Source§

type Output = u64

The type of the output value.
Source§

fn hashed(&self) -> u64

A well-distributed integer derived from the data.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T, U> OverrideFrom<Option<&T>> for U
where U: OverrideFrom<T>,

Source§

fn override_from(self, layer: &Option<&T>) -> U

Override the configuration represented by Self with values from the given layer.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ProgressEventTimestamp for T
where T: Data + Debug + Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Upcasts this ProgressEventTimestamp to Any. Read more
Source§

fn type_name(&self) -> &'static str

Returns the name of the concrete type of this object. Read more
Source§

impl<P, R> ProtoType<R> for P
where R: RustType<P>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<'a, S, T> Semigroup<&'a S> for T
where T: Semigroup<S>,

Source§

fn plus_equals(&mut self, rhs: &&'a S)

The method of std::ops::AddAssign, for types that do not implement AddAssign.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<I> ToStream<<I as IntoIterator>::Item> for I
where I: IntoIterator + 'static, <I as IntoIterator>::Item: Data,

Source§

fn to_stream<S>( self, scope: &mut S, ) -> StreamCore<S, Vec<<I as IntoIterator>::Item>>
where S: Scope,

Converts to a timely Stream. Read more
Source§

impl<C, I> ToStream<C> for I
where C: SizableContainer + PushInto<<I as IntoIterator>::Item>, I: IntoIterator + 'static,

Source§

fn to_stream<S>(self, scope: &mut S) -> StreamCore<S, C>
where S: Scope,

Converts to a timely StreamCore. Read more
Source§

impl<CB, I> ToStreamBuilder<CB> for I
where CB: ContainerBuilder + PushInto<<I as IntoIterator>::Item>, I: IntoIterator + 'static,

Source§

fn to_stream_with_builder<S>( self, scope: &mut S, ) -> StreamCore<S, <CB as ContainerBuilder>::Container>
where S: Scope,

Converts to a timely StreamCore, using the supplied container builder type. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Data for T
where T: Clone + 'static,

Source§

impl<T> Data for T
where T: Send + Sync + Any + Serialize + for<'a> Deserialize<'a> + 'static,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ExchangeData for T
where T: Data + Data,

Source§

impl<T> Sequence for T
where T: Eq + Hash,