pub struct ClickHouseConnection<'a> { /* private fields */ }
Expand description
A wrapper around ArrowPoolConnection
that provides additional functionality relevant for
DataFusion
.
The methods ClickHouseConnection::tables
, ClickHouseConnection::get_schema
, and
ClickHouseConnection::query_arrow
will all be run against the ClickHouse
instance.
Implementations§
Source§impl<'a> ClickHouseConnection<'a>
impl<'a> ClickHouseConnection<'a>
pub fn new(conn: ArrowPoolConnection<'a>) -> Self
pub fn new_static(conn: ArrowPoolConnection<'static>) -> Self
Sourcepub async fn query_arrow_with_schema(
&self,
sql: &str,
params: &[()],
schema: SchemaRef,
coerce_schema: bool,
) -> Result<RecordBatchStreamWrapper, DataFusionError>
pub async fn query_arrow_with_schema( &self, sql: &str, params: &[()], schema: SchemaRef, coerce_schema: bool, ) -> Result<RecordBatchStreamWrapper, DataFusionError>
Issues a query against ClickHouse
and returns the result as an arrow
SendableRecordBatchStream
using the provided schema.
The argument coerce_schema
will be passed to RecordBatchStream
only if
projected_schema
is also provided. Otherwise coercion won’t be necessary as the streamed
RecordBatch
es will determine the schema.
§Errors
- Returns an error if the query fails.
Sourcepub async fn query_arrow(
&self,
sql: &str,
params: &[()],
projected_schema: Option<SchemaRef>,
) -> Result<SendableRecordBatchStream, GenericError>
pub async fn query_arrow( &self, sql: &str, params: &[()], projected_schema: Option<SchemaRef>, ) -> Result<SendableRecordBatchStream, GenericError>
Issues a query against ClickHouse
and returns the result as an arrow
SendableRecordBatchStream
using the provided schema.
This method allows interop with datafusion-table-providers
if desired. Otherwise, the
method Self::query_arrow_raw
can be used to prevent additional wrapping, or
Self::query_arrow_with_schema
if schema coercion is desired.
§Errors
- Returns an error if the query fails.
Source§impl ClickHouseConnection<'_>
impl ClickHouseConnection<'_>
Sourcepub async fn tables(&self, schema: &str) -> Result<Vec<String>>
pub async fn tables(&self, schema: &str) -> Result<Vec<String>>
Fetch the names of the tables in a schema (database).
§Errors
- Returns an error if the tables cannot be fetched.
Sourcepub async fn schemas(&self) -> Result<Vec<String>>
pub async fn schemas(&self) -> Result<Vec<String>>
Fetch the names of the schemas (databases).
§Errors
- Returns an error if the schemas cannot be fetched.
Sourcepub async fn get_schema(
&self,
table_reference: &TableReference,
) -> Result<SchemaRef>
pub async fn get_schema( &self, table_reference: &TableReference, ) -> Result<SchemaRef>
Sourcepub async fn query_arrow_raw(
&self,
sql: &str,
_params: &[()],
) -> Result<ClickHouseResponse<RecordBatch>>
pub async fn query_arrow_raw( &self, sql: &str, _params: &[()], ) -> Result<ClickHouseResponse<RecordBatch>>
Issues a query against ClickHouse
and returns the raw ClickHouseResponse<RecordBatch>
§Errors
- Returns an error if the query fails
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ClickHouseConnection<'a>
impl<'a> !RefUnwindSafe for ClickHouseConnection<'a>
impl<'a> Send for ClickHouseConnection<'a>
impl<'a> Sync for ClickHouseConnection<'a>
impl<'a> Unpin for ClickHouseConnection<'a>
impl<'a> !UnwindSafe for ClickHouseConnection<'a>
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> 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