Enum mz_repr::ScalarType

source ·
pub enum ScalarType {
Show 36 variants Bool, Int16, Int32, Int64, UInt16, UInt32, UInt64, Float32, Float64, Numeric { max_scale: Option<NumericMaxScale>, }, Date, Time, Timestamp { precision: Option<TimestampPrecision>, }, TimestampTz { precision: Option<TimestampPrecision>, }, Interval, PgLegacyChar, PgLegacyName, 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: Box<[(ColumnName, ColumnType)]>, custom_id: Option<GlobalId>, }, Oid, Map { value_type: Box<ScalarType>, custom_id: Option<GlobalId>, }, RegProc, RegType, RegClass, Int2Vector, MzTimestamp, Range { element_type: Box<ScalarType>, }, MzAclItem, AclItem,
}
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

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.

Fields

§

Date

The type of Datum::Date.

§

Time

The type of Datum::Time.

§

Timestamp

The type of Datum::Timestamp.

Fields

§

TimestampTz

The type of Datum::TimestampTz.

Fields

§

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.

§

PgLegacyName

A character type for storing identifiers of no more than 64 characters in length.

PostgreSQL uses this type to represent the names of objects in the system catalog.

§

Bytes

The type of Datum::Bytes.

§

String

The type of Datum::String.

§

Char

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.

Fields

§

VarChar

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

Fields

§

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

The type of Datum::List.

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

Fields

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

Record

An ordered and named sequence of datums.

Fields

§fields: Box<[(ColumnName, ColumnType)]>

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

Boxed slice to reduce the size of the enum variant.

§custom_id: Option<GlobalId>
§

Oid

A PostgreSQL object identifier.

§

Map

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.

Fields

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

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. The type of Datum::MzTimestamp.

§

Range

Fields

§element_type: Box<ScalarType>
§

MzAclItem

The type of Datum::MzAclItem

§

AclItem

The type of Datum::AclItem

Implementations§

source§

impl ScalarType

source

pub fn unwrap_numeric_max_scale(&self) -> Option<NumericMaxScale>

Returns the contained numeric maximum scale.

§Panics

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

source

pub fn unwrap_timestamp_precision(&self) -> Option<TimestampPrecision>

Returns the contained timestamp precision.

§Panics

Panics if the scalar type is not ScalarType::Timestamp or ScalarType::TimestampTz.

source

pub fn unwrap_list_element_type(&self) -> &ScalarType

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

§Panics

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

source

pub fn unwrap_list_nth_layer_type(&self, layer: usize) -> &ScalarType

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.

source

pub fn unwrap_record_element_type(&self) -> Vec<&ScalarType>

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

§Panics

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

source

pub fn unwrap_record_element_column_type(&self) -> Vec<&ColumnType>

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

§Panics

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

source

pub fn unwrap_list_n_layers(&self) -> usize

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

§Panics

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

source

pub fn without_modifiers(&self) -> ScalarType

Returns self with any type modifiers removed.

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

source

pub fn unwrap_array_element_type(&self) -> &ScalarType

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.

source

pub fn unwrap_collection_element_type(&self) -> &ScalarType

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.

source

pub fn unwrap_map_value_type(&self) -> &ScalarType

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

§Panics

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

source

pub fn unwrap_char_length(&self) -> Option<CharLength>

Returns the length of a ScalarType::Char.

§Panics

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

source

pub fn unwrap_varchar_max_length(&self) -> Option<VarCharMaxLength>

Returns the max length of a ScalarType::VarChar.

§Panics

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

source

pub fn unwrap_range_element_type(&self) -> &ScalarType

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

§Panics

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

source

pub fn near_match(&self) -> Option<&'static ScalarType>

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.

source

pub const fn nullable(self, nullable: bool) -> ColumnType

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

source

pub fn is_vec(&self) -> bool

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

source

pub fn is_custom_type(&self) -> bool

source

pub fn base_eq(&self, other: &ScalarType) -> bool

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.

source

pub fn structural_eq(&self, other: &ScalarType) -> bool

source

pub fn eq_inner(&self, other: &ScalarType, structure_only: bool) -> bool

source

pub fn interesting_datums(&self) -> impl Iterator<Item = Datum<'static>>

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

source

pub fn enumerate() -> &'static [Self]

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

source

pub fn array_of_self_elem_type(self) -> Result<ScalarType, ScalarType>

Returns the appropriate element type for making a ScalarType::Array whose elements are of self.

If the type is not compatible with making an array, returns in the error position.

Trait Implementations§

source§

impl Arbitrary for ScalarType

§

type Parameters = ()

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

type Strategy = BoxedStrategy<ScalarType>

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

fn arbitrary_with(_: 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 ScalarType

source§

fn clone(&self) -> ScalarType

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 ScalarType

source§

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

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

impl<'de> Deserialize<'de> for ScalarType

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<'__enum_kinds1> From<&'__enum_kinds1 ScalarType> for ScalarBaseType

source§

fn from(_value: &'__enum_kinds1 ScalarType) -> Self

Converts to this type from the input type.
source§

impl<'__enum_kinds1> From<ScalarType> for ScalarBaseType

source§

fn from(value: ScalarType) -> Self

Converts to this type from the input type.
source§

impl Hash for ScalarType

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 MzReflect for ScalarType

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 Ord for ScalarType

source§

fn cmp(&self, other: &ScalarType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for ScalarType

source§

fn eq(&self, other: &ScalarType) -> 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 PartialOrd for ScalarType

source§

fn partial_cmp(&self, other: &ScalarType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl RustType<ProtoScalarType> for ScalarType

source§

fn into_proto(&self) -> ProtoScalarType

Convert a Self into a Proto value.
source§

fn from_proto(proto: ProtoScalarType) -> 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 Serialize for ScalarType

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 ScalarType

source§

impl StructuralPartialEq for ScalarType

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§

default 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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
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,

§

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

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> PreferredContainer for T
where T: Ord + Clone + 'static,

§

type Container = Vec<T>

The preferred container for the type.
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

§

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,

§

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<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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> Data for T
where T: Data + Ord + Debug,

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> ExchangeData for T
where T: ExchangeData + Ord + Debug,

source§

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