zakariya-s commented on code in PR #2776:
URL: https://github.com/apache/iceberg-rust/pull/2776#discussion_r3621361704
##########
crates/iceberg/src/spec/table_properties.rs:
##########
@@ -40,6 +40,37 @@ where
})
}
+/// Strips trailing slashes from a location, preserving a bare URI scheme root
+fn strip_trailing_slash(path: &str) -> &str {
+ let mut path = path;
+ while !path.ends_with("://") {
+ let Some(stripped) = path.strip_suffix('/') else {
+ break;
+ };
+ path = stripped;
+ }
+ path
+}
+
+fn parse_location_property(
+ properties: &HashMap<String, String>,
+ key: &str,
+) -> Result<Option<String>> {
+ properties
+ .get(key)
+ .map(|path| {
+ if path.is_empty() {
+ return Err(Error::new(
+ ErrorKind::DataInvalid,
+ format!("Invalid value for {key}: path must not be empty"),
+ ));
+ }
+
+ Ok(strip_trailing_slash(path).to_string())
+ })
+ .transpose()
+}
+
Review Comment:
Currently `write.data.path`, which isn't touched by this PR, doesn't do any
sort of trimming. We can make this fix and moving it to `TableProperties` in
another PR
--
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]