Skip to content

Commit a739bc5

Browse files
authored
some api improvements + remove manual changelog (#12)
1 parent da8ed33 commit a739bc5

File tree

3 files changed

+16
-35
lines changed

3 files changed

+16
-35
lines changed

CHANGELOG.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/materialized/dependencies.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -842,13 +842,12 @@ mod test {
842842
use datafusion_common::{Column, Result, ScalarValue};
843843
use datafusion_expr::{Expr, JoinType, LogicalPlan, TableType};
844844
use datafusion_physical_plan::ExecutionPlan;
845-
use datafusion_sql::TableReference;
846845
use itertools::Itertools;
847846

848847
use crate::materialized::{
849848
dependencies::pushdown_projection_inexact,
850849
register_materialized,
851-
row_metadata::{ObjectStoreRowMetadataSource, RowMetadataRegistry, RowMetadataSource},
850+
row_metadata::{ObjectStoreRowMetadataSource, RowMetadataRegistry},
852851
ListingTableLike, Materialized,
853852
};
854853

@@ -1005,31 +1004,14 @@ mod test {
10051004
.collect()
10061005
.await?;
10071006

1008-
let row_metadata_registry = Arc::new(RowMetadataRegistry::default());
1009-
let t1_ref = TableReference::parse_str("t1").resolve(
1010-
&ctx.state().config_options().catalog.default_catalog,
1011-
&ctx.state().config_options().catalog.default_schema,
1012-
);
1013-
let t2_ref = TableReference::parse_str("t2").resolve(
1014-
&ctx.state().config_options().catalog.default_catalog,
1015-
&ctx.state().config_options().catalog.default_schema,
1016-
);
1017-
let t3_ref = TableReference::parse_str("t3").resolve(
1018-
&ctx.state().config_options().catalog.default_catalog,
1019-
&ctx.state().config_options().catalog.default_schema,
1020-
);
1021-
10221007
let metadata_table = ctx.table_provider("file_metadata").await?;
10231008
let object_store_metadata_source = Arc::new(
10241009
ObjectStoreRowMetadataSource::with_file_metadata(Arc::clone(&metadata_table)),
10251010
);
10261011

1027-
for r in [t1_ref, t2_ref, t3_ref] {
1028-
row_metadata_registry.register_source(
1029-
&r,
1030-
Arc::clone(&object_store_metadata_source) as Arc<dyn RowMetadataSource>,
1031-
);
1032-
}
1012+
let row_metadata_registry = Arc::new(RowMetadataRegistry::new_with_default_source(
1013+
object_store_metadata_source,
1014+
));
10331015

10341016
ctx.register_udtf(
10351017
"mv_dependencies",

src/materialized/row_metadata.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use super::{file_metadata::FileMetadata, hive_partition::hive_partition, META_CO
2727
/// Registry that manages metadata sources for different tables.
2828
/// Provides a centralized way to register and retrieve metadata sources
2929
/// that can be used to obtain row-level metadata for tables.
30-
#[derive(Default)]
3130
pub struct RowMetadataRegistry {
3231
metadata_sources: DashMap<String, Arc<dyn RowMetadataSource>>,
3332
default_source: Option<Arc<dyn RowMetadataSource>>,
@@ -49,14 +48,24 @@ impl std::fmt::Debug for RowMetadataRegistry {
4948
}
5049

5150
impl RowMetadataRegistry {
52-
/// Initializes this `RowMetadataRegistry` with a default `RowMetadataSource`
51+
/// Initializes this `RowMetadataRegistry` with a default [`RowMetadataSource`]
5352
/// to be used if a table has not been explicitly registered with a specific source.
5453
///
5554
/// Typically the [`FileMetadata`] source should be used as the default.
5655
pub fn new_with_default_source(default_source: Arc<dyn RowMetadataSource>) -> Self {
5756
Self {
57+
metadata_sources: Default::default(),
5858
default_source: Some(default_source),
59-
..Default::default()
59+
}
60+
}
61+
62+
/// Initializes a new `RowMetadataRegistry` with no default [`RowMetadataSource`].
63+
///
64+
/// Users should typically use [`RowMetadataRegistry::new_with_default_source`].
65+
pub fn new_empty() -> Self {
66+
Self {
67+
metadata_sources: Default::default(),
68+
default_source: None,
6069
}
6170
}
6271

0 commit comments

Comments
 (0)