7
7
//! with a [data stream][datafusion::physical_plan::SendableRecordBatchStream],
8
8
//! if the operation returns data as well.
9
9
use async_trait:: async_trait;
10
+ use delta_kernel:: table_properties:: { DataSkippingNumIndexedCols , TableProperties } ;
10
11
use std:: collections:: HashMap ;
11
12
use std:: sync:: Arc ;
12
13
use update_field_metadata:: UpdateFieldMetadataBuilder ;
@@ -36,6 +37,7 @@ use self::{
36
37
use crate :: errors:: { DeltaResult , DeltaTableError } ;
37
38
use crate :: logstore:: LogStoreRef ;
38
39
use crate :: table:: builder:: DeltaTableBuilder ;
40
+ use crate :: table:: config:: { TablePropertiesExt as _, DEFAULT_NUM_INDEX_COLS } ;
39
41
use crate :: DeltaTable ;
40
42
41
43
pub mod add_column;
@@ -333,19 +335,33 @@ impl AsRef<DeltaTable> for DeltaOps {
333
335
/// If table_config does not exist (only can occur in the first write action) it takes
334
336
/// the configuration that was passed to the writerBuilder.
335
337
pub fn get_num_idx_cols_and_stats_columns (
336
- config : Option < crate :: table :: config :: TableConfig < ' _ > > ,
338
+ config : Option < & TableProperties > ,
337
339
configuration : HashMap < String , Option < String > > ,
338
- ) -> ( i32 , Option < Vec < String > > ) {
340
+ ) -> ( DataSkippingNumIndexedCols , Option < Vec < String > > ) {
339
341
let ( num_index_cols, stats_columns) = match & config {
340
- Some ( conf) => ( conf. num_indexed_cols ( ) , conf. stats_columns ( ) ) ,
342
+ Some ( conf) => (
343
+ conf. num_indexed_cols ( ) ,
344
+ conf. data_skipping_stats_columns
345
+ . clone ( )
346
+ . map ( |v| v. iter ( ) . map ( |v| v. to_string ( ) ) . collect :: < Vec < String > > ( ) ) ,
347
+ ) ,
341
348
_ => (
342
349
configuration
343
350
. get ( "delta.dataSkippingNumIndexedCols" )
344
- . and_then ( |v| v. clone ( ) . map ( |v| v. parse :: < i32 > ( ) . unwrap ( ) ) )
345
- . unwrap_or ( crate :: table:: config:: DEFAULT_NUM_INDEX_COLS ) ,
351
+ . and_then ( |v| {
352
+ v. as_ref ( )
353
+ . and_then ( |vv| vv. parse :: < u64 > ( ) . ok ( ) )
354
+ . map ( DataSkippingNumIndexedCols :: NumColumns )
355
+ } )
356
+ . unwrap_or ( DataSkippingNumIndexedCols :: NumColumns (
357
+ DEFAULT_NUM_INDEX_COLS ,
358
+ ) ) ,
346
359
configuration
347
360
. get ( "delta.dataSkippingStatsColumns" )
348
- . and_then ( |v| v. as_ref ( ) . map ( |v| v. split ( ',' ) . collect :: < Vec < & str > > ( ) ) ) ,
361
+ . and_then ( |v| {
362
+ v. as_ref ( )
363
+ . map ( |v| v. split ( ',' ) . map ( |s| s. to_string ( ) ) . collect :: < Vec < String > > ( ) )
364
+ } ) ,
349
365
) ,
350
366
} ;
351
367
(
@@ -360,14 +376,14 @@ pub fn get_num_idx_cols_and_stats_columns(
360
376
/// If table_config does not exist (only can occur in the first write action) it takes
361
377
/// the configuration that was passed to the writerBuilder.
362
378
pub ( crate ) fn get_target_file_size (
363
- config : & Option < crate :: table :: config :: TableConfig < ' _ > > ,
379
+ config : Option < & TableProperties > ,
364
380
configuration : & HashMap < String , Option < String > > ,
365
- ) -> i64 {
381
+ ) -> u64 {
366
382
match & config {
367
- Some ( conf) => conf. target_file_size ( ) ,
383
+ Some ( conf) => conf. target_file_size ( ) . get ( ) ,
368
384
_ => configuration
369
385
. get ( "delta.targetFileSize" )
370
- . and_then ( |v| v. clone ( ) . map ( |v| v. parse :: < i64 > ( ) . unwrap ( ) ) )
386
+ . and_then ( |v| v. clone ( ) . map ( |v| v. parse :: < u64 > ( ) . unwrap ( ) ) )
371
387
. unwrap_or ( crate :: table:: config:: DEFAULT_TARGET_FILE_SIZE ) ,
372
388
}
373
389
}
0 commit comments