liurenjie1024 commented on code in PR #237: URL: https://github.com/apache/iceberg-rust/pull/237#discussion_r1518567904
########## crates/catalog/hms/src/catalog.rs: ########## @@ -95,9 +106,156 @@ impl HmsCatalog { client: HmsClient(client), }) } + + /// Create and extract properties from `hive_metastore::hms::Database`. + pub fn properties_from_database(database: &Database) -> HashMap<String, String> { + let mut properties = HashMap::new(); + + if let Some(description) = &database.description { + properties.insert("comment".to_string(), description.to_string()); + }; + + if let Some(location) = &database.location_uri { + properties.insert("location".to_string(), location.to_string()); + }; + + if let Some(owner) = &database.owner_name { + properties.insert(HMS_DB_OWNER.to_string(), owner.to_string()); + }; + + if let Some(owner_type) = &database.owner_type { + let value = match owner_type { + PrincipalType::User => "User", + PrincipalType::Group => "Group", + PrincipalType::Role => "Role", + }; + + properties.insert(HMS_DB_OWNER_TYPE.to_string(), value.to_string()); + }; + + if let Some(params) = &database.parameters { + params.iter().for_each(|(k, v)| { + properties.insert(k.clone().into(), v.clone().into()); + }); + }; + + properties + } + + /// Converts name and properties into `hive_metastore::hms::Database` + /// after validating the `namespace` and `owner-settings`. + pub fn convert_to_database( Review Comment: > Fetching the db and then wrapping it with the new type simply to call fn to_namespace seems weird - but maybe there is another way to do this more elegantly? This is what I think and currently I don't have idea to make it more elegant. To move on my suggestion is that we make the conversion apis crate private, and not exposing them before we found a good approach, what do you think? -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org