Skip to main content

ClickHouse

Struct ClickHouse 

Source
pub struct ClickHouse { /* private fields */ }
Expand description

The ClickHouse schema: backtick quoting, Nullable(...) / LowCardinality(...) wrapping, engines with ORDER BY, PARTITION BY, SAMPLE BY, TTL and SETTINGS, data-skipping indexes, codecs and materialized views.

use utopia_query::schema::{ClickHouse, Engine, Schema};

let mut table = ClickHouse::new().table("events");
table.big_integer("id").unsigned().primary();
table.string("country", 255).low_cardinality();
table.datetime("at", 3);
table.engine(Engine::MergeTree, &[])?.partition_by("toYYYYMM(at)");
assert_eq!(
    table.create()?.query,
    "CREATE TABLE `events` (`id` UInt64, `country` LowCardinality(String), `at` DateTime64(3)) \
     ENGINE = MergeTree() PARTITION BY toYYYYMM(at) ORDER BY (`id`)"
);
use Utopia\Query\Schema\ClickHouse;
use Utopia\Query\Schema\ClickHouse\Engine;

$table = (new ClickHouse())->table('events');
$table->bigInteger('id')->unsigned()->primary();
$table->string('country')->lowCardinality();
$table->datetime('at', 3);
$table->engine(Engine::MergeTree)->partitionBy('toYYYYMM(at)');
echo $table->create()->query, "\n";

PHP: Utopia\Query\Schema\ClickHouse.

Implementations§

Source§

impl ClickHouse

Source

pub fn new() -> Self

A ClickHouse schema without an executor.

PHP: new ClickHouse().

Trait Implementations§

Source§

impl Clone for ClickHouse

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ColumnAlterations for ClickHouse

Source§

impl ColumnComments for ClickHouse

Source§

fn comment_on_column( &self, table: &str, column: &str, comment: &str, ) -> Result<Statement>

Sets the comment of column of table. Read more
Source§

impl Comment for ClickHouse

Source§

impl CompositePrimary for ClickHouse

Source§

impl Databases for ClickHouse

Source§

fn create_database(&self, name: &str) -> Result<Statement>

Creates database name. Read more
Source§

fn drop_database(&self, name: &str) -> Result<Statement>

Drops database name. Read more
Source§

impl Debug for ClickHouse

Source§

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

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

impl Default for ClickHouse

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl DropPartition for ClickHouse

Source§

fn drop_partition(&self, table: &str, name: &str) -> Result<Statement>

Drops partition name of table. Read more
Source§

impl MaterializedViews for ClickHouse

Source§

fn create_materialized_view( &self, name: &str, body: ViewBody<'_>, target_table: Option<&str>, if_not_exists: bool, ) -> Result<Statement>

CREATE MATERIALIZED VIEW [IF NOT EXISTS] name [TO target] AS body (PHP’s default for if_not_exists is true). Read more
Source§

fn drop_materialized_view( &self, name: &str, if_exists: bool, ) -> Result<Statement>

Drops materialized view name (PHP’s default for if_exists is true). Read more
Source§

impl Schema for ClickHouse

Source§

fn compile_column_definition(&self, column: &Column<Self>) -> Result<String>

Name, type, default, codecs, TTL and comment.

Source§

fn compile_alter(&self, table: &Table<Self>) -> Result<Statement>

Columns, renames, drops and data-skipping indexes; settings cannot change here.

Source§

fn compile_create( &self, table: &Table<Self>, if_not_exists: bool, ) -> Result<Statement>

Columns and skip indexes, then ENGINE, PARTITION BY, ORDER BY (the primary key when unset), SAMPLE BY, TTL and SETTINGS.

Source§

fn executor(&self) -> Option<&Executor>

The executor statements carry, if any.
Source§

fn set_executor(&mut self, executor: Executor) -> &mut Self

Sets the executor every statement compiled from now on carries (Statement::execute runs it). Read more
Source§

fn literal(&self) -> StringLiteral

How the dialect writes a string literal: comments, defaults and enum values are inlined, since DDL takes no bound parameters. Read more
Source§

fn quote(&self, identifier: &str) -> Result<String>

Quotes a possibly qualified identifier. Read more
Source§

fn quote_literal(&self, identifier: &str) -> Result<String>

Quotes one identifier, dots included. Read more
Source§

fn compile_column_type(&self, column: &Column<Self>) -> Result<String>

The SQL type of column. Read more
Source§

fn compile_auto_increment(&self) -> &'static str

The auto-increment keyword. Read more
Source§

fn compile_unsigned(&self) -> &'static str

The unsigned keyword, or empty where there is none. Read more
Source§

fn drop_index(&self, table: &str, name: &str) -> Result<Statement>

Drops index name of table. Read more
Source§

fn table(&self, name: impl Into<String>) -> Table<Self>

A blueprint of table name compiled by this schema. Read more
Source§

fn compile_drop(&self, name: &str, if_exists: bool) -> Result<Statement>

DROP TABLE [IF EXISTS] name. Read more
Source§

fn compile_rename(&self, from: &str, to: &str) -> Result<Statement>

Renames table from to to. Read more
Source§

fn compile_truncate(&self, name: &str) -> Result<Statement>

Empties table name. Read more
Source§

fn create_index( &self, table: &str, name: &str, columns: &[&str], options: &IndexOptions, ) -> Result<Statement>

CREATE INDEX name ON table (columns) with options. Read more
Source§

fn compile_generated_clause(&self, column: &Column<Self>) -> String

GENERATED ALWAYS AS (...) STORED|VIRTUAL. Read more
Source§

fn compile_create_suffix(&self, _table: &Table<Self>) -> String

Clauses after the column list of CREATE TABLE (partitioning). Read more
Source§

fn quote_collation(&self, collation: &str) -> Result<String>

A collation name as COLLATE takes it. Read more
Source§

fn compile_index_columns(&self, index: &Index) -> Result<String>

The column list of an index: lengths, collations, operator class, orders and raw expressions. Read more
Source§

impl TableComments for ClickHouse

Source§

fn comment_on_table(&self, table: &str, comment: &str) -> Result<Statement>

Sets the comment of table. Read more
Source§

impl Views for ClickHouse

Source§

fn create_view( &self, name: &str, query: &mut dyn AnyBuilder, ) -> Result<Statement>

Creates view name of the query query builds (its bindings ride along). Read more
Source§

fn drop_view(&self, name: &str) -> Result<Statement>

Drops view name. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for ClickHouse

§

impl !UnwindSafe for ClickHouse

§

impl Forget for ClickHouse

§

impl Freeze for ClickHouse
where *const ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>>: Freeze,

§

impl Move for ClickHouse

§

impl Send for ClickHouse
where Arc<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>: Send,

§

impl Sync for ClickHouse
where Arc<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>: Sync,

§

impl Unpin for ClickHouse
where Arc<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>: Unpin,

§

impl UnsafeUnpin for ClickHouse
where *const ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>>: UnsafeUnpin,

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<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, 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> Same for T

Source§

type Output = T

Should always be Self
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.