@@ -69,8 +69,14 @@ pub const S3_DISABLE_CONFIG_LOAD: &str = "s3.disable-config-load";
6969///
7070/// This struct contains all the configuration options for connecting to Amazon S3.
7171/// Use the builder pattern via `S3Config::builder()` to construct instances.
72- /// ```
73- #[ derive( Clone , Debug , Default , PartialEq , Eq , Serialize , Deserialize , TypedBuilder ) ]
72+ ///
73+ /// Defaults follow the Iceberg `S3FileIOProperties` spec (see
74+ /// [`PATH_STYLE_ACCESS_DEFAULT = false`](https://github.com/apache/iceberg/blob/main/aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIOProperties.java)),
75+ /// i.e. virtual-host-style addressing is enabled unless
76+ /// `s3.path-style-access=true` is explicitly set. This matches what
77+ /// Java clients do out of the box and is required for a number of
78+ /// S3-compatible stores that do not support path-style URLs.
79+ #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize , TypedBuilder ) ]
7480pub struct S3Config {
7581 /// S3 endpoint URL.
7682 #[ builder( default , setter( strip_option, into) ) ]
@@ -88,7 +94,9 @@ pub struct S3Config {
8894 #[ builder( default , setter( strip_option, into) ) ]
8995 pub region : Option < String > ,
9096 /// Enable virtual host style (opposite of path style access).
91- #[ builder( default ) ]
97+ ///
98+ /// Defaults to `true` to match Iceberg `S3FileIOProperties.PATH_STYLE_ACCESS_DEFAULT = false`.
99+ #[ builder( default = true ) ]
92100 pub enable_virtual_host_style : bool ,
93101 /// Server side encryption type.
94102 #[ builder( default , setter( strip_option, into) ) ]
@@ -125,6 +133,12 @@ pub struct S3Config {
125133 pub disable_config_load : bool ,
126134}
127135
136+ impl Default for S3Config {
137+ fn default ( ) -> Self {
138+ Self :: builder ( ) . build ( )
139+ }
140+ }
141+
128142impl TryFrom < & StorageConfig > for S3Config {
129143 type Error = crate :: Error ;
130144
@@ -267,6 +281,17 @@ mod tests {
267281 assert_eq ! ( s3_config. region. as_deref( ) , Some ( "eu-west-1" ) ) ;
268282 }
269283
284+ #[ test]
285+ fn test_s3_config_default_is_virtual_host_style ( ) {
286+ // Matches Iceberg S3FileIOProperties.PATH_STYLE_ACCESS_DEFAULT = false.
287+ assert ! ( S3Config :: default ( ) . enable_virtual_host_style) ;
288+ assert ! (
289+ S3Config :: try_from( & StorageConfig :: new( ) )
290+ . unwrap( )
291+ . enable_virtual_host_style
292+ ) ;
293+ }
294+
270295 #[ test]
271296 fn test_s3_config_path_style_access ( ) {
272297 let storage_config = StorageConfig :: new ( ) . with_prop ( S3_PATH_STYLE_ACCESS , "true" ) ;
0 commit comments