pub struct ColumnType {
pub typ: SqlType,
pub nullable: bool,
pub precision: Option<i64>,
pub scale: Option<i64>,
pub component: Option<Box<ColumnType>>,
pub fields: Option<Vec<Field>>,
pub key: Option<Box<ColumnType>>,
pub value: Option<Box<ColumnType>>,
}Expand description
A SQL column type description.
Matches the Calcite JSON format.
Fields§
§typ: SqlTypeIdentifier for the type (e.g., VARCHAR, BIGINT, ARRAY etc.)
nullable: boolDoes the type accept NULL values?
precision: Option<i64>Precision of the type.
§Examples
VARCHARsets precision to-1.VARCHAR(255)sets precision to255.BIGINT,DATE,FLOAT,DOUBLE,GEOMETRY, etc. sets precision to NoneTIME,TIMESTAMPset precision to0.
scale: Option<i64>§component: Option<Box<ColumnType>>A component of the type (if available).
This is in a Box because it makes it a recursive types.
For example, this would specify the VARCHAR(20) in the VARCHAR(20) ARRAY type.
fields: Option<Vec<Field>>The fields of the type (if available).
For example this would specify the fields of a CREATE TYPE construct.
CREATE TYPE person_typ AS (
firstname VARCHAR(30),
lastname VARCHAR(30),
address ADDRESS_TYP
);Would lead to the following fields value:
[
ColumnType { name: "firstname, ... },
ColumnType { name: "lastname", ... },
ColumnType { name: "address", fields: [ ... ] }
]key: Option<Box<ColumnType>>Key type; must be set when type == "MAP".
value: Option<Box<ColumnType>>Value type; must be set when type == "MAP".
Implementations§
Source§impl ColumnType
impl ColumnType
pub fn boolean(nullable: bool) -> Self
pub fn tinyint(nullable: bool) -> Self
pub fn smallint(nullable: bool) -> Self
pub fn int(nullable: bool) -> Self
pub fn bigint(nullable: bool) -> Self
pub fn double(nullable: bool) -> Self
pub fn real(nullable: bool) -> Self
pub fn decimal(precision: i64, scale: i64, nullable: bool) -> Self
pub fn varchar(nullable: bool) -> Self
pub fn varbinary(nullable: bool) -> Self
pub fn fixed(width: i64, nullable: bool) -> Self
pub fn date(nullable: bool) -> Self
pub fn time(nullable: bool) -> Self
pub fn timestamp(nullable: bool) -> Self
pub fn variant(nullable: bool) -> Self
pub fn array(nullable: bool, element: ColumnType) -> Self
pub fn structure(nullable: bool, fields: &[Field]) -> Self
pub fn map(nullable: bool, key: ColumnType, val: ColumnType) -> Self
pub fn is_integral_type(&self) -> bool
pub fn is_fp_type(&self) -> bool
pub fn is_decimal_type(&self) -> bool
pub fn is_numeric_type(&self) -> bool
Trait Implementations§
Source§impl Clone for ColumnType
impl Clone for ColumnType
Source§fn clone(&self) -> ColumnType
fn clone(&self) -> ColumnType
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ColumnType
impl Debug for ColumnType
Source§impl<'de> Deserialize<'de> for ColumnType
impl<'de> Deserialize<'de> for ColumnType
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ColumnType
impl PartialEq for ColumnType
Source§impl Serialize for ColumnType
impl Serialize for ColumnType
Source§impl<'__s> ToSchema<'__s> for ColumnType
impl<'__s> ToSchema<'__s> for ColumnType
impl Eq for ColumnType
impl StructuralPartialEq for ColumnType
Auto Trait Implementations§
impl Freeze for ColumnType
impl RefUnwindSafe for ColumnType
impl Send for ColumnType
impl Sync for ColumnType
impl Unpin for ColumnType
impl UnwindSafe for ColumnType
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.