laskoviymishka commented on code in PR #3102:
URL: https://github.com/apache/iceberg-rust/pull/3102#discussion_r4286579599
##########
crates/catalog/glue/src/catalog.rs:
##########
@@ -149,29 +102,38 @@ impl CatalogBuilder for GlueCatalogBuilder {
None => Runtime::try_current()?,
};
let kms_client = match self.kms_client_factory {
- Some(factory) =>
Some(factory.create_kms_client(&self.config.props).await?),
+ Some(factory) =>
Some(factory.create_kms_client(&props).await?),
None => None,
};
- GlueCatalog::new(self.config, self.storage_factory, runtime,
kms_client).await
+ GlueCatalog::new(
+ name,
+ catalog_properties,
+ props,
+ self.storage_factory,
+ runtime,
+ kms_client,
+ )
+ .await
}
}
}
-#[derive(Debug)]
-/// Glue Catalog configuration
-pub(crate) struct GlueCatalogConfig {
- name: Option<String>,
+#[derive(Debug, Properties)]
Review Comment:
The rename dropped the old doc line, I'd keep a one-liner:
```suggestion
/// Glue catalog properties parsed from the `load` property map.
#[derive(Debug, Properties)]
```
##########
crates/catalog/glue/src/catalog.rs:
##########
@@ -149,29 +102,38 @@ impl CatalogBuilder for GlueCatalogBuilder {
None => Runtime::try_current()?,
};
let kms_client = match self.kms_client_factory {
- Some(factory) =>
Some(factory.create_kms_client(&self.config.props).await?),
+ Some(factory) =>
Some(factory.create_kms_client(&props).await?),
Review Comment:
This now passes `uri`/`catalog_id`/`warehouse` to `create_kms_client` (and
to FileIO via `file_io_props`), where the old code stripped them first. Fine
since it's the intent, but nothing pins it. I'd add a small test with a stub
`KmsClientFactory` that records the map it receives and returns an error, so
`load` stops before `GlueCatalog::new`, then assert the recorded map equals the
full input. That way nobody quietly brings the filter back later.
##########
crates/catalog/glue/src/catalog.rs:
##########
@@ -959,3 +925,56 @@ impl Catalog for GlueCatalog {
Ok(staged_table)
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_catalog_properties() {
+ let properties =
GlueCatalogProperties::from_properties(&HashMap::from([
+ (
+ GLUE_CATALOG_PROP_URI.to_string(),
+ "http://localhost".to_string(),
+ ),
+ (
+ GLUE_CATALOG_PROP_CATALOG_ID.to_string(),
+ "catalog".to_string(),
+ ),
+ (
+ GLUE_CATALOG_PROP_WAREHOUSE.to_string(),
+ "s3://warehouse".to_string(),
+ ),
+ ]))
+ .unwrap();
+
+ assert_eq!(properties.uri.as_deref(), Some("http://localhost"));
+ assert_eq!(properties.catalog_id.as_deref(), Some("catalog"));
+ assert_eq!(properties.warehouse, "s3://warehouse");
+ }
+
+ #[test]
+ fn test_catalog_properties_defaults() {
+ let properties =
GlueCatalogProperties::from_properties(&HashMap::new()).unwrap();
+
+ assert_eq!(properties.uri, None);
+ assert_eq!(properties.catalog_id, None);
+ assert_eq!(properties.warehouse, "");
+ }
+
+ #[tokio::test]
+ async fn test_load_rejects_missing_or_empty_warehouse() {
+ for props in [
Review Comment:
If this fails, the output won't say which of the two cases tripped. I'd
label them (or split into two tests):
```rust
for (case, props) in [
("missing", HashMap::new()),
("empty", HashMap::from([(GLUE_CATALOG_PROP_WAREHOUSE.to_string(),
String::new())])),
] {
// ...
assert_eq!(error.kind(), ErrorKind::DataInvalid, "{case}");
assert_eq!(error.message(), "Catalog warehouse is required", "{case}");
}
```
--
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]