Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add constructor for RowMetadataRegistry from FileMetadata #25

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/materialized/row_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ impl std::fmt::Debug for RowMetadataRegistry {
}

impl RowMetadataRegistry {
/// Initializes this `RowMetadataRegistry` with a [`FileMetadata`] as the default
/// row metadata source.
///
/// This should be the typical entrypoint for most usecases.
pub fn new(file_metadata: Arc<FileMetadata>) -> Self {
Self::new_with_default_source(Arc::new(ObjectStoreRowMetadataSource::new(file_metadata))
as Arc<dyn RowMetadataSource + 'static>)
}

/// Initializes this `RowMetadataRegistry` with a default [`RowMetadataSource`]
/// to be used if a table has not been explicitly registered with a specific source.
///
Expand Down
7 changes: 2 additions & 5 deletions tests/materialized_listing_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use datafusion_materialized_views::materialized::{
dependencies::{mv_dependencies, stale_files},
file_metadata::FileMetadata,
register_materialized,
row_metadata::{ObjectStoreRowMetadataSource, RowMetadataRegistry},
row_metadata::RowMetadataRegistry,
ListingTableLike, Materialized,
};
use datafusion_physical_plan::{collect, ExecutionPlan};
Expand Down Expand Up @@ -147,10 +147,7 @@ async fn setup() -> Result<TestContext> {
// They have `FileMetadata` and `RowMetadataRegistry` as dependencies.

let file_metadata = Arc::new(FileMetadata::new(Arc::clone(ctx.state().catalog_list())));

let row_metadata_registry = Arc::new(RowMetadataRegistry::new_with_default_source(Arc::new(
ObjectStoreRowMetadataSource::new(Arc::clone(&file_metadata)),
)));
let row_metadata_registry = Arc::new(RowMetadataRegistry::new(Arc::clone(&file_metadata)));

ctx.register_udtf(
"mv_dependencies",
Expand Down
Loading