-
Notifications
You must be signed in to change notification settings - Fork 197
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: View Metadata Builder #908
base: main
Are you sure you want to change the base?
Conversation
// ToDo Discuss: Similar to TableMetadata sort-order, Java does not add changes | ||
// in this case. I prefer to add changes as the state of the builder is | ||
// potentially mutated (`last_added_version_id`), thus we should record the change. | ||
if self.last_added_version_id != Some(version_id) { | ||
self.changes.push(ViewUpdate::AddViewVersion { | ||
view_version: view_version.with_version_id(version_id), | ||
}); | ||
self.last_added_version_id = Some(version_id); | ||
} |
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.
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.
Java returns here:
So when you do a rollback to an earlier version, the change isn't recorded in Java. Java will only update the last_added_version_id
if the version is added in the builder. I would assume that the change will be recorded in Java as well. Because I think the addInBuilder
will only be true if you add it twice. I think I'm okay with this, but let's check with @nastra to be sure 👍
// ToDo Discuss: This check is not present in Java. | ||
// The `TableMetadataBuilder` uses these checks in multiple places - also in Java. | ||
// If we think delayed requests are a problem, I think we should also add it here. | ||
if let Some(last) = self.metadata.version_log.last() { | ||
// commits can happen concurrently from different machines. | ||
// A tolerance helps us avoid failure for small clock skew | ||
if view_version.timestamp_ms() - last.timestamp_ms() < -ONE_MINUTE_MS { | ||
return Err(Error::new( | ||
ErrorKind::DataInvalid, | ||
format!( | ||
"Invalid snapshot timestamp {}: before last snapshot timestamp {}", | ||
view_version.timestamp_ms(), | ||
last.timestamp_ms() | ||
), | ||
)); | ||
} | ||
} |
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.
// ToDo Discuss: In Java this uses `new_view_version.version_id()` instead. | ||
// I believe 0 is more appropriate here, as the first version should always be 0. | ||
// The TableMetadataBuilder also uses 0 for partition specs (and other `reuse_or_create_*` functions). | ||
// Consistent behaviour between the two builders is desirable. | ||
.unwrap_or(INITIAL_VIEW_VERSION_ID) |
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.
// ToDo Discuss: Java does not add changes in this case. I prefer to add changes | ||
// as the state of the builder is potentially mutated (`last_added_schema_id`), | ||
// thus we should record the change. | ||
if self.last_added_schema_id != Some(schema_id) { | ||
self.changes.push(ViewUpdate::AddSchema { | ||
schema: schema.clone().with_schema_id(schema_id), | ||
last_column_id: None, | ||
}); | ||
self.last_added_schema_id = Some(schema_id); | ||
} |
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.
let builder = builder_without_changes(); | ||
let v1 = new_view_version(0, 1, "select * from ns.tbl"); | ||
|
||
// ToDo Java: I think we should remove line 688 - 693 in Java TestVeiwMetadata.java as it does nothing. |
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.
CC @nastra
.get(VIEW_PROPERTY_REPLACE_DROP_DIALECT_ALLOWED) | ||
.map_or( | ||
VIEW_PROPERTY_REPLACE_DROP_DIALECT_ALLOWED_DEFAULT, | ||
|value| value.to_lowercase() == "true", |
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.
Would it make sense to move this into some utility method?
// ToDo Discuss: Similar to TableMetadata sort-order, Java does not add changes | ||
// in this case. I prefer to add changes as the state of the builder is | ||
// potentially mutated (`last_added_version_id`), thus we should record the change. | ||
if self.last_added_version_id != Some(version_id) { | ||
self.changes.push(ViewUpdate::AddViewVersion { | ||
view_version: view_version.with_version_id(version_id), | ||
}); | ||
self.last_added_version_id = Some(version_id); | ||
} |
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.
Java returns here:
So when you do a rollback to an earlier version, the change isn't recorded in Java. Java will only update the last_added_version_id
if the version is added in the builder. I would assume that the change will be recorded in Java as well. Because I think the addInBuilder
will only be true if you add it twice. I think I'm okay with this, but let's check with @nastra to be sure 👍
Co-authored-by: Fokko Driesprong <[email protected]>
This PR is not completely ready yet as I believe the current mechanism of view expiration is flawed.
I opened a PR in Java to demonstrate the problem and use for discussions:
apache/iceberg#12051
Feedback from anyone is welcome. I am not sure what the best solutions looks like.