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
impl ClickHouse
Trait Implementations§
Source§impl Clone for ClickHouse
impl Clone for ClickHouse
impl ColumnAlterations for ClickHouse
Source§impl ColumnComments for ClickHouse
impl ColumnComments for ClickHouse
impl Comment for ClickHouse
impl CompositePrimary for ClickHouse
Source§impl Databases for ClickHouse
impl Databases for ClickHouse
Source§impl Debug for ClickHouse
impl Debug for ClickHouse
Source§impl Default for ClickHouse
impl Default for ClickHouse
Source§impl DropPartition for ClickHouse
impl DropPartition for ClickHouse
Source§impl MaterializedViews for ClickHouse
impl MaterializedViews for ClickHouse
Source§impl Schema for ClickHouse
impl Schema for ClickHouse
Source§fn compile_column_definition(&self, column: &Column<Self>) -> Result<String>
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>
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>
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 set_executor(&mut self, executor: Executor) -> &mut Self
fn set_executor(&mut self, executor: Executor) -> &mut Self
Sets the executor every statement compiled from now on carries
(
Statement::execute runs it). Read moreSource§fn literal(&self) -> StringLiteral
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>
fn quote(&self, identifier: &str) -> Result<String>
Quotes a possibly qualified identifier. Read more
Source§fn quote_literal(&self, identifier: &str) -> Result<String>
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>
fn compile_column_type(&self, column: &Column<Self>) -> Result<String>
The SQL type of
column. Read moreSource§fn compile_auto_increment(&self) -> &'static str
fn compile_auto_increment(&self) -> &'static str
The auto-increment keyword. Read more
Source§fn compile_unsigned(&self) -> &'static str
fn compile_unsigned(&self) -> &'static str
The unsigned keyword, or empty where there is none. Read more
Source§fn table(&self, name: impl Into<String>) -> Table<Self>
fn table(&self, name: impl Into<String>) -> Table<Self>
A blueprint of table
name compiled by this schema. Read moreSource§fn compile_drop(&self, name: &str, if_exists: bool) -> Result<Statement>
fn compile_drop(&self, name: &str, if_exists: bool) -> Result<Statement>
DROP TABLE [IF EXISTS] name. Read moreSource§fn create_index(
&self,
table: &str,
name: &str,
columns: &[&str],
options: &IndexOptions,
) -> Result<Statement>
fn create_index( &self, table: &str, name: &str, columns: &[&str], options: &IndexOptions, ) -> Result<Statement>
Source§fn compile_generated_clause(&self, column: &Column<Self>) -> String
fn compile_generated_clause(&self, column: &Column<Self>) -> String
GENERATED ALWAYS AS (...) STORED|VIRTUAL. Read moreSource§fn compile_create_suffix(&self, _table: &Table<Self>) -> String
fn compile_create_suffix(&self, _table: &Table<Self>) -> String
Clauses after the column list of
CREATE TABLE (partitioning). Read moreSource§impl TableComments for ClickHouse
impl TableComments for ClickHouse
Auto Trait Implementations§
impl !RefUnwindSafe for ClickHouse
impl !UnwindSafe for ClickHouse
impl Forget for ClickHouse
impl Freeze for ClickHouse
impl Move for ClickHouse
impl Send for ClickHouse
impl Sync for ClickHouse
impl Unpin for ClickHouse
impl UnsafeUnpin for ClickHouse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more