@@ -53,6 +53,8 @@ pub const DEFAULT_BLOOM_FILTER_FPP: f64 = 0.05;
53
53
pub const DEFAULT_BLOOM_FILTER_NDV : u64 = 1_000_000_u64 ;
54
54
/// Default values for [`WriterProperties::statistics_truncate_length`]
55
55
pub const DEFAULT_STATISTICS_TRUNCATE_LENGTH : Option < usize > = None ;
56
+ /// Default values for [`WriterProperties::coerce_types`]
57
+ pub const DEFAULT_COERCE_TYPES : bool = false ;
56
58
57
59
/// Parquet writer version.
58
60
///
@@ -139,6 +141,7 @@ pub struct WriterProperties {
139
141
sorting_columns : Option < Vec < SortingColumn > > ,
140
142
column_index_truncate_length : Option < usize > ,
141
143
statistics_truncate_length : Option < usize > ,
144
+ coerce_types : bool ,
142
145
}
143
146
144
147
impl Default for WriterProperties {
@@ -251,6 +254,13 @@ impl WriterProperties {
251
254
self . statistics_truncate_length
252
255
}
253
256
257
+ /// Returns `coerce_types` boolean
258
+ ///
259
+ /// `true` if type coercion enabled.
260
+ pub fn coerce_types ( & self ) -> bool {
261
+ self . coerce_types
262
+ }
263
+
254
264
/// Returns encoding for a data page, when dictionary encoding is enabled.
255
265
/// This is not configurable.
256
266
#[ inline]
@@ -345,6 +355,7 @@ pub struct WriterPropertiesBuilder {
345
355
sorting_columns : Option < Vec < SortingColumn > > ,
346
356
column_index_truncate_length : Option < usize > ,
347
357
statistics_truncate_length : Option < usize > ,
358
+ coerce_types : bool ,
348
359
}
349
360
350
361
impl WriterPropertiesBuilder {
@@ -364,6 +375,7 @@ impl WriterPropertiesBuilder {
364
375
sorting_columns : None ,
365
376
column_index_truncate_length : DEFAULT_COLUMN_INDEX_TRUNCATE_LENGTH ,
366
377
statistics_truncate_length : DEFAULT_STATISTICS_TRUNCATE_LENGTH ,
378
+ coerce_types : DEFAULT_COERCE_TYPES ,
367
379
}
368
380
}
369
381
@@ -383,6 +395,7 @@ impl WriterPropertiesBuilder {
383
395
sorting_columns : self . sorting_columns ,
384
396
column_index_truncate_length : self . column_index_truncate_length ,
385
397
statistics_truncate_length : self . statistics_truncate_length ,
398
+ coerce_types : self . coerce_types ,
386
399
}
387
400
}
388
401
@@ -667,6 +680,13 @@ impl WriterPropertiesBuilder {
667
680
self . statistics_truncate_length = max_length;
668
681
self
669
682
}
683
+
684
+ /// Sets flag to enable/disable type coercion.
685
+ /// Takes precedence over globally defined settings.
686
+ pub fn set_coerce_types ( mut self , coerce_types : bool ) -> Self {
687
+ self . coerce_types = coerce_types;
688
+ self
689
+ }
670
690
}
671
691
672
692
/// Controls the level of statistics to be computed by the writer
0 commit comments