pub struct Catalog { /* private fields */ }Expand description
Wrapper catalog supporting generation of pg metadata (e.g. pg_catalog schema).
Implementations§
Source§impl Catalog
impl Catalog
Sourcepub fn new(wrapped: Arc<dyn CatalogProvider>) -> Self
pub fn new(wrapped: Arc<dyn CatalogProvider>) -> Self
Create a new wrapper catalog that provides postgres metadata for the contained objects.
Examples found in repository?
examples/datafusion.rs (line 25)
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 CatalogProvider for Catalog
impl CatalogProvider for Catalog
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Returns the catalog provider as
Any
so that it can be downcast to a specific implementation.Source§fn schema_names(&self) -> Vec<String>
fn schema_names(&self) -> Vec<String>
Retrieves the list of available schema names in this catalog.
Source§fn schema(&self, name: &str) -> Option<Arc<dyn SchemaProvider>>
fn schema(&self, name: &str) -> Option<Arc<dyn SchemaProvider>>
Retrieves a specific schema from the catalog by name, provided it exists.
Source§fn register_schema(
&self,
name: &str,
schema: Arc<dyn SchemaProvider>,
) -> Result<Option<Arc<dyn SchemaProvider>>, DataFusionError>
fn register_schema( &self, name: &str, schema: Arc<dyn SchemaProvider>, ) -> Result<Option<Arc<dyn SchemaProvider>>, DataFusionError>
Adds a new schema to this catalog. Read more
Source§fn deregister_schema(
&self,
_name: &str,
_cascade: bool,
) -> Result<Option<Arc<dyn SchemaProvider>>, DataFusionError>
fn deregister_schema( &self, _name: &str, _cascade: bool, ) -> Result<Option<Arc<dyn SchemaProvider>>, DataFusionError>
Removes a schema from this catalog. Implementations of this method should return
errors if the schema exists but cannot be dropped. For example, in DataFusion’s
default in-memory catalog,
MemoryCatalogProvider, a non-empty schema
will only be successfully dropped when cascade is true.
This is equivalent to how DROP SCHEMA works in PostgreSQL. Read moreAuto Trait Implementations§
impl Freeze for Catalog
impl !RefUnwindSafe for Catalog
impl Send for Catalog
impl Sync for Catalog
impl Unpin for Catalog
impl !UnwindSafe for Catalog
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