@@ -38,7 +38,7 @@ const DEFAULT_FILE_STATISTICS: &[Stat] = PRUNING_STATS;
3838/// This can be used to configure writer options before acquiring a handle, where we later reuse the options but need to source an available handle.
3939///
4040/// This factory maintains the default behaviour of [`VortexWriteOptions::default`].
41- #[ derive( Clone ) ]
41+ #[ derive( Default , Clone ) ]
4242pub struct VortexWriteOptionsFactory {
4343 strategy : Option < Arc < dyn LayoutStrategy > > ,
4444 exclude_dtype : Option < bool > ,
@@ -59,17 +59,6 @@ impl std::fmt::Debug for VortexWriteOptionsFactory {
5959 }
6060}
6161
62- impl Default for VortexWriteOptionsFactory {
63- fn default ( ) -> Self {
64- Self {
65- strategy : None ,
66- exclude_dtype : None ,
67- max_variable_length_statistics_size : None ,
68- file_statistics : None ,
69- }
70- }
71- }
72-
7362impl VortexWriteOptionsFactory {
7463 /// Create a new builder with default settings.
7564 pub fn new ( ) -> Self {
@@ -112,10 +101,9 @@ impl VortexWriteOptionsFactory {
112101 . strategy
113102 . clone ( )
114103 . unwrap_or_else ( || WriteStrategyBuilder :: new ( ) . build ( ) ) ,
115- exclude_dtype : self . exclude_dtype . clone ( ) . unwrap_or ( DEFAULT_EXCLUDE_DTYPE ) ,
104+ exclude_dtype : self . exclude_dtype . unwrap_or ( DEFAULT_EXCLUDE_DTYPE ) ,
116105 max_variable_length_statistics_size : self
117106 . max_variable_length_statistics_size
118- . clone ( )
119107 . unwrap_or ( DEFAULT_MAX_VARIABLE_LENGTH_STATISTICS_SIZE ) ,
120108 file_statistics : self
121109 . file_statistics
@@ -544,3 +532,22 @@ impl WriteSummary {
544532 self . footer . row_count ( )
545533 }
546534}
535+
536+ #[ cfg( test) ]
537+ mod tests {
538+ use super :: * ;
539+
540+ #[ test]
541+ fn test_write_options_factory ( ) {
542+ let factory = VortexWriteOptionsFactory :: new ( )
543+ . exclude_dtype ( )
544+ . with_max_variable_length_statistics_size ( 128 )
545+ . with_file_statistics ( vec ! [ Stat :: Min , Stat :: Max ] ) ;
546+ let options = factory. build ( ) ;
547+
548+ assert ! ( options. exclude_dtype) ;
549+ assert_eq ! ( options. max_variable_length_statistics_size, 128 ) ;
550+ assert_eq ! ( options. file_statistics, vec![ Stat :: Min , Stat :: Max ] ) ;
551+ assert_eq ! ( options. handle. is_some( ) , false ) ; // test is running synchronously, so no handle
552+ }
553+ }
0 commit comments