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<CatalogItemId>,
},
Record {
fields: Box<[(ColumnName, ColumnType)]>,
custom_id: Option<CatalogItemId>,
},
Oid,
Map {
value_type: Box<ScalarType>,
custom_id: Option<CatalogItemId>,
},
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
max_scale: Option<NumericMaxScale>
Date
The type of Datum::Date
.
Time
The type of Datum::Time
.
Timestamp
The type of Datum::Timestamp
.
Fields
precision: Option<TimestampPrecision>
TimestampTz
The type of Datum::TimestampTz
.
Fields
precision: Option<TimestampPrecision>
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
length: Option<CharLength>
VarChar
Stored as Datum::String
, but can optionally express a limit on the
string’s length.
Fields
max_length: Option<VarCharMaxLength>
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
.
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<CatalogItemId>
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
.
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
impl ScalarType
sourcepub fn unwrap_numeric_max_scale(&self) -> Option<NumericMaxScale>
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
.
sourcepub fn unwrap_timestamp_precision(&self) -> Option<TimestampPrecision>
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
.
sourcepub fn unwrap_list_element_type(&self) -> &ScalarType
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
.
sourcepub fn unwrap_list_nth_layer_type(&self, layer: usize) -> &ScalarType
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
.
sourcepub fn unwrap_record_element_type(&self) -> Vec<&ScalarType>
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
.
sourcepub fn unwrap_record_element_column_type(&self) -> Vec<&ColumnType>
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
.
sourcepub fn unwrap_list_n_layers(&self) -> usize
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
.
sourcepub fn without_modifiers(&self) -> ScalarType
pub fn without_modifiers(&self) -> ScalarType
Returns self
with any type modifiers removed.
Namely, this should set optional scales or limits to None
.
sourcepub fn unwrap_array_element_type(&self) -> &ScalarType
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
.
sourcepub fn unwrap_collection_element_type(&self) -> &ScalarType
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
.
sourcepub fn unwrap_map_value_type(&self) -> &ScalarType
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
.
sourcepub fn unwrap_char_length(&self) -> Option<CharLength>
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
.
sourcepub fn unwrap_varchar_max_length(&self) -> Option<VarCharMaxLength>
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
.
sourcepub fn unwrap_range_element_type(&self) -> &ScalarType
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
.
sourcepub fn near_match(&self) -> Option<&'static ScalarType>
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.
sourcepub const fn nullable(self, nullable: bool) -> ColumnType
pub const fn nullable(self, nullable: bool) -> ColumnType
Derives a column type from this scalar type with the specified nullability.
sourcepub fn is_vec(&self) -> bool
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.
pub fn is_custom_type(&self) -> bool
sourcepub fn base_eq(&self, other: &ScalarType) -> bool
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.
pub fn structural_eq(&self, other: &ScalarType) -> bool
pub fn eq_inner(&self, other: &ScalarType, structure_only: bool) -> bool
sourcepub fn interesting_datums(&self) -> impl Iterator<Item = Datum<'static>>
pub fn interesting_datums(&self) -> impl Iterator<Item = Datum<'static>>
Returns various interesting datums for a ScalarType (max, min, 0 values, etc.).
sourcepub fn enumerate() -> &'static [Self]
pub fn enumerate() -> &'static [Self]
Returns all non-parameterized types and some versions of some parameterized types.
sourcepub fn array_of_self_elem_type(self) -> Result<ScalarType, ScalarType>
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
impl Arbitrary for ScalarType
§type Parameters = ()
type Parameters = ()
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = BoxedStrategy<ScalarType>
type Strategy = BoxedStrategy<ScalarType>
Strategy
used to generate values of type Self
.source§fn arbitrary_with(_: Self::Parameters) -> Self::Strategy
fn arbitrary_with(_: Self::Parameters) -> Self::Strategy
source§impl Clone for ScalarType
impl Clone for ScalarType
source§fn clone(&self) -> ScalarType
fn clone(&self) -> ScalarType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ScalarType
impl Debug for ScalarType
source§impl<'de> Deserialize<'de> for ScalarType
impl<'de> Deserialize<'de> for ScalarType
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<'__enum_kinds1> From<&'__enum_kinds1 ScalarType> for ScalarBaseType
impl<'__enum_kinds1> From<&'__enum_kinds1 ScalarType> for ScalarBaseType
source§fn from(_value: &'__enum_kinds1 ScalarType) -> Self
fn from(_value: &'__enum_kinds1 ScalarType) -> Self
source§impl<'__enum_kinds1> From<ScalarType> for ScalarBaseType
impl<'__enum_kinds1> From<ScalarType> for ScalarBaseType
source§fn from(value: ScalarType) -> Self
fn from(value: ScalarType) -> Self
source§impl Hash for ScalarType
impl Hash for ScalarType
source§impl MzReflect for ScalarType
impl MzReflect for ScalarType
source§fn add_to_reflected_type_info(rti: &mut ReflectedTypeInfo)
fn add_to_reflected_type_info(rti: &mut ReflectedTypeInfo)
rti
. Read moresource§impl Ord for ScalarType
impl Ord for ScalarType
source§fn cmp(&self, other: &ScalarType) -> Ordering
fn cmp(&self, other: &ScalarType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for ScalarType
impl PartialEq for ScalarType
source§impl PartialOrd for ScalarType
impl PartialOrd for ScalarType
source§impl RustType<ProtoScalarType> for ScalarType
impl RustType<ProtoScalarType> for ScalarType
source§fn into_proto(&self) -> ProtoScalarType
fn into_proto(&self) -> ProtoScalarType
Self
into a Proto
value.source§fn from_proto(proto: ProtoScalarType) -> Result<Self, TryFromProtoError>
fn from_proto(proto: ProtoScalarType) -> Result<Self, TryFromProtoError>
source§fn into_proto_owned(self) -> Proto
fn into_proto_owned(self) -> Proto
Self::into_proto
that types can
optionally implement, otherwise, the default implementation
delegates to Self::into_proto
.source§impl Serialize for ScalarType
impl Serialize for ScalarType
impl Eq for ScalarType
impl StructuralPartialEq for ScalarType
Auto Trait Implementations§
impl Freeze for ScalarType
impl RefUnwindSafe for ScalarType
impl Send for ScalarType
impl Sync for ScalarType
impl Unpin for ScalarType
impl UnwindSafe for ScalarType
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> PreferredContainer for T
impl<T> PreferredContainer for T
source§impl<T> ProgressEventTimestamp for T
impl<T> ProgressEventTimestamp for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.