-
Notifications
You must be signed in to change notification settings - Fork 530
feat: Incremental append scan #2337
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
Open
xanderbailey
wants to merge
34
commits into
apache:main
Choose a base branch
from
xanderbailey:xb/incremental_read
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
de1415f
Add incremental reads
xanderbailey 44ca553
Add datafusion integration
xanderbailey cf557e1
fmt
xanderbailey 2e73ae6
fix tests
xanderbailey ade3b56
clippy
xanderbailey c8a9ba0
clippy
xanderbailey 9bc0d13
fmt
xanderbailey 0bbddf0
tests
xanderbailey 2c3e310
current schema
xanderbailey 8a364da
new scan
xanderbailey 2649f4c
fixes
xanderbailey 77d4587
remove
xanderbailey 5865d3a
refactor
xanderbailey 7188f82
Remove examples
xanderbailey 66fd342
move tests
xanderbailey 65b3e92
rename
xanderbailey ed3c846
fix
xanderbailey 37aae03
nit
xanderbailey d26fb34
generify
xanderbailey a17ce94
make java semantics true here
xanderbailey 58f57c6
fix-up
xanderbailey a54d97e
clippy
xanderbailey 2135469
tests
xanderbailey f50afb7
Fix exclusive check
xanderbailey 36d3c8b
fmt
xanderbailey 489084d
don't need this
xanderbailey a393825
api
xanderbailey 346eb35
Merge origin/main into xb/incremental_read
xanderbailey c2db6cb
fix(datafusion): remove erroneous as_any() call in incremental provid…
xanderbailey bbf6ac5
feat(scan): project incremental append scan onto current schema
xanderbailey ae77133
test(scan): address py-iceberg #3512 review feedback
xanderbailey a372fa2
test(scan): use dedicated testdata files for deep-history variants
xanderbailey fadcd5a
Merge origin/main into xb/incremental_read
xanderbailey 198a85d
update docs
xanderbailey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,14 @@ use crate::spec::{ | |
| }; | ||
| use crate::{Error, ErrorKind, Result}; | ||
|
|
||
| /// Filter applied to each [`ManifestFile`] before fetching it. | ||
| /// Returns `true` to include the manifest, `false` to skip it. | ||
| pub(crate) type ManifestFileFilter = Arc<dyn Fn(&ManifestFile) -> bool + Send + Sync>; | ||
|
|
||
| /// Filter applied to each manifest entry after loading a manifest. | ||
| /// Returns `true` to include the entry, `false` to skip it. | ||
| pub(crate) type ManifestEntryFilter = Arc<dyn Fn(&ManifestEntryRef) -> bool + Send + Sync>; | ||
|
|
||
| /// Wraps a [`ManifestFile`] alongside the objects that are needed | ||
| /// to process it in a thread-safe manner | ||
| pub(crate) struct ManifestFileContext { | ||
|
|
@@ -48,6 +56,7 @@ pub(crate) struct ManifestFileContext { | |
| delete_file_index: DeleteFileIndex, | ||
| name_mapping: Option<Arc<NameMapping>>, | ||
| case_sensitive: bool, | ||
| entry_filter: Option<ManifestEntryFilter>, | ||
| partition_spec: Option<PartitionSpecRef>, | ||
| } | ||
|
|
||
|
|
@@ -82,12 +91,19 @@ impl ManifestFileContext { | |
| delete_file_index, | ||
| name_mapping, | ||
| case_sensitive, | ||
| entry_filter, | ||
| partition_spec, | ||
| } = self; | ||
|
|
||
| let manifest = object_cache.get_manifest(&manifest_file).await?; | ||
|
|
||
| for manifest_entry in manifest.entries() { | ||
| if let Some(ref filter) = entry_filter | ||
| && !filter(manifest_entry) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| let manifest_entry_context = ManifestEntryContext { | ||
| // TODO: refactor to avoid the expensive ManifestEntry clone | ||
| manifest_entry: manifest_entry.clone(), | ||
|
|
@@ -149,7 +165,6 @@ impl ManifestEntryContext { | |
|
|
||
| /// PlanContext wraps a [`SnapshotRef`] alongside all the other | ||
| /// objects that are required to perform a scan file plan. | ||
| #[derive(Debug)] | ||
| pub(crate) struct PlanContext { | ||
| pub snapshot: SnapshotRef, | ||
|
|
||
|
|
@@ -165,6 +180,25 @@ pub(crate) struct PlanContext { | |
| pub partition_filter_cache: Arc<PartitionFilterCache>, | ||
| pub manifest_evaluator_cache: Arc<ManifestEvaluatorCache>, | ||
| pub expression_evaluator_cache: Arc<ExpressionEvaluatorCache>, | ||
| pub manifest_file_filter: Option<ManifestFileFilter>, | ||
| pub manifest_entry_filter: Option<ManifestEntryFilter>, | ||
| } | ||
|
|
||
| impl std::fmt::Debug for PlanContext { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| f.debug_struct("PlanContext") | ||
| .field("snapshot", &self.snapshot) | ||
| .field("case_sensitive", &self.case_sensitive) | ||
| .field( | ||
| "manifest_file_filter", | ||
| &self.manifest_file_filter.as_ref().map(|_| "..."), | ||
| ) | ||
| .field( | ||
| "manifest_entry_filter", | ||
| &self.manifest_entry_filter.as_ref().map(|_| "..."), | ||
| ) | ||
| .finish_non_exhaustive() | ||
| } | ||
| } | ||
|
|
||
| impl PlanContext { | ||
|
|
@@ -218,6 +252,12 @@ impl PlanContext { | |
| // TODO: Ideally we could ditch this intermediate Vec as we return an iterator. | ||
| let mut filtered_mfcs = vec![]; | ||
| for manifest_file in manifest_files { | ||
| if let Some(ref filter) = self.manifest_file_filter | ||
| && !filter(manifest_file) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| let tx = if manifest_file.content == ManifestContentType::Deletes { | ||
| delete_file_tx.clone() | ||
| } else { | ||
|
|
@@ -288,6 +328,7 @@ impl PlanContext { | |
| delete_file_index, | ||
| name_mapping: self.name_mapping.clone(), | ||
| case_sensitive: self.case_sensitive, | ||
| entry_filter: self.manifest_entry_filter.clone(), | ||
| partition_spec: self | ||
| .table_metadata | ||
| .partition_spec_by_id(manifest_file.partition_spec_id) | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a nice way to inject these filters and should extend to other future scans