CTTY commented on code in PR #2776:
URL: https://github.com/apache/iceberg-rust/pull/2776#discussion_r3618017742
##########
crates/iceberg/src/catalog/metadata_location.rs:
##########
@@ -42,27 +49,21 @@ impl MetadataLocation {
parse_metadata_file_compression(properties).unwrap_or(CompressionCodec::None)
}
- /// Creates a completely new metadata location starting at version 0.
- /// Only used for creating a new table. For updates, see `next_version`.
- #[deprecated(
- since = "0.8.0",
- note = "Use new_with_metadata instead to properly handle compression
settings"
- )]
- pub fn new_with_table_location(table_location: impl ToString) -> Self {
- Self {
- table_location: table_location.to_string(),
- version: 0,
- id: Uuid::new_v4(),
- compression_codec: CompressionCodec::None,
- }
- }
-
/// Creates a completely new metadata location starting at version 0,
/// with compression settings from the table metadata.
/// Only used for creating a new table. For updates, see `next_version`.
+ ///
+ /// The metadata directory honors the `write.metadata.path` table property
when set,
+ /// otherwise defaults to the `metadata` subdirectory of `table_location`.
pub fn new_with_metadata(table_location: impl ToString, metadata:
&TableMetadata) -> Self {
+ let table_location = table_location.to_string();
+ let location = metadata
+ .table_properties()
+ .ok()
Review Comment:
Good point. I think it was an API-level compromise that we still allow
users/catalogs to pass in table location, and now should be a good time to fix
that.
I can't think of a case where a caller needs pass in an explicit
`table_location` and a `metadata` with a different `location`, metadata should
always have a `location` as well. So I believe we should change the function to
just take in a metadata:
```rust
pub fn try_with_metadata(&self, metadata: &TableMetadata) -> Result<Self> {
// call metadata.metadata_location for location
}
```
Again, this is not a correctness issue, and if you think the change would be
too big then let's leave TODO comments and create a tracking issue so we can
move forward here
##########
crates/iceberg/src/catalog/metadata_location.rs:
##########
@@ -279,10 +273,15 @@ mod test {
"/metadata/noversion-2cd22b57-5127-4198-92ba-e4e67c79821b.metadata.json",
Err("".to_string()),
),
- // No /metadata subdirectory
+ // Metadata dir does not need to be named "metadata" (e.g. a
`write.metadata.path`` location)
Review Comment:
```suggestion
// Metadata dir does not need to be named "metadata" (e.g. a
`write.metadata.path` location)
```
nit
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]