DataFusionEngine

Struct DataFusionEngine 

Source
pub struct DataFusionEngine { /* private fields */ }
Expand description

An engine instance using DataFusion for catalogue management and queries.

Implementations§

Source§

impl DataFusionEngine

Source

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

Source§

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,

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,

Creates a new portal for the given statement.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T