pub enum ScalarType {
Show 32 variants Bool, Int16, Int32, Int64, UInt16, UInt32, UInt64, Float32, Float64, Numeric { max_scale: Option<NumericMaxScale>, }, Date, Time, Timestamp, TimestampTz, Interval, PgLegacyChar, Bytes, String, Char { length: Option<CharLength>, }, VarChar { max_length: Option<VarCharMaxLength>, }, Jsonb, Uuid, Array(Box<ScalarType>), List { element_type: Box<ScalarType>, custom_id: Option<GlobalId>, }, Record { fields: Vec<(ColumnName, ColumnType)>, custom_id: Option<GlobalId>, }, Oid, Map { value_type: Box<ScalarType>, custom_id: Option<GlobalId>, }, RegProc, RegType, RegClass, Int2Vector, MzTimestamp,
}
Expand description

The type of a Datum.

There is a direct correspondence between Datum variants and ScalarType variants.

Variants

Bool

The type of Datum::True and Datum::False.

Int16

The type of Datum::Int16.

Int32

The type of Datum::Int32.

Int64

The type of Datum::Int64.

UInt16

The type of Datum::UInt16.

UInt32

The type of Datum::UInt32.

UInt64

The type of Datum::UInt64.

Float32

The type of Datum::Float32.

Float64

The type of Datum::Float64.

Numeric

Fields

max_scale: Option<NumericMaxScale>

The type of Datum::Numeric.

Numeric values cannot exceed NUMERIC_DATUM_MAX_PRECISION digits of precision.

This type additionally specifies the maximum scale of the decimal. The scale specifies the number of digits after the decimal point.

Date

The type of Datum::Date.

Time

The type of Datum::Time.

Timestamp

The type of Datum::Timestamp.

TimestampTz

The type of Datum::TimestampTz.

Interval

The type of Datum::Interval.

PgLegacyChar

A single byte character type backed by a Datum::UInt8.

PostgreSQL calls this type "char". Note the quotes, which distinguish it from the type ScalarType::Char.

Bytes

The type of Datum::Bytes.

String

The type of Datum::String.

Char

Fields

length: Option<CharLength>

Stored as Datum::String, but expresses a fixed-width, blank-padded string.

Note that a length of None is used in special cases, such as creating lists.

VarChar

Fields

max_length: Option<VarCharMaxLength>

Stored as Datum::String, but can optionally express a limit on the string’s length.

Jsonb

The type of a datum that may represent any valid JSON value.

Valid datum variants for this type are:

Uuid

The type of Datum::Uuid.

Array(Box<ScalarType>)

The type of Datum::Array.

Elements within the array are of the specified type. It is illegal for the element type to be itself an array type. Array elements may always be Datum::Null.

List

Fields

element_type: Box<ScalarType>
custom_id: Option<GlobalId>

The type of Datum::List.

Elements within the list are of the specified type. List elements may always be Datum::Null.

Record

Fields

fields: Vec<(ColumnName, ColumnType)>

The names and types of the fields of the record, in order from left to right.

custom_id: Option<GlobalId>

An ordered and named sequence of datums.

Oid

A PostgreSQL object identifier.

Map

Fields

value_type: Box<ScalarType>
custom_id: Option<GlobalId>

The type of Datum::Map

Keys within the map are always of type ScalarType::String. Values within the map are of the specified type. Values may always be Datum::Null.

RegProc

A PostgreSQL function name.

RegType

A PostgreSQL type name.

RegClass

A PostgreSQL class name.

Int2Vector

A vector on small ints; this is a legacy type in PG used primarily in the catalog.

MzTimestamp

A Materialize timestamp.

Implementations

Returns the contained numeric maximum scale.

Panics

Panics if the scalar type is not ScalarType::Numeric.

Returns the ScalarType of elements in a ScalarType::List.

Panics

Panics if called on anything other than a ScalarType::List.

Returns the ScalarType of elements in the nth layer a ScalarType::List.

For example, in an int list list, the:

  • 0th layer is int list list
  • 1st layer is int list
  • 2nd layer is int
Panics

Panics if the nth-1 layer is anything other than a ScalarType::List.

Returns vector of ScalarType elements in a ScalarType::Record.

Panics

Panics if called on anything other than a ScalarType::Record.

Returns number of dimensions/axes (also known as “rank”) on a ScalarType::List.

Panics

Panics if called on anything other than a ScalarType::List.

Returns self with any type modifiers removed.

Namely, this should set optional scales or limits to None.

Returns the ScalarType of elements in a ScalarType::Array or the elements of a vector type, e.g. ScalarType::Int16 for ScalarType::Int2Vector.

Panics

Panics if called on anything other than a ScalarType::Array or ScalarType::Int2Vector.

Returns the ScalarType of elements in a ScalarType::Array, ScalarType::Int2Vector, or ScalarType::List.

Panics

Panics if called on anything other than a ScalarType::Array, ScalarType::Int2Vector, or ScalarType::List.

Returns the ScalarType of values in a ScalarType::Map.

Panics

Panics if called on anything other than a ScalarType::Map.

Returns the length of a ScalarType::Char.

Panics

Panics if called on anything other than a ScalarType::Char.

Returns the max length of a ScalarType::VarChar.

Panics

Panics if called on anything other than a ScalarType::VarChar.

Returns a “near match” of self, which are types that are implicitly castable from self and offer a means to leverage Materialize’s type system to achieve more reasonable approaches to unifying types.

However, it’s very important to not blithely accept the near_match, which can be suboptimal/unnecessary, e.g. in the case of an already homogeneous group.

The feature is preferrable in MZ, but unnecessary in PG because PG’s type system offers totally linear progression through the complexity of types. e.g. with numbers, there is a linear progression in the domain each can represent. However, MZ’s support for unsigned integers create a non-linear type system, i.e. while the magnitude of Int32 and UInt32’s domains are the same, they are not equal.

Without this feature, Materialize will:

  • Guess that a mixute of the same width of int and uint cannot be coerced to a homogeneous type.
  • Select the Float64 based version of common binary functions (e.g. =), which introduces an unexpected float cast to integer values.

Note that if adding any near matches besides unsigned ints, consider extending/generalizing how guess_best_common_type uses this function.

Derives a column type from this scalar type with the specified nullability.

Returns whether or not self is a vector-like type, i.e. ScalarType::Array, ScalarType::Int2Vector, or ScalarType::List, irrespective of its element type.

Determines equality among scalar types that acknowledges custom OIDs, but ignores other embedded values.

In most situations, you want to use base_eq rather than ScalarType’s implementation of Eq. base_eq expresses the semantics of direct type interoperability whereas Eq expresses an exact comparison between the values.

For instance, base_eq signals that e.g. two ScalarType::Numeric values can be added together, irrespective of their embedded scale. In contrast, two Numeric values with different scales are never Eq to one another.

Returns various interesting datums for a ScalarType (max, min, 0 values, etc.).

Returns all non-parameterized types and some versions of some parameterized types.

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
Converts to this type from the input type.
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
Adds names and types of the fields of the struct or enum to rti. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. 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
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. 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
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