wjones127 commented on code in PR #478: URL: https://github.com/apache/arrow-adbc/pull/478#discussion_r1141464220
########## rust/src/objects.rs: ########## @@ -0,0 +1,483 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Structs and traits for representing database objects (tables, columns, schemas). +//! +//! When [crate::AdbcConnection::get_objects] is called, it returns an associated type that +//! implements [DatabaseCatalogCollection]. This collection contains a hierarchical data +//! structure representing: +//! +//! * Database catalogs +//! * Database schemas +//! * Tables +//! * Columns +//! * Table constraints +//! +//! A database catalog, schema, and table are represented by a type implementing +//! [DatabaseCatalogEntry], [DatabaseSchemaEntry], and [DatabaseTableEntry], +//! respectively. These can be concrete Rust structs, such as [SimpleCatalogEntry], +//! [SimpleSchemaEntry], and [SimpleTableEntry]. Or they can be zero-copy views +//! onto Arrow record batches as returned by the C API ADBC drivers (TODO). +//! +//! | Trait | Simple Rust-based | +//! |------------------------------|----------------------| +//! | [DatabaseCatalogCollection] | [SimpleSchemaEntry] | +//! | [DatabaseCatalogEntry] | [SimpleCatalogEntry] | +//! | [DatabaseSchemaEntry] | [SimpleSchemaEntry] | +//! | [DatabaseTableEntry] | [SimpleTableEntry] | +//! +//! There are owned and reference variations of columns, table constraints, +//! and foreign key usage. Each have a `borrow()` method to transform a owned +//! variant into its reference variant, and a `to_owned()` method to transform the +//! reference variant into the owned. These mimic the [std::borrow::Borrow] and +//! [std::borrow::ToOwned] traits, but do not actually implement them. +//! +//! | Owned | Reference | +//! |-------------------|----------------------| +//! | [ColumnSchema] | [ColumnSchemaRef] | +//! | [TableConstraint] | [TableConstraintRef] | +//! | [ForeignKeyUsage] | [ForeignKeyUsageRef] | + +/// A collection of database catalogs, returned by [crate::AdbcConnection::get_objects]. +pub trait DatabaseCatalogCollection { + type CatalogEntryType<'a>: DatabaseCatalogEntry<'a> + where + Self: 'a; + + /// List all catalogs in the result set. + fn catalogs<'a>(&'a self) -> Box<dyn Iterator<Item = Self::CatalogEntryType<'a>> + 'a>; Review Comment: Yeah this seems like a place where avoiding dynamic dispatch seems worthwhile. :thumbsup: -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
