Skip to main content

DataRow

Struct DataRow 

Source
pub struct DataRow {
    pub column_names: Arc<[Arc<str>]>,
    pub column_types: Arc<[DataTypeNode]>,
    pub values: Vec<Value>,
}
Available on crate feature sea-ql only.
Expand description

A dynamically-typed row returned by crate::query::DataRowCursor.

Column names are shared across all rows from the same cursor via Arc, making each row cheap to construct (one Arc clone + one Vec alloc).

§Example

let mut cursor = client
    .query("SELECT number, toString(number) AS s FROM system.numbers LIMIT 3")
    .fetch_rows()?;

while let Some(row) = cursor.next().await? {
    for (col, val) in row.column_names.iter().zip(&row.values) {
        println!("{col}: {val:?}");
    }
}

Fields§

§column_names: Arc<[Arc<str>]>

Column names in schema order, shared with all other rows from the same query.

§column_types: Arc<[DataTypeNode]>

ClickHouse data types in schema order, shared with all other rows from the same query.

§values: Vec<Value>

Per-column values decoded from RowBinaryWithNamesAndTypes.

Implementations§

Source§

impl DataRow

Source

pub fn try_get<T, I>(&self, idx: I) -> Result<T, TypeError>
where T: FromValue, I: ColumnIndex,

Extract column idx as type T.

idx can be a column name (&str) or a zero-based index (usize).

Numeric conversions are flexible: any integer or float column can be decoded into any compatible numeric type, with range-checked narrowing. Fractional floats are truncated when converting to integers. Option<T> decodes NULL as None instead of returning an error.

§Errors

Returns TypeError if the column is not found, the value is NULL (for non-Option targets), or the conversion is not possible / out of range.

§Examples
let id: i64 = row.try_get("id")?;
let name: String = row.try_get("name")?;
let score: Option<f64> = row.try_get(2)?;

Trait Implementations§

Source§

impl Clone for DataRow

Source§

fn clone(&self) -> DataRow

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 DataRow

Source§

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

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

impl PartialEq for DataRow

Source§

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

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serializes as a struct, emitting each value in column order.

None values are serialized as serialize_none() (nullable NULL). Some(v) values are serialized as the inner primitive (non-nullable style).

Limitation: nullable columns with non-null values will be missing the null flag byte. Use crate::Client::insert_data_row + [crate::insert::DataRowInsert::write_row] for correct handling of all nullable columns.

Source§

impl Row for DataRow

This is only to satisfy the trait bounds of insert.

Source§

impl StructuralPartialEq for DataRow

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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<S> Bind for S
where S: Serialize,

Source§

fn write(&self, dst: &mut impl Write) -> Result<(), String>

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> 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> Is for T
where T: ?Sized,

Source§

type EqTo = T

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> 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<R> RowOwned for R
where R: 'static + for<'a> Row<Value<'a> = R>,

Source§

impl<R> RowWrite for R
where R: for<'a> Row, <R as Row>::Value<'a>: for<'a> Serialize,