Skip to main content

DataType

Enum DataType 

Source
pub enum DataType {
Show 38 variants Boolean, TinyInt { length: Option<u32>, }, SmallInt { length: Option<u32>, }, Int { length: Option<u32>, integer_spelling: bool, }, BigInt { length: Option<u32>, }, Float { precision: Option<u32>, scale: Option<u32>, real_spelling: bool, }, Double { precision: Option<u32>, scale: Option<u32>, }, Decimal { precision: Option<u32>, scale: Option<u32>, }, Char { length: Option<u32>, }, VarChar { length: Option<u32>, parenthesized_length: bool, }, String { length: Option<u32>, }, Text, Binary { length: Option<u32>, }, VarBinary { length: Option<u32>, }, Blob, Bit { length: Option<u32>, }, VarBit { length: Option<u32>, }, Date, Time { precision: Option<u32>, timezone: bool, }, Timestamp { precision: Option<u32>, timezone: bool, }, Interval { unit: Option<String>, to: Option<String>, }, Json, JsonB, Uuid, Array { element_type: Box<DataType>, dimension: Option<u32>, }, List { element_type: Box<DataType>, }, Struct { fields: Vec<StructField>, nested: bool, }, Map { key_type: Box<DataType>, value_type: Box<DataType>, }, Enum { values: Vec<String>, assignments: Vec<Option<String>>, }, Set { values: Vec<String>, }, Union { fields: Vec<(String, DataType)>, }, Vector { element_type: Option<Box<DataType>>, dimension: Option<u32>, }, Object { fields: Vec<(String, DataType, bool)>, modifier: Option<String>, }, Custom { name: String, }, Geometry { subtype: Option<String>, srid: Option<u32>, }, Geography { subtype: Option<String>, srid: Option<u32>, }, CharacterSet { name: String, }, Unknown,
}
Expand description

Enumerate all SQL data types recognized by the parser.

Covers standard SQL types (BOOLEAN, INT, VARCHAR, TIMESTAMP, etc.) as well as dialect-specific types (JSONB, VECTOR, OBJECT, etc.). Parametric types like ARRAY, MAP, and STRUCT are represented with nested DataType fields.

This enum is used in CAST expressions, column definitions, function return types, and anywhere a data type specification appears in SQL.

Types that do not match any known variant fall through to Custom { name }, preserving the original type name for round-trip fidelity.

Variants§

§

Boolean

§

TinyInt

Fields

§length: Option<u32>
§

SmallInt

Fields

§length: Option<u32>
§

Int

Int type with optional length. integer_spelling indicates whether the original type was spelled as INTEGER (true) vs INT (false), used for certain dialects like Databricks that preserve the original spelling in specific contexts (e.g., ?:: syntax).

Fields

§length: Option<u32>
§integer_spelling: bool
§

BigInt

Fields

§length: Option<u32>
§

Float

Float type with optional precision and scale. real_spelling indicates whether the original type was spelled as REAL (true) vs FLOAT (false), used for dialects like Redshift that preserve the original spelling.

Fields

§precision: Option<u32>
§scale: Option<u32>
§real_spelling: bool
§

Double

Fields

§precision: Option<u32>
§scale: Option<u32>
§

Decimal

Fields

§precision: Option<u32>
§scale: Option<u32>
§

Char

Fields

§length: Option<u32>
§

VarChar

VarChar type with optional length. parenthesized_length indicates whether the length was wrapped in extra parentheses (Hive: VARCHAR((50)) inside STRUCT definitions).

Fields

§length: Option<u32>
§parenthesized_length: bool
§

String

String type with optional max length (BigQuery STRING(n))

Fields

§length: Option<u32>
§

Text

§

Binary

Fields

§length: Option<u32>
§

VarBinary

Fields

§length: Option<u32>
§

Blob

§

Bit

Fields

§length: Option<u32>
§

VarBit

Fields

§length: Option<u32>
§

Date

§

Time

Fields

§precision: Option<u32>
§timezone: bool
§

Timestamp

Fields

§precision: Option<u32>
§timezone: bool
§

Interval

Fields

§to: Option<String>

For range intervals like INTERVAL DAY TO HOUR

§

Json

§

JsonB

§

Uuid

§

Array

Fields

§element_type: Box<DataType>
§dimension: Option<u32>

Optional dimension size for PostgreSQL (e.g., [3] in INT[3])

§

List

List type (Materialize): INT LIST, TEXT LIST LIST Uses postfix LIST syntax instead of ARRAY

Fields

§element_type: Box<DataType>
§

Struct

Fields

§nested: bool
§

Map

Fields

§key_type: Box<DataType>
§value_type: Box<DataType>
§

Enum

Fields

§values: Vec<String>
§assignments: Vec<Option<String>>
§

Set

Fields

§values: Vec<String>
§

Union

Fields

§fields: Vec<(String, DataType)>
§

Vector

Fields

§element_type: Option<Box<DataType>>
§dimension: Option<u32>
§

Object

Fields

§fields: Vec<(String, DataType, bool)>
§modifier: Option<String>
§

Custom

Fields

§name: String
§

Geometry

Fields

§subtype: Option<String>
§srid: Option<u32>
§

Geography

Fields

§subtype: Option<String>
§srid: Option<u32>
§

CharacterSet

Fields

§name: String
§

Unknown

Trait Implementations§

Source§

impl Clone for DataType

Source§

fn clone(&self) -> DataType

Returns a duplicate 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 DataType

Source§

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

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

impl<'de> Deserialize<'de> for DataType

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 PartialEq for DataType

Source§

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

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 StructuralPartialEq for DataType

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

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

Source§

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

Source§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,