Skip to main content

Crate ytsaurus_helpers

Crate ytsaurus_helpers 

Source
Expand description

Derive macros for ytsaurus-client.

A job’s rows are already described by a Rust struct. A table schema describes the same thing to the cluster, so writing it out again by hand is a chance to disagree with yourself. TableRow reads the struct.

use ytsaurus_client::TableRow;

#[derive(TableRow)]
struct Visit<'a> {
    #[yt(key)]
    host: &'a str,               // utf8, required, sorted
    size: i64,                   // int64, required
    referrer: Option<&'a str>,   // utf8, optional — the Rust type says so
}

client.create_table("//tmp/visits", &Visit::table_schema())?;

Nothing here runs on a cluster: a procedural-macro crate is loaded by the compiler and contributes nothing to the binary a worker ships.

Derive Macros§

TableRow
Derives a YTsaurus table schema from a struct’s fields.