pub trait WorkerSessionBuilder {
// Required method
fn build_session_state<'life0, 'async_trait>(
&'life0 self,
ctx: WorkerQueryContext,
) -> Pin<Box<dyn Future<Output = Result<SessionState, DataFusionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
builds a DataFusion’s SessionState in each query issued to a worker.
Required Methods§
Sourcefn build_session_state<'life0, 'async_trait>(
&'life0 self,
ctx: WorkerQueryContext,
) -> Pin<Box<dyn Future<Output = Result<SessionState, DataFusionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn build_session_state<'life0, 'async_trait>(
&'life0 self,
ctx: WorkerQueryContext,
) -> Pin<Box<dyn Future<Output = Result<SessionState, DataFusionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Builds a custom SessionState scoped to a single ArrowFlight gRPC call, allowing the users to provide a customized DataFusion session with things like custom extension codecs, custom physical optimization rules, UDFs, UDAFs, config extensions, etc…
Example:
#[derive(Debug)]
struct CustomExecCodec;
impl PhysicalExtensionCodec for CustomExecCodec {
fn try_decode(&self, buf: &[u8], inputs: &[Arc<dyn ExecutionPlan>], ctx: &TaskContext) -> datafusion::common::Result<Arc<dyn ExecutionPlan>> {
todo!()
}
fn try_encode(&self, node: Arc<dyn ExecutionPlan>, buf: &mut Vec<u8>) -> datafusion::common::Result<()> {
todo!()
}
}
#[derive(Clone)]
struct CustomSessionBuilder;
#[async_trait]
impl WorkerSessionBuilder for CustomSessionBuilder {
async fn build_session_state(&self, ctx: WorkerQueryContext) -> Result<SessionState, DataFusionError> {
Ok(ctx
.builder
.with_distributed_user_codec(CustomExecCodec)
// Add your UDFs, optimization rules, etc...
.build())
}
}Implementors§
impl WorkerSessionBuilder for DefaultSessionBuilder
impl<F, Fut> WorkerSessionBuilder for Fwhere
F: Fn(WorkerQueryContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<SessionState, DataFusionError>> + Send + 'static,
Implementation of WorkerSessionBuilder for any async function that returns a Result