pub struct FlightTableFactory { /* private fields */ }Available on crate feature
flight only.Expand description
Generic Arrow Flight data source. Requires a FlightDriver that allows implementors to integrate any custom Flight RPC service by producing a FlightMetadata for some DDL.
§Sample usage:
#[derive(Debug, Clone, Default)]
struct CustomFlightDriver {}
#[async_trait::async_trait]
impl FlightDriver for CustomFlightDriver {
async fn metadata(
&self,
channel: Channel,
opts: &HashMap<String, String>,
) -> arrow_flight::error::Result<FlightMetadata> {
let mut client = FlightClient::new(channel);
// for simplicity, we'll just assume the server expects a string command and no handshake
let descriptor = FlightDescriptor::new_cmd(opts["flight.command"].clone());
let flight_info = client.get_flight_info(descriptor).await?;
FlightMetadata::try_from(flight_info)
}
}
#[tokio::main]
async fn main() {
let ctx = SessionContext::new();
ctx.state_ref().write().table_factories_mut().insert(
"CUSTOM_FLIGHT".into(),
Arc::new(FlightTableFactory::new(Arc::new(
CustomFlightDriver::default(),
))),
);
let _ = ctx.sql(
r#"
CREATE EXTERNAL TABLE custom_flight_table STORED AS CUSTOM_FLIGHT
LOCATION 'https://custom.flight.rpc'
OPTIONS ('flight.command' 'AI, show me the data!')
"#,
); // no .await here, so we don't actually try to connect to the bogus URL
}Implementations§
Source§impl FlightTableFactory
impl FlightTableFactory
Sourcepub fn new(driver: Arc<dyn FlightDriver>) -> Self
pub fn new(driver: Arc<dyn FlightDriver>) -> Self
Create a data source using the provided driver
Sourcepub async fn open_table(
&self,
entry_point: impl Into<String>,
options: HashMap<String, String>,
) -> Result<FlightTable>
pub async fn open_table( &self, entry_point: impl Into<String>, options: HashMap<String, String>, ) -> Result<FlightTable>
Convenient way to create a FlightTable programatically, as an alternative to DDL.
Trait Implementations§
Source§impl Clone for FlightTableFactory
impl Clone for FlightTableFactory
Source§fn clone(&self) -> FlightTableFactory
fn clone(&self) -> FlightTableFactory
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FlightTableFactory
impl Debug for FlightTableFactory
Source§impl TableProviderFactory for FlightTableFactory
impl TableProviderFactory for FlightTableFactory
Source§fn create<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_state: &'life1 dyn Session,
cmd: &'life2 CreateExternalTable,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn TableProvider>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn create<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_state: &'life1 dyn Session,
cmd: &'life2 CreateExternalTable,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn TableProvider>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Create a TableProvider with the given url
Auto Trait Implementations§
impl Freeze for FlightTableFactory
impl !RefUnwindSafe for FlightTableFactory
impl Send for FlightTableFactory
impl Sync for FlightTableFactory
impl Unpin for FlightTableFactory
impl !UnwindSafe for FlightTableFactory
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request