xanderbailey commented on code in PR #2776:
URL: https://github.com/apache/iceberg-rust/pull/2776#discussion_r3573621592
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -364,6 +364,33 @@ impl TableMetadata {
&self.properties
}
+ /// Returns the default metadata directory for a table location: the
`metadata`
+ /// subdirectory under `table_location`. Used when `write.metadata.path`
is not set.
+ pub fn default_metadata_dir(table_location: &str) -> String {
+ format!(
+ "{table_location}/{}",
+ TableProperties::PROPERTY_WRITE_METADATA_PATH_DEFAULT_DIR
+ )
+ }
+
+ /// Returns the base location for metadata files.
+ ///
+ /// Honors the `write.metadata.path` table property when set, otherwise
defaults
+ /// to the `metadata` directory under the table location.
+ pub fn metadata_location_root(&self) -> String {
+ self.metadata_location_root_with_base(self.location())
+ }
+
+ /// Like [`Self::metadata_location_root`], but uses an explicit table
location as
+ /// the base for the default `<location>/metadata` when
`write.metadata.path` is not
+ /// configured.
+ pub(crate) fn metadata_location_root_with_base(&self, base: &str) ->
String {
+ self.properties
+ .get(TableProperties::PROPERTY_WRITE_METADATA_PATH)
+ .map(|location| location.trim_end_matches('/').to_string())
+ .unwrap_or_else(|| Self::default_metadata_dir(base))
Review Comment:
Can I suggest adding this to the strongly typed `TableProperties` rather
than getting it from the raw properties map?
--
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]