#[derive(TableRow)]
{
// Attributes available to this derive:
#[yt]
}
Expand description
Derives a YTsaurus table schema from a struct’s fields.
One column per field, in declaration order, named after the field. The
Rust type decides the column type, and Option<T> is the only thing that
makes a column optional — a bare T is required.
| Rust | column type |
|---|---|
i8 i16 i32 i64 | int8 … int64 |
u8 u16 u32 u64 | uint8 … uint64 |
f32 / f64 | float / double |
bool | boolean |
String, &str, Cow<str> | utf8 |
Vec<u8>, &[u8] | string — YTsaurus strings are arbitrary bytes |
YsonValue | any |
Option<T> | T, not required |
Anything else is a compile error naming the field: guessing a column type
from an unknown Rust type is how a schema comes to disagree with the data.
Say what you mean with #[yt(column_type = "…")].
§Attributes
On the struct:
#[yt(non_strict)]— let rows carry columns the schema does not mention.#[yt(unique_keys)]— promise no two rows share a key. Requires a key.#[yt(crate_path = "::path::to::ytsaurus_client")]— for a renamed dependency.
On a field:
#[yt(key)]— a key column, sorted ascending. Key fields must come first: the cluster refuses a schema whose keys are not a prefix, so the macro refuses it earlier and names the field.#[yt(name = "…")]— the column name, when it differs from the field’s.#[yt(column_type = "…")]— the column type, by its wire name.#[yt(skip)]— not a column at all.
§Example
ⓘ
#[derive(TableRow)]
#[yt(unique_keys)]
struct Session {
#[yt(key)]
user_id: i64,
#[yt(key)]
started_at: i64,
#[yt(name = "duration_s")]
duration: i64,
#[yt(column_type = "any")]
details: ytsaurus_client::yson_build::YsonValue,
#[yt(skip)]
cached: usize,
}