pub struct DataRow {
pub column_names: Arc<[Arc<str>]>,
pub column_types: Arc<[DataTypeNode]>,
pub values: Vec<Value>,
}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
impl DataRow
Sourcepub fn try_get<T, I>(&self, idx: I) -> Result<T, TypeError>where
T: FromValue,
I: ColumnIndex,
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 Serialize for DataRow
impl Serialize for DataRow
Source§fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
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.
impl Row for DataRow
This is only to satisfy the trait bounds of insert.