pub struct Connector { /* private fields */ }Expand description
Bundles a CatalogProvider with TableReaders for convenient use.
The Connector is the primary entry point for interacting with an external
catalog. It delegates metadata operations to the catalog provider and data
reading to the appropriate table reader based on the table’s data format.
§Storage Options
Cloud storage credentials (S3, Azure, GCS) are passed via storage_options
and forwarded to each TableReader during table registration.
§Extensibility
- Swap the catalog: pass a different
CatalogProvider(e.g., AWS Glue). - Add formats: pass additional
TableReaders (e.g., Iceberg).
§Example
// let connector = Connector::new(catalog, readers)
// .with_storage_options(HashMap::from([
// ("aws_access_key_id".into(), "...".into()),
// ("aws_secret_access_key".into(), "...".into()),
// ]));Implementations§
Source§impl Connector
impl Connector
Sourcepub fn new(
catalog: Arc<dyn CatalogProvider>,
readers: Vec<Arc<dyn TableReader>>,
) -> Self
pub fn new( catalog: Arc<dyn CatalogProvider>, readers: Vec<Arc<dyn TableReader>>, ) -> Self
Create a new connector with the given catalog provider and table readers.
Sourcepub fn with_storage_options(self, options: HashMap<String, String>) -> Self
pub fn with_storage_options(self, options: HashMap<String, String>) -> Self
Set storage options for cloud storage access (S3, Azure, GCS).
Common keys:
- S3:
aws_access_key_id,aws_secret_access_key,aws_region - Azure:
azure_storage_account_name,azure_storage_account_key - GCS:
google_service_account_path
Sourcepub fn storage_options(&self) -> &HashMap<String, String>
pub fn storage_options(&self) -> &HashMap<String, String>
Get the current storage options.
Sourcepub fn catalog(&self) -> &dyn CatalogProvider
pub fn catalog(&self) -> &dyn CatalogProvider
Get a reference to the underlying catalog provider.
Sourcepub fn reader_for(&self, format: &DataSourceFormat) -> Option<&dyn TableReader>
pub fn reader_for(&self, format: &DataSourceFormat) -> Option<&dyn TableReader>
Find a table reader that supports the given data format.
Sourcepub fn readers(&self) -> &[Arc<dyn TableReader>]
pub fn readers(&self) -> &[Arc<dyn TableReader>]
List all available table readers.
pub async fn list_catalogs(&self) -> CatalogResult<Vec<CatalogInfo>>
pub async fn get_catalog(&self, name: &str) -> CatalogResult<CatalogInfo>
pub async fn list_schemas( &self, catalog_name: &str, ) -> CatalogResult<Vec<SchemaInfo>>
pub async fn get_schema( &self, catalog_name: &str, schema_name: &str, ) -> CatalogResult<SchemaInfo>
pub async fn list_tables( &self, catalog_name: &str, schema_name: &str, ) -> CatalogResult<Vec<TableInfo>>
pub async fn get_table( &self, catalog_name: &str, schema_name: &str, table_name: &str, ) -> CatalogResult<TableInfo>
Sourcepub async fn register_schema(
&self,
ctx: &SessionContext,
catalog_name: &str,
schema_name: &str,
) -> CatalogResult<Vec<(String, SchemaRef)>>
pub async fn register_schema( &self, ctx: &SessionContext, catalog_name: &str, schema_name: &str, ) -> CatalogResult<Vec<(String, SchemaRef)>>
Register all tables from a catalog schema into a DataFusion SessionContext.
For each table:
- Retrieves full table metadata (including columns) from the catalog.
- Converts columns to an Arrow schema.
- Finds an appropriate
TableReaderfor the table’s data format. - Registers the table in the session context with storage options for cloud access.
If no reader matches the table’s format, falls back to registering an
empty MemTable with the correct schema (schema-only, for planning).
Individual table failures are logged as warnings but do not abort the registration of remaining tables.
Returns a list of (table_name, schema) for successfully registered tables.
Auto Trait Implementations§
impl Freeze for Connector
impl !RefUnwindSafe for Connector
impl Send for Connector
impl Sync for Connector
impl Unpin for Connector
impl UnsafeUnpin for Connector
impl !UnwindSafe for Connector
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
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