Rust

clickhouse

Module

ClickHouse: ClickHouse, its bulk-insert Formats and FormattedInsertStatement, and the ASOF join AsofOperator.

ClickHouse extends the base builder directly (not the SQL dialects): it adds PREWHERE, FINAL, SAMPLE, ARRAY JOIN, ASOF JOIN, LIMIT ... BY, WITH FILL, SETTINGS, the -If conditional aggregates, the approximate aggregates (quantile, uniq, topK, ...), mutations (ALTER TABLE ... UPDATE / DELETE), FORMAT inserts and named, typed placeholders ({param0:Int64}).

Contents

use utopia_query::builder::clickhouse::ClickHouseDialect;
Rust
pub struct ClickHouseDialect

The ClickHouse dialect and its own state.

use utopia_query::builder::clickhouse::FormattedInsertStatement;
Rust
pub struct FormattedInsertStatement

An INSERT INTO table [(columns)] FORMAT name envelope (no bindings), with the format, the columns and, from Builder::bulk_insert, the serialized rows to send with it.

It is a Statement (it derefs to one) with three more fields.

Also implements Deref.
use utopia_query::builder::clickhouse::DeleteMode;
Rust
pub enum DeleteMode

Which DELETE form Builder::delete emits.

Rust
pub type ClickHouse = Builder<ClickHouseDialect>

A ClickHouse builder.

Rust
use utopia_query::Query;
use utopia_query::builder::ClickHouse;

let statement = ClickHouse::new()
    .from("events", "")
    .final_()
    .sample(0.1)?
    .prewhere([Query::equal("type", ["click"])])
    .filter([Query::greater_than("count", 5)])
    .build()?;
assert_eq!(
    statement.query,
    "SELECT * FROM `events` FINAL SAMPLE 0.1 PREWHERE `type` IN (?) WHERE `count` > ?"
);