pub struct ExaImport(/* private fields */);etl only.Expand description
An ETL IMPORT worker.
The type implements AsyncWrite and is Send and Sync so it can be freely used for any
data pipeline.
The only caveat is that you MUST call futures_util::AsyncWriteExt::close on each worker to
finalize the import. A worker that is dropped without closing will cause the HTTP connection to
be unexpectedly dropped and the IMPORT query will return an error.
§Atomicity
IMPORT jobs are not atomic by themselves. If an error occurs during the data ingestion, some
of the data might be already sent and written in the database. However, since IMPORT is
fundamentally just a query, it can be transactional. Therefore, beginning a transaction and
passing that to the ImportBuilder::build method will result in the import job needing to be
explicitly committed:
use std::env;
use sqlx_exasol::{error::*, etl::*, *};
let pool = ExaPool::connect(&env::var("DATABASE_URL").unwrap()).await?;
let mut con = pool.acquire().await?;
let mut tx = con.begin().await?;
let (query_fut, writers) = ImportBuilder::new("SOME_TABLE", None)
.build(&mut *tx)
.await?;
// concurrently use the writers and await the query future
tx.commit().await?;§IMPORTANT
During IMPORT jobs Exasol will make a series of HTTP requests to the driver, one for each
worker. An IMPORT query is considered successful by Exasol if at least one HTTP response from
the driver contains data. This means at least one crate::connection::etl::ExaImport worker
(regardless which) must write some data before being closed.
Trait Implementations§
Source§impl AsyncWrite for ExaImport
impl AsyncWrite for ExaImport
Source§fn poll_write(
self: Pin<&mut ExaImport>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut ExaImport>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf into the object. Read moreSource§fn poll_write_vectored(
self: Pin<&mut ExaImport>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut ExaImport>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
bufs into the object using vectored
IO operations. Read moreAuto Trait Implementations§
impl Freeze for ExaImport
impl !RefUnwindSafe for ExaImport
impl Send for ExaImport
impl Sync for ExaImport
impl Unpin for ExaImport
impl !UnwindSafe for ExaImport
Blanket Implementations§
Source§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
Source§fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
AsyncWrite. Read moreSource§fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
AsyncWrite.Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
buf into the object. Read moreSource§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
bufs into the object using vectored
IO operations. Read moreSource§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