pub struct RelationDesc {
    typ: RelationType,
    names: Vec<ColumnName>,
}
Expand description

A description of the shape of a relation.

It bundles a RelationType with the name of each column in the relation. Individual column names are optional.

Examples

A RelationDescs is typically constructed via its builder API:

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

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

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: RelationTypenames: Vec<ColumnName>

Implementations

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

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.

Concatenates a RelationDesc onto the end of this RelationDesc.

Appends a column with the specified name and type.

Adds a new key for the relation.

Drops all existing keys.

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.

Computes the number of columns in the relation.

Returns the relation type underlying this relation description.

Returns an iterator over the columns in this relation.

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

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

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.

Gets the name of the ith column.

Panics

Panics if i is not a valid column index.

Mutably gets the name of the ith column.

Panics

Panics if i is not a valid column index.

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.

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

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default. Read more
The type of Strategy used to generate values of type Self. Read more
Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
Adds names and types of the fields of the struct or enum to rti. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Convert a Self into a Proto value.
Consume and convert a Proto back into a Self value. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Consumes the collection and returns its first element. Read more
Consumes the collection and returns its last element. Read more
Consumes the collection and returns its only element. Read more
Consumes the collection and returns its only element. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Attaches the current Context to this type, returning a WithContext wrapper. Read more
The type of the output value.
A well-distributed integer derived from the data.
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Wrap the input message T in a tonic::Request
Upcasts this ProgressEventTimestamp to Any. Read more
Returns the name of the concrete type of this object. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more