fvaleye commented on code in PR #1598:
URL: https://github.com/apache/iceberg-rust/pull/1598#discussion_r2278839531
##########
crates/catalog/s3tables/src/catalog.rs:
##########
@@ -28,32 +28,124 @@ use iceberg::io::{FileIO, FileIOBuilder};
use iceberg::spec::{TableMetadata, TableMetadataBuilder};
use iceberg::table::Table;
use iceberg::{
- Catalog, Error, ErrorKind, MetadataLocation, Namespace, NamespaceIdent,
Result, TableCommit,
- TableCreation, TableIdent,
+ Catalog, CatalogBuilder, Error, ErrorKind, MetadataLocation, Namespace,
NamespaceIdent, Result,
+ TableCommit, TableCreation, TableIdent,
};
use typed_builder::TypedBuilder;
use crate::utils::create_sdk_config;
+/// S3Tables table bucket ARN property
+pub const S3TABLES_CATALOG_PROP_TABLE_BUCKET_ARN: &str = "table_bucket_arn";
+/// S3Tables endpoint URL property
+pub const S3TABLES_CATALOG_PROP_ENDPOINT_URL: &str = "endpoint_url";
+
/// S3Tables catalog configuration.
#[derive(Debug, TypedBuilder)]
pub struct S3TablesCatalogConfig {
+ /// Catalog name.
+ #[builder(default, setter(strip_option))]
+ name: Option<String>,
/// Unlike other buckets, S3Tables bucket is not a physical bucket, but a
virtual bucket
/// that is managed by s3tables. We can't directly access the bucket with
path like
/// s3://{bucket_name}/{file_path}, all the operations are done with
respect of the bucket
/// ARN.
table_bucket_arn: String,
+ /// Endpoint URL for the catalog.
+ #[builder(default)]
+ endpoint_url: Option<String>,
+ /// Optional pre-configured AWS SDK client for S3Tables.
+ #[builder(default)]
+ client: Option<aws_sdk_s3tables::Client>,
/// Properties for the catalog. The available properties are:
/// - `profile_name`: The name of the AWS profile to use.
/// - `region_name`: The AWS region to use.
/// - `aws_access_key_id`: The AWS access key ID to use.
/// - `aws_secret_access_key`: The AWS secret access key to use.
/// - `aws_session_token`: The AWS session token to use.
#[builder(default)]
- properties: HashMap<String, String>,
- /// Endpoint URL for the catalog.
- #[builder(default, setter(strip_option(fallback = endpoint_url_opt)))]
- endpoint_url: Option<String>,
+ props: HashMap<String, String>,
+}
+
+/// Builder for [`S3TablesCatalog`].
+#[derive(Debug)]
+pub struct S3TablesCatalogBuilder(S3TablesCatalogConfig);
+
+/// Default builder for [`S3TablesCatalog`].
+impl Default for S3TablesCatalogBuilder {
+ fn default() -> Self {
+ Self(S3TablesCatalogConfig {
+ name: None,
+ table_bucket_arn: "".to_string(),
+ endpoint_url: None,
+ client: None,
+ props: HashMap::new(),
+ })
+ }
+}
+
+/// Builder methods for [`S3TablesCatalog`].
+impl S3TablesCatalogBuilder {
+ /// Configure the catalog with a custom endpoint URL (useful for local
testing/mocking).
+ pub fn with_endpoint_url(mut self, endpoint_url: impl Into<String>) ->
Self {
Review Comment:
Ok, I'll add more documentation and proper unit tests.
--
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]