pub struct ClickHouseCatalogBuilder { /* private fields */ }
Expand description
ClickHouseCatalogBuilder
can be used to create tables, register existing tables, and finally
refresh the ClickHouse
catalog in DataFusion
.
IMPORTANT! After creating tables, one of the build variations, ie Self::build
or
Self::build_schema
, must be called to ensure the catalog provider is up to date with the
remote ClickHouse
database. If you forget to do this, DataFusion
queries targeting one of
these tables will fail.
Implementations§
Source§impl ClickHouseCatalogBuilder
impl ClickHouseCatalogBuilder
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Return the name of the catalog in DataFusion
’s context that this builder is configuring.
Sourcepub fn schema(&self) -> &str
pub fn schema(&self) -> &str
Return the currently set schema (database) being targeted. Can be changed on the fly by
calling Self::with_schema
.
Sourcepub async fn with_schema(self, name: impl Into<String>) -> Result<Self>
pub async fn with_schema(self, name: impl Into<String>) -> Result<Self>
Update the current “schema” (database) that this builder is targeting, and continue building.
§Errors
- Returns an error if the schema needs to be created and fails
Sourcepub fn with_new_table(
&self,
name: impl Into<String>,
engine: impl Into<ClickHouseEngine>,
schema: SchemaRef,
) -> ClickHouseTableCreator
pub fn with_new_table( &self, name: impl Into<String>, engine: impl Into<ClickHouseEngine>, schema: SchemaRef, ) -> ClickHouseTableCreator
Create a new table in the remote ClickHouse
instance.
§Arguments
name
: The name of the table to create.engine
: The engine to use for the table.schema
: The schema of the table.
§Returns
- A
ClickHouseTableCreator
that can be used to create tables in the remoteClickHouse
instance.
Sourcepub fn with_new_table_and_options(
&self,
name: impl Into<String>,
schema: SchemaRef,
options: CreateOptions,
) -> ClickHouseTableCreator
pub fn with_new_table_and_options( &self, name: impl Into<String>, schema: SchemaRef, options: CreateOptions, ) -> ClickHouseTableCreator
Create a new table in the remote ClickHouse
instance.
§Arguments
name
: The name of the table to create.schema
: The schema of the table.options
: More detailedCreateOptions
for creating the provided table.
§Returns
- A
ClickHouseTableCreator
that can be used to create tables in the remoteClickHouse
instance.
Sourcepub async fn register_existing_table(
&self,
name: impl Into<TableReference>,
name_as: Option<impl Into<TableReference>>,
ctx: &SessionContext,
) -> Result<()>
pub async fn register_existing_table( &self, name: impl Into<TableReference>, name_as: Option<impl Into<TableReference>>, ctx: &SessionContext, ) -> Result<()>
Register an existing ClickHouse
table, optionally renaming it in the provided session
state.
§Errors
- Returns an error if the table does not exist in the remote database
- Returns an error if the table cannot be registered to the context
Sourcepub async fn build_schema(
self,
new_schema: Option<String>,
ctx: &SessionContext,
) -> Result<Self>
pub async fn build_schema( self, new_schema: Option<String>, ctx: &SessionContext, ) -> Result<Self>
Build the current schema
(database) being managed by this catalog, optionally registering
a new schema to continue building
Note: For the SessionContext
to recognize the added tables and updated schema, either this
function or Self::build
must be called.
§Errors
- Returnes an error if an error occurs while refreshing the catalog
Sourcepub async fn build(
&self,
ctx: &SessionContext,
) -> Result<Arc<ClickHouseCatalogProvider>>
pub async fn build( &self, ctx: &SessionContext, ) -> Result<Arc<ClickHouseCatalogProvider>>
Re-register the catalog, updating the SessionContext
, and return the updated context.
Note: Important! For the SessionContext
to recognize the added tables and updated
schema, either this function or Self::build
must be called. For that reason, it is
important to use the SessionContext
provided back from this function.
§Errors
- Returns an error if the
SessionContext
has not been federated - Returnes an error if an error occurs while refreshing the catalog
- Returns an error if the “federation” feature is enabled but the context is not federated
Trait Implementations§
Source§impl Clone for ClickHouseCatalogBuilder
impl Clone for ClickHouseCatalogBuilder
Source§fn clone(&self) -> ClickHouseCatalogBuilder
fn clone(&self) -> ClickHouseCatalogBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ClickHouseCatalogBuilder
impl !RefUnwindSafe for ClickHouseCatalogBuilder
impl Send for ClickHouseCatalogBuilder
impl Sync for ClickHouseCatalogBuilder
impl Unpin for ClickHouseCatalogBuilder
impl !UnwindSafe for ClickHouseCatalogBuilder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more