pub struct DataFusionEngine { /* private fields */ }Expand description
An engine instance using DataFusion for catalogue management and queries.
Implementations§
Source§impl DataFusionEngine
impl DataFusionEngine
Sourcepub fn new(ctx: SessionContext) -> Self
pub fn new(ctx: SessionContext) -> Self
Creates a new engine instance using the given DataFusion execution context.
Examples found in repository?
examples/datafusion.rs (line 51)
13async fn new_engine() -> DataFusionEngine {
14 let ctx = SessionContext::new_with_config(
15 SessionConfig::new()
16 .with_information_schema(true)
17 .with_create_default_catalog_and_schema(false),
18 );
19
20 let mem_catalog = Arc::new(MemoryCatalogProvider::new());
21 mem_catalog
22 .register_schema("public", Arc::new(MemorySchemaProvider::new()))
23 .expect("failed to register schema");
24
25 ctx.register_catalog("datafusion", Arc::new(Catalog::new(mem_catalog)));
26
27 ctx.register_csv(
28 "test_100_4buckets",
29 "convergence-arrow/data/100_4buckets.csv",
30 CsvReadOptions::new(),
31 )
32 .await
33 .expect("failed to register csv");
34
35 ctx.register_udf(create_udf(
36 "pg_backend_pid",
37 vec![],
38 DataType::Int32,
39 Volatility::Stable,
40 Arc::new(|_| Ok(ColumnarValue::Scalar(ScalarValue::Int32(Some(0))))),
41 ));
42
43 ctx.register_udf(create_udf(
44 "current_schema",
45 vec![],
46 DataType::Utf8,
47 Volatility::Stable,
48 Arc::new(|_| Ok(ColumnarValue::Scalar(ScalarValue::Utf8(Some("public".to_owned()))))),
49 ));
50
51 DataFusionEngine::new(ctx)
52}Trait Implementations§
Source§impl Engine for DataFusionEngine
impl Engine for DataFusionEngine
Source§type PortalType = DataFusionPortal
type PortalType = DataFusionPortal
The Portal implementation used by Engine::create_portal.
Source§fn prepare<'life0, 'life1, 'async_trait>(
&'life0 mut self,
statement: &'life1 Statement,
) -> Pin<Box<dyn Future<Output = Result<Vec<FieldDescription>, ErrorResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn prepare<'life0, 'life1, 'async_trait>(
&'life0 mut self,
statement: &'life1 Statement,
) -> Pin<Box<dyn Future<Output = Result<Vec<FieldDescription>, ErrorResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Prepares a statement, returning a vector of field descriptions for the final statement result.
Source§fn create_portal<'life0, 'life1, 'async_trait>(
&'life0 mut self,
statement: &'life1 Statement,
) -> Pin<Box<dyn Future<Output = Result<Self::PortalType, ErrorResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create_portal<'life0, 'life1, 'async_trait>(
&'life0 mut self,
statement: &'life1 Statement,
) -> Pin<Box<dyn Future<Output = Result<Self::PortalType, ErrorResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Creates a new portal for the given statement.
Auto Trait Implementations§
impl Freeze for DataFusionEngine
impl !RefUnwindSafe for DataFusionEngine
impl Send for DataFusionEngine
impl Sync for DataFusionEngine
impl Unpin for DataFusionEngine
impl !UnwindSafe for DataFusionEngine
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
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>
Converts
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>
Converts
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