From c7f95c786d25e160db980ba8634782947e03b613 Mon Sep 17 00:00:00 2001 From: suremarc <8771538+suremarc@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:25:25 +0000 Subject: [PATCH] add constructor for RowMetadataRegistry from FileMetadata --- src/materialized/row_metadata.rs | 9 +++++++++ tests/materialized_listing_table.rs | 7 ++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/materialized/row_metadata.rs b/src/materialized/row_metadata.rs index d51927c..6476f39 100644 --- a/src/materialized/row_metadata.rs +++ b/src/materialized/row_metadata.rs @@ -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) -> Self { + Self::new_with_default_source(Arc::new(ObjectStoreRowMetadataSource::new(file_metadata)) + as Arc) + } + /// Initializes this `RowMetadataRegistry` with a default [`RowMetadataSource`] /// to be used if a table has not been explicitly registered with a specific source. /// diff --git a/tests/materialized_listing_table.rs b/tests/materialized_listing_table.rs index fa26a7b..6ab2bf1 100644 --- a/tests/materialized_listing_table.rs +++ b/tests/materialized_listing_table.rs @@ -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}; @@ -147,10 +147,7 @@ async fn setup() -> Result { // 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",