SqlType

Enum SqlType 

Source
pub enum SqlType {
Show 22 variants Bool, Int32, Int64, Uint32, Uint64, Float32, Float64, Numeric { precision: Option<u8>, scale: Option<u8>, }, Varchar, Varbinary, Date, Time, Datetime, Timestamp, Interval, Array(Box<SqlType>), Struct(Vec<StructField>), Json, Range(Box<SqlType>), Uuid, Unknown, Any,
}
Expand description

A SQL data type used during semantic analysis.

Type names follow ISO SQL standards:

  • Int32 displays as “INTEGER”
  • Int64 displays as “BIGINT”
  • Float32 displays as “REAL”
  • Float64 displays as “DOUBLE PRECISION”
  • Varchar displays as “VARCHAR”
  • Varbinary displays as “VARBINARY”

Variants§

§

Bool

Boolean type (BOOLEAN)

§

Int32

32-bit signed integer (INTEGER)

§

Int64

64-bit signed integer (BIGINT)

§

Uint32

32-bit unsigned integer (UINTEGER) - extension

§

Uint64

64-bit unsigned integer (UBIGINT) - extension

§

Float32

32-bit floating point (REAL)

§

Float64

64-bit floating point (DOUBLE PRECISION)

§

Numeric

Fixed-precision decimal (NUMERIC/DECIMAL)

Fields

§precision: Option<u8>
§scale: Option<u8>
§

Varchar

Variable-length character string (VARCHAR)

§

Varbinary

Variable-length binary data (VARBINARY)

§

Date

Date (year, month, day)

§

Time

Time of day

§

Datetime

Date and time without timezone (TIMESTAMP WITHOUT TIME ZONE)

§

Timestamp

Date and time with timezone (TIMESTAMP WITH TIME ZONE)

§

Interval

Time interval

§

Array(Box<SqlType>)

Array of elements

§

Struct(Vec<StructField>)

Struct with named fields (ROW type in standard SQL)

§

Json

JSON data

§

Range(Box<SqlType>)

Range of values

§

Uuid

Universally unique identifier (UUID)

§

Unknown

Unknown type (for unresolved expressions)

§

Any

Any type (for polymorphic functions)

Implementations§

Source§

impl SqlType

Source

pub fn is_numeric(&self) -> bool

Check if this type is numeric.

Source

pub fn is_integer(&self) -> bool

Check if this type is an integer type (signed or unsigned).

Source

pub fn is_signed_integer(&self) -> bool

Check if this type is a signed integer type.

Source

pub fn is_unsigned_integer(&self) -> bool

Check if this type is an unsigned integer type.

Source

pub fn is_floating_point(&self) -> bool

Check if this type is a floating-point type.

Source

pub fn is_string(&self) -> bool

Check if this type is a string type.

Source

pub fn is_datetime(&self) -> bool

Check if this type is a date/time type.

Source

pub fn is_comparable_with(&self, other: &SqlType) -> bool

Check if this type is comparable with another type.

Source

pub fn can_coerce_to(&self, target: &SqlType) -> bool

Check if this type can be implicitly coerced to another type.

Source

pub fn common_supertype(&self, other: &SqlType) -> Option<SqlType>

Get the common supertype of two types.

Source

pub fn element_type(&self) -> Option<&SqlType>

Get the element type if this is an array.

Source

pub fn struct_fields(&self) -> Option<&[StructField]>

Get struct fields if this is a struct.

Trait Implementations§

Source§

impl Clone for SqlType

Source§

fn clone(&self) -> SqlType

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 SqlType

Source§

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

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

impl Display for SqlType

Source§

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

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

impl Hash for SqlType

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

Source§

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

Source§

impl StructuralPartialEq for SqlType

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.