Skip to content

Conversation

@jonathanc-n
Copy link
Contributor

Which issue does this PR close?

What changes are included in this PR?

Makes CatalogConfig calls more explicit.

Are these changes tested?

Copy link
Contributor Author

@jonathanc-n jonathanc-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some comments to clarify to reviewers

Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jonathanc-n for this pr, I have some suggestions to improve the readability.


impl GlueCatalogBuilder {
/// Get a mutable reference to the catalog configuration.
pub(crate) fn catalog_config(&mut self) -> &mut GlueCatalogConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of such a change. I think a better approach would be following:

pub struct GlueCatalogBuilder {
   name: Option<String>,
   ....
}

struct GlueCatalogConfig {
   name: String
}

This makes things easier to read, more importantly, the config class type safe. Builder struct need to store intermediate states, so it's reasonable to have it contains many optional fields. The config struct, which is finally built and verfied, should only contain valid states, e.g. it should no longer has unnecessary optional fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the changes in 400c6b6

pub(crate) struct GlueCatalogConfig {
name: Option<String>,
#[allow(dead_code)] // can be used for debugging
name: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It's a little annoying to have this #[allow(dead_code)] attribute here, is it possible to figure out a way to remove this? For example, adding a Display method, etc.

#[derive(Debug)]
pub(crate) struct HmsCatalogConfig {
#[allow(dead_code)] // Stored for debugging and potential future use
name: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required, we should remove the Option

pub(crate) struct RestCatalogConfig {
#[allow(dead_code)] // Stored for debugging and potential future use
#[builder(default, setter(strip_option))]
name: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

/// Rest catalog configuration.
#[derive(Clone, Debug, TypedBuilder)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this TypedBuilder?

pub(crate) struct S3TablesCatalogConfig {
/// Catalog name.
#[allow(dead_code)] // Stored for debugging and potential future use
name: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

uri: "".to_string(),
name: "".to_string(),
warehouse_location: "".to_string(),
Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could also derive Default?

}
}

impl MemoryCatalogBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minor: Make CatalogBuilder.0 more explicit

2 participants