Struct repr::relation::RelationDesc[][src]

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 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 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.

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

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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.

Performs the conversion.

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

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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