Repository navigation
Conversation
|
|
||
| /// Produces the resulting manifest set for the current table and writes | ||
| /// this attempt's snapshot. | ||
| pub(crate) async fn apply(&mut self, table: &Table) -> Result<ActionCommit> { |
There was a problem hiding this comment.
Seems like we currently have no logic to validate new deletes or overwrite?
There was a problem hiding this comment.
We can add them later before adding the actions that consume MSP
laskoviymishka
left a comment
There was a problem hiding this comment.
It's on the large side, but this is close; I left a couple of comments inline.
Keying each rewrite by ManifestKey rather than path means a retry only redoes the manifests whose inherited values actually moved, and that's the piece the rest of #3417 builds on.
What I'd most like to settle is who decides that a missing delete fails, the action or the filter. I'd like to hear @anoopj's opinion on that thread; a follow-up is fine.
Could the description also mention the to_human_string promotion fix in spec/?
I'll take another look once that thread converges.
| /// Produces the resulting manifest set for the current table and writes | ||
| /// this attempt's snapshot. | ||
| pub(crate) async fn apply(&mut self, table: &Table) -> Result<ActionCommit> { |
There was a problem hiding this comment.
I think this is aligned with the current Java implementation and we are trying to change it for v4. I suggest establishing a separate CommitValidator API. Action execution state can own the validator alongside this producer across retries. This has two advantages:
- The validation can be stateful. So retries can reuse the already validated state.
- Provides a useful seam for introducing v4 specific implementations of validations.
apache/iceberg#18699 may be a useful reference. This is one of the many upcoming changes we are making for validations.
There was a problem hiding this comment.
Thanks for pointing me to the java side PR! I had some thoughts about this a few weeks ago, and my previous thought was caching validated snapshots directly under the MSP and the seam also makes sense to me.
iiuc, we could still address this #3419 ? I'm leaning toward moving validations to another PR since the current PR is already quite large
Merges CTTY's branch and drops the producer this branch carried from apache#3046.
|
@CTTY we put #3585 (
Happy to open either as a PR on top of this once it lands. Both were in the producer #3585 carried before the restack, in case it saves time: the keep rule at https://github.com/jopdorp/iceberg-rust/blob/682a6150b/crates/iceberg/src/transaction/merging.rs#L301-L313 and the sequence number check at https://github.com/jopdorp/iceberg-rust/blob/682a6150b/crates/iceberg/src/transaction/merging.rs#L259-L270. |
|
Hi @jopdorp , thanks for the feedback! I've addressed the first point you mentioned. And I'm planning to address the starting-seq-number issue when we are actually wiring actions with MSP and adding validation methods |
|
@CTTY #3300 (overwrite) sits on this branch now as well, it only builds a
Happy to send a PR into your branch for 1 if you want it. |
JeonDaehong
left a comment
There was a problem hiding this comment.
Re-ran my check at 8a442c6: removing a.parquet now marks its DV deleted (total-delete-files=0). Naming the DV as well under fail_missing_delete_paths removes it once, and removing only b.parquet or appending leaves a's DV alone. The older delete file cleanup (dropDeleteFilesOlderThan) isn't there yet, which is fine as a follow-up.
|
@CTTY one thing from my last comment is still open: the |
|
@CTTY opened CTTY#21 against your branch, it just merges main and resolves the conflict with the per-spec fast append, so you can pull it in if it helps. |
| let field_type = field_type.as_primitive_type().unwrap(); | ||
| // A value written before its source column was promoted (`int` | ||
| // to `long`, `float` to `double`) still carries the old type. | ||
| let value = value.promote_to(field_type).unwrap_or(value); |
There was a problem hiding this comment.
Why we need to add this? The original semantics of this function is to ensure that the type and value should exactly match. I perfer to put the promotion outside the function and let caller do it, which make the semanctics of this function clear
| pub(crate) struct AddedManifests { | ||
| /// One per content type today. Several once added files are grouped by | ||
| /// partition spec (#3500) or rolled over at a target size (#3499). | ||
| pub manifests: Vec<ManifestFile>, |
There was a problem hiding this comment.
I perfer not using pub fields as the reason stated in #3172, how about we use TypedBuilder + pub accessor function?
| use crate::{ErrorKind, TableUpdate}; | ||
|
|
||
| fn data_file(table: &Table, path: &str, record_count: u64) -> DataFile { | ||
| pub(super) fn data_file(table: &Table, path: &str, record_count: u64) -> DataFile { |
There was a problem hiding this comment.
Please move the helper functions to test_utils mods rather than making tests mod visible to others.
| /// vectors, each its own entry at a distinct blob offset. Data files and | ||
| /// non-DV delete files have no offset, so for them this is the path. | ||
| #[derive(Clone, Debug, PartialEq, Eq, Hash)] | ||
| struct RemovedFileIdentity { |
There was a problem hiding this comment.
How about we turn this into an enum so that its fields are type safe?
| /// The result of one filter pass. | ||
| pub(crate) struct Filtered { | ||
| /// The resulting manifests, in input order. | ||
| pub manifests: Vec<ManifestFile>, |
| filtered: HashMap<ManifestKey, FilteredManifest>, | ||
| /// Format version the rewrites were written under. Per spec, v1 entries | ||
| /// cannot inherit sequence numbers, so an upgrade invalidates them. | ||
| format_version: Option<FormatVersion>, |
| pub(crate) fn new( | ||
| content: ManifestContentType, | ||
| files_to_remove: &[DataFile], | ||
| fail_missing_delete_paths: bool, | ||
| ) -> Self { | ||
| Self { | ||
| content, | ||
| files_to_remove: files_to_remove | ||
| .iter() | ||
| .map(RemovedFileIdentity::of) | ||
| .collect(), | ||
| fail_missing_delete_paths, | ||
| removed_data_file_paths: HashSet::new(), | ||
| filtered: HashMap::new(), | ||
| format_version: None, | ||
| } | ||
| } | ||
|
|
||
| /// Also marks `Deleted` any deletion vector whose referenced data file is | ||
| /// among `removed_data_files`, as Java's `removeDanglingDeletesFor` does. | ||
| /// Only deletion vectors qualify: a position delete file's | ||
| /// `referenced_data_file` is a hint, not a guarantee of its contents. | ||
| pub(crate) fn with_dangling_dvs_for(mut self, removed_data_files: &[DataFile]) -> Self { |
There was a problem hiding this comment.
This will lead to invalid api call. A MainfestFilterManager should be constructed with filter conditions(files to delete, delete expression etc), and then call filter methods. I think we should create a builder for MainfestFilterManager, later calls should only change it bu calling filter or consume results.
| }); | ||
| } | ||
|
|
||
| if self.format_version != Some(format_version) { |
There was a problem hiding this comment.
This is actually odd to me. I think Table should be passed as an argument of ManifestFilterManager?
| // before reading, as Java's ManifestFilterManager does, and read the | ||
| // rest concurrently as `validate_files_not_live` does. | ||
| for source in manifests { | ||
| if source.content != self.content { |
There was a problem hiding this comment.
I think we should return error here?
| /// table-independent parts, such as content types, before each attempt. A path | ||
| /// may be both removed and added: the producer marks the old entry `Deleted` | ||
| /// and writes a new `Added` one, so whether to allow it is the action's call. | ||
| pub(crate) struct MergingIntent { |
There was a problem hiding this comment.
Which issue does this PR close?
MergingSnapshotProducer, manifest filtering, reusable added-manifest production; wire terminalCommitStatusreporting and cleanup #3417What changes are included in this PR?
MergingSnapshotProduceras a Transaction state to store deleted filesManifestFilterManagerto cache the manifests across transaction attemptsTransform::to_human_stringto widen a value to the declared field typebefore rendering.
Are these changes tested?
Added unit tests
AI Disclosure
Used Claude, but reviewed them with human eyes