CreateOptions

Struct CreateOptions 

Source
pub struct CreateOptions {
    pub engine: String,
    pub order_by: Vec<String>,
    pub primary_keys: Vec<String>,
    pub partition_by: Option<String>,
    pub sampling: Option<String>,
    pub settings: Settings,
    pub ttl: Option<String>,
    pub schema_conversions: Option<SchemaConversions>,
    pub defaults: Option<HashMap<String, String>>,
    pub defaults_for_nullable: bool,
}
Expand description

Options for creating a ClickHouse table, specifying engine, ordering, partitioning, and other settings.

This struct is used to configure the creation of a ClickHouse table via create_table_statement_from_arrow. It supports common table options like ORDER BY, PRIMARY KEY, PARTITION BY, SAMPLE BY, TTL, and custom settings. It also allows specifying default values for columns and enabling defaults for nullable columns.

§Examples

use clickhouse_arrow::sql::CreateOptions;
use clickhouse_arrow::Settings;

let options = CreateOptions::new("MergeTree")
    .with_order_by(&["id".to_string()])
    .with_setting("index_granularity", 4096)
    .with_ttl("1 DAY");

Fields§

§engine: String§order_by: Vec<String>§primary_keys: Vec<String>§partition_by: Option<String>§sampling: Option<String>§settings: Settings§ttl: Option<String>§schema_conversions: Option<SchemaConversions>§defaults: Option<HashMap<String, String>>§defaults_for_nullable: bool

Implementations§

Source§

impl CreateOptions

Source

pub fn new(engine: impl Into<String>) -> Self

Creates a new CreateOptions with the specified engine.

§Arguments
  • engine: The ClickHouse table engine (e.g., MergeTree, Memory).
§Returns

A new CreateOptions instance with the specified engine.

Source

pub fn from_engine(engine: impl Into<ClickHouseEngine>) -> Self

Creates a new CreateOptions with the specified engine.

§Arguments
  • engine: The ClickHouseEngine .
§Returns

A new CreateOptions instance with the specified engine.

Source

pub fn with_order_by(self, order_by: &[String]) -> Self

Sets the ORDER BY clause for the table.

Filters out empty strings from the provided list.

§Arguments
  • order_by: A slice of column names to order by.
§Returns

Self for method chaining.

Source

pub fn with_primary_keys(self, keys: &[String]) -> Self

Sets the PRIMARY KEY clause for the table.

Filters out empty strings from the provided list.

§Arguments
  • keys: A slice of column names to use as primary keys.
§Returns

Self for method chaining.

Source

pub fn with_partition_by(self, partition_by: impl Into<String>) -> Self

Sets the PARTITION BY clause for the table.

Ignores empty strings.

§Arguments
  • partition_by: The partitioning expression.
§Returns

Self for method chaining.

Source

pub fn with_sample_by(self, sampling: impl Into<String>) -> Self

Sets the SAMPLE BY clause for the table.

Ignores empty strings.

§Arguments
  • sampling: The sampling expression.
§Returns

Self for method chaining.

Source

pub fn with_settings(self, settings: Settings) -> Self

Sets the table settings.

§Arguments
  • settings: The Settings object containing key-value pairs.
§Returns

Self for method chaining.

Source

pub fn with_ttl(self, ttl: impl Into<String>) -> Self

Sets the TTL clause for the table.

Ignores empty strings.

§Arguments
  • ttl: The TTL expression (e.g., 1 DAY).
§Returns

Self for method chaining.

Source

pub fn with_setting<S>(self, name: impl Into<String>, setting: S) -> Self
where SettingValue: From<S>,

Adds a single setting to the table.

§Arguments
  • name: The setting name (e.g., index_granularity).
  • setting: The setting value (e.g., 4096).
§Returns

Self for method chaining.

Source

pub fn with_defaults<I>(self, defaults: I) -> Self
where I: Iterator<Item = (String, String)>,

Sets default values for columns.

§Arguments
  • defaults: An iterator of (column name, default value) pairs.
§Returns

Self for method chaining.

Source

pub fn with_defaults_for_nullable(self) -> Self

Enables default values for nullable columns (e.g., NULL).

§Returns

Self for method chaining.

Source

pub fn with_schema_conversions(self, map: SchemaConversions) -> Self

Provide a map of resolved type conversions.

For example, since arrow does not support enum types, providing a map of column name to Type::Enum8 with enum values ensures arrow::datatypes::DataType::Dictionary is serialized as crate::Type::Enum16 instead of the default crate::Type::LowCardinality

§Returns

Self for method chaining.

Source

pub fn defaults(&self) -> Option<&HashMap<String, String>>

Returns the configured default values, if any.

§Returns

An optional reference to the HashMap of column names to default values.

Source

pub fn schema_conversions(&self) -> Option<&SchemaConversions>

Returns the configured default values, if any.

§Returns

An optional reference to the HashMap of column names to default values.

Trait Implementations§

Source§

impl Clone for CreateOptions

Source§

fn clone(&self) -> CreateOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CreateOptions

Source§

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

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

impl Default for CreateOptions

Source§

fn default() -> CreateOptions

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

impl<'de> Deserialize<'de> for CreateOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CreateOptions

Source§

fn eq(&self, other: &CreateOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CreateOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CreateOptions

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,