@@ -39,7 +39,7 @@ use datafusion_common::{
3939 DataFusionError , JoinSide , ScalarValue , Statistics , TableReference ,
4040 arrow_datafusion_err,
4141 config:: {
42- CsvOptions , JsonOptions , ParquetColumnOptions , ParquetOptions ,
42+ CdcOptions , CsvOptions , JsonOptions , ParquetColumnOptions , ParquetOptions ,
4343 TableParquetOptions ,
4444 } ,
4545 file_options:: { csv_writer:: CsvWriterOptions , json_writer:: JsonWriterOptions } ,
@@ -1089,16 +1089,14 @@ impl TryFrom<&protobuf::ParquetOptions> for ParquetOptions {
10891089 max_predicate_cache_size : value. max_predicate_cache_size_opt . map ( |opt| match opt {
10901090 protobuf:: parquet_options:: MaxPredicateCacheSizeOpt :: MaxPredicateCacheSize ( v) => Some ( v as usize ) ,
10911091 } ) . unwrap_or ( None ) ,
1092- enable_content_defined_chunking : value. content_defined_chunking ,
1093- cdc_min_chunk_size : value. cdc_min_chunk_size_opt . map ( |opt| match opt {
1094- protobuf:: parquet_options:: CdcMinChunkSizeOpt :: CdcMinChunkSize ( v) => v as usize ,
1095- } ) . unwrap_or ( ParquetOptions :: default ( ) . cdc_min_chunk_size ) ,
1096- cdc_max_chunk_size : value. cdc_max_chunk_size_opt . map ( |opt| match opt {
1097- protobuf:: parquet_options:: CdcMaxChunkSizeOpt :: CdcMaxChunkSize ( v) => v as usize ,
1098- } ) . unwrap_or ( ParquetOptions :: default ( ) . cdc_max_chunk_size ) ,
1099- cdc_norm_level : value. cdc_norm_level_opt . map ( |opt| match opt {
1100- protobuf:: parquet_options:: CdcNormLevelOpt :: CdcNormLevel ( v) => v as i64 ,
1101- } ) . unwrap_or ( ParquetOptions :: default ( ) . cdc_norm_level ) ,
1092+ use_content_defined_chunking : value. content_defined_chunking . map ( |cdc| {
1093+ let defaults = CdcOptions :: default ( ) ;
1094+ CdcOptions {
1095+ min_chunk_size : if cdc. min_chunk_size != 0 { cdc. min_chunk_size as usize } else { defaults. min_chunk_size } ,
1096+ max_chunk_size : if cdc. max_chunk_size != 0 { cdc. max_chunk_size as usize } else { defaults. max_chunk_size } ,
1097+ norm_level : cdc. norm_level as i64 ,
1098+ }
1099+ } ) ,
11021100 } )
11031101 }
11041102}
@@ -1275,7 +1273,7 @@ pub(crate) fn csv_writer_options_from_proto(
12751273#[ cfg( test) ]
12761274mod tests {
12771275 use super :: * ;
1278- use datafusion_common:: config:: { ParquetOptions , TableParquetOptions } ;
1276+ use datafusion_common:: config:: { CdcOptions , ParquetOptions , TableParquetOptions } ;
12791277
12801278 fn parquet_options_proto_round_trip ( opts : ParquetOptions ) -> ParquetOptions {
12811279 let proto: crate :: protobuf_common:: ParquetOptions =
@@ -1294,66 +1292,65 @@ mod tests {
12941292 #[ test]
12951293 fn test_parquet_options_cdc_disabled_round_trip ( ) {
12961294 let opts = ParquetOptions :: default ( ) ;
1297- assert ! ( ! opts. enable_content_defined_chunking ) ;
1295+ assert ! ( opts. use_content_defined_chunking . is_none ( ) ) ;
12981296 let recovered = parquet_options_proto_round_trip ( opts. clone ( ) ) ;
12991297 assert_eq ! ( opts, recovered) ;
13001298 }
13011299
13021300 #[ test]
13031301 fn test_parquet_options_cdc_enabled_round_trip ( ) {
13041302 let opts = ParquetOptions {
1305- enable_content_defined_chunking : true ,
1306- cdc_min_chunk_size : 128 * 1024 ,
1307- cdc_max_chunk_size : 512 * 1024 ,
1308- cdc_norm_level : 2 ,
1303+ use_content_defined_chunking : Some ( CdcOptions {
1304+ min_chunk_size : 128 * 1024 ,
1305+ max_chunk_size : 512 * 1024 ,
1306+ norm_level : 2 ,
1307+ } ) ,
13091308 ..ParquetOptions :: default ( )
13101309 } ;
13111310 let recovered = parquet_options_proto_round_trip ( opts. clone ( ) ) ;
1312- assert_eq ! ( recovered. enable_content_defined_chunking , true ) ;
1313- assert_eq ! ( recovered . cdc_min_chunk_size , 128 * 1024 ) ;
1314- assert_eq ! ( recovered . cdc_max_chunk_size , 512 * 1024 ) ;
1315- assert_eq ! ( recovered . cdc_norm_level , 2 ) ;
1311+ let cdc = recovered. use_content_defined_chunking . unwrap ( ) ;
1312+ assert_eq ! ( cdc . min_chunk_size , 128 * 1024 ) ;
1313+ assert_eq ! ( cdc . max_chunk_size , 512 * 1024 ) ;
1314+ assert_eq ! ( cdc . norm_level , 2 ) ;
13161315 }
13171316
13181317 #[ test]
13191318 fn test_parquet_options_cdc_negative_norm_level_round_trip ( ) {
13201319 let opts = ParquetOptions {
1321- enable_content_defined_chunking : true ,
1322- cdc_norm_level : -3 ,
1320+ use_content_defined_chunking : Some ( CdcOptions {
1321+ norm_level : -3 ,
1322+ ..CdcOptions :: default ( )
1323+ } ) ,
13231324 ..ParquetOptions :: default ( )
13241325 } ;
13251326 let recovered = parquet_options_proto_round_trip ( opts) ;
1326- assert_eq ! ( recovered. cdc_norm_level, -3 ) ;
1327+ assert_eq ! (
1328+ recovered. use_content_defined_chunking. unwrap( ) . norm_level,
1329+ -3
1330+ ) ;
13271331 }
13281332
13291333 #[ test]
13301334 fn test_table_parquet_options_cdc_round_trip ( ) {
13311335 let mut opts = TableParquetOptions :: default ( ) ;
1332- opts. global . enable_content_defined_chunking = true ;
1333- opts. global . cdc_min_chunk_size = 64 * 1024 ;
1334- opts. global . cdc_max_chunk_size = 2 * 1024 * 1024 ;
1335- opts. global . cdc_norm_level = -1 ;
1336+ opts. global . use_content_defined_chunking = Some ( CdcOptions {
1337+ min_chunk_size : 64 * 1024 ,
1338+ max_chunk_size : 2 * 1024 * 1024 ,
1339+ norm_level : -1 ,
1340+ } ) ;
13361341
13371342 let recovered = table_parquet_options_proto_round_trip ( opts. clone ( ) ) ;
1338- assert_eq ! ( recovered. global. enable_content_defined_chunking , true ) ;
1339- assert_eq ! ( recovered . global . cdc_min_chunk_size , 64 * 1024 ) ;
1340- assert_eq ! ( recovered . global . cdc_max_chunk_size , 2 * 1024 * 1024 ) ;
1341- assert_eq ! ( recovered . global . cdc_norm_level , -1 ) ;
1343+ let cdc = recovered. global . use_content_defined_chunking . unwrap ( ) ;
1344+ assert_eq ! ( cdc . min_chunk_size , 64 * 1024 ) ;
1345+ assert_eq ! ( cdc . max_chunk_size , 2 * 1024 * 1024 ) ;
1346+ assert_eq ! ( cdc . norm_level , -1 ) ;
13421347 }
13431348
13441349 #[ test]
13451350 fn test_table_parquet_options_cdc_disabled_round_trip ( ) {
13461351 let opts = TableParquetOptions :: default ( ) ;
1347- assert ! ( ! opts. global. enable_content_defined_chunking ) ;
1352+ assert ! ( opts. global. use_content_defined_chunking . is_none ( ) ) ;
13481353 let recovered = table_parquet_options_proto_round_trip ( opts. clone ( ) ) ;
1349- assert_eq ! ( recovered. global. enable_content_defined_chunking, false ) ;
1350- assert_eq ! (
1351- recovered. global. cdc_min_chunk_size,
1352- ParquetOptions :: default ( ) . cdc_min_chunk_size
1353- ) ;
1354- assert_eq ! (
1355- recovered. global. cdc_max_chunk_size,
1356- ParquetOptions :: default ( ) . cdc_max_chunk_size
1357- ) ;
1354+ assert ! ( recovered. global. use_content_defined_chunking. is_none( ) ) ;
13581355 }
13591356}
0 commit comments