Catalog

Struct Catalog 

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

Wrapper catalog supporting generation of pg metadata (e.g. pg_catalog schema).

Implementations§

Source§

impl Catalog

Source

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

Source§

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>

Retrieves the list of available schema names in this catalog.
Source§

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>

Adds a new schema to this catalog. Read more
Source§

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

impl Debug for Catalog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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