@@ -40,7 +40,7 @@ use datafusion_common::{
4040 DataFusionError , JoinSide , ScalarValue , Statistics , TableReference ,
4141 arrow_datafusion_err,
4242 config:: {
43- CsvOptions , JsonOptions , ParquetColumnOptions , ParquetOptions ,
43+ CdcOptions , CsvOptions , JsonOptions , ParquetColumnOptions , ParquetOptions ,
4444 TableParquetOptions ,
4545 } ,
4646 file_options:: { csv_writer:: CsvWriterOptions , json_writer:: JsonWriterOptions } ,
@@ -1090,16 +1090,14 @@ impl TryFrom<&protobuf::ParquetOptions> for ParquetOptions {
10901090 max_predicate_cache_size : value. max_predicate_cache_size_opt . map ( |opt| match opt {
10911091 protobuf:: parquet_options:: MaxPredicateCacheSizeOpt :: MaxPredicateCacheSize ( v) => Some ( v as usize ) ,
10921092 } ) . unwrap_or ( None ) ,
1093- enable_content_defined_chunking : value. content_defined_chunking ,
1094- cdc_min_chunk_size : value. cdc_min_chunk_size_opt . map ( |opt| match opt {
1095- protobuf:: parquet_options:: CdcMinChunkSizeOpt :: CdcMinChunkSize ( v) => v as usize ,
1096- } ) . unwrap_or ( ParquetOptions :: default ( ) . cdc_min_chunk_size ) ,
1097- cdc_max_chunk_size : value. cdc_max_chunk_size_opt . map ( |opt| match opt {
1098- protobuf:: parquet_options:: CdcMaxChunkSizeOpt :: CdcMaxChunkSize ( v) => v as usize ,
1099- } ) . unwrap_or ( ParquetOptions :: default ( ) . cdc_max_chunk_size ) ,
1100- cdc_norm_level : value. cdc_norm_level_opt . map ( |opt| match opt {
1101- protobuf:: parquet_options:: CdcNormLevelOpt :: CdcNormLevel ( v) => v as i64 ,
1102- } ) . unwrap_or ( ParquetOptions :: default ( ) . cdc_norm_level ) ,
1093+ use_content_defined_chunking : value. content_defined_chunking . map ( |cdc| {
1094+ let defaults = CdcOptions :: default ( ) ;
1095+ CdcOptions {
1096+ min_chunk_size : if cdc. min_chunk_size != 0 { cdc. min_chunk_size as usize } else { defaults. min_chunk_size } ,
1097+ max_chunk_size : if cdc. max_chunk_size != 0 { cdc. max_chunk_size as usize } else { defaults. max_chunk_size } ,
1098+ norm_level : cdc. norm_level as i64 ,
1099+ }
1100+ } ) ,
11031101 } )
11041102 }
11051103}
@@ -1276,7 +1274,7 @@ pub(crate) fn csv_writer_options_from_proto(
12761274#[ cfg( test) ]
12771275mod tests {
12781276 use super :: * ;
1279- use datafusion_common:: config:: { ParquetOptions , TableParquetOptions } ;
1277+ use datafusion_common:: config:: { CdcOptions , ParquetOptions , TableParquetOptions } ;
12801278
12811279 fn parquet_options_proto_round_trip ( opts : ParquetOptions ) -> ParquetOptions {
12821280 let proto: crate :: protobuf_common:: ParquetOptions =
@@ -1295,66 +1293,65 @@ mod tests {
12951293 #[ test]
12961294 fn test_parquet_options_cdc_disabled_round_trip ( ) {
12971295 let opts = ParquetOptions :: default ( ) ;
1298- assert ! ( ! opts. enable_content_defined_chunking ) ;
1296+ assert ! ( opts. use_content_defined_chunking . is_none ( ) ) ;
12991297 let recovered = parquet_options_proto_round_trip ( opts. clone ( ) ) ;
13001298 assert_eq ! ( opts, recovered) ;
13011299 }
13021300
13031301 #[ test]
13041302 fn test_parquet_options_cdc_enabled_round_trip ( ) {
13051303 let opts = ParquetOptions {
1306- enable_content_defined_chunking : true ,
1307- cdc_min_chunk_size : 128 * 1024 ,
1308- cdc_max_chunk_size : 512 * 1024 ,
1309- cdc_norm_level : 2 ,
1304+ use_content_defined_chunking : Some ( CdcOptions {
1305+ min_chunk_size : 128 * 1024 ,
1306+ max_chunk_size : 512 * 1024 ,
1307+ norm_level : 2 ,
1308+ } ) ,
13101309 ..ParquetOptions :: default ( )
13111310 } ;
13121311 let recovered = parquet_options_proto_round_trip ( opts. clone ( ) ) ;
1313- assert_eq ! ( recovered. enable_content_defined_chunking , true ) ;
1314- assert_eq ! ( recovered . cdc_min_chunk_size , 128 * 1024 ) ;
1315- assert_eq ! ( recovered . cdc_max_chunk_size , 512 * 1024 ) ;
1316- assert_eq ! ( recovered . cdc_norm_level , 2 ) ;
1312+ let cdc = recovered. use_content_defined_chunking . unwrap ( ) ;
1313+ assert_eq ! ( cdc . min_chunk_size , 128 * 1024 ) ;
1314+ assert_eq ! ( cdc . max_chunk_size , 512 * 1024 ) ;
1315+ assert_eq ! ( cdc . norm_level , 2 ) ;
13171316 }
13181317
13191318 #[ test]
13201319 fn test_parquet_options_cdc_negative_norm_level_round_trip ( ) {
13211320 let opts = ParquetOptions {
1322- enable_content_defined_chunking : true ,
1323- cdc_norm_level : -3 ,
1321+ use_content_defined_chunking : Some ( CdcOptions {
1322+ norm_level : -3 ,
1323+ ..CdcOptions :: default ( )
1324+ } ) ,
13241325 ..ParquetOptions :: default ( )
13251326 } ;
13261327 let recovered = parquet_options_proto_round_trip ( opts) ;
1327- assert_eq ! ( recovered. cdc_norm_level, -3 ) ;
1328+ assert_eq ! (
1329+ recovered. use_content_defined_chunking. unwrap( ) . norm_level,
1330+ -3
1331+ ) ;
13281332 }
13291333
13301334 #[ test]
13311335 fn test_table_parquet_options_cdc_round_trip ( ) {
13321336 let mut opts = TableParquetOptions :: default ( ) ;
1333- opts. global . enable_content_defined_chunking = true ;
1334- opts. global . cdc_min_chunk_size = 64 * 1024 ;
1335- opts. global . cdc_max_chunk_size = 2 * 1024 * 1024 ;
1336- opts. global . cdc_norm_level = -1 ;
1337+ opts. global . use_content_defined_chunking = Some ( CdcOptions {
1338+ min_chunk_size : 64 * 1024 ,
1339+ max_chunk_size : 2 * 1024 * 1024 ,
1340+ norm_level : -1 ,
1341+ } ) ;
13371342
13381343 let recovered = table_parquet_options_proto_round_trip ( opts. clone ( ) ) ;
1339- assert_eq ! ( recovered. global. enable_content_defined_chunking , true ) ;
1340- assert_eq ! ( recovered . global . cdc_min_chunk_size , 64 * 1024 ) ;
1341- assert_eq ! ( recovered . global . cdc_max_chunk_size , 2 * 1024 * 1024 ) ;
1342- assert_eq ! ( recovered . global . cdc_norm_level , -1 ) ;
1344+ let cdc = recovered. global . use_content_defined_chunking . unwrap ( ) ;
1345+ assert_eq ! ( cdc . min_chunk_size , 64 * 1024 ) ;
1346+ assert_eq ! ( cdc . max_chunk_size , 2 * 1024 * 1024 ) ;
1347+ assert_eq ! ( cdc . norm_level , -1 ) ;
13431348 }
13441349
13451350 #[ test]
13461351 fn test_table_parquet_options_cdc_disabled_round_trip ( ) {
13471352 let opts = TableParquetOptions :: default ( ) ;
1348- assert ! ( ! opts. global. enable_content_defined_chunking ) ;
1353+ assert ! ( opts. global. use_content_defined_chunking . is_none ( ) ) ;
13491354 let recovered = table_parquet_options_proto_round_trip ( opts. clone ( ) ) ;
1350- assert_eq ! ( recovered. global. enable_content_defined_chunking, false ) ;
1351- assert_eq ! (
1352- recovered. global. cdc_min_chunk_size,
1353- ParquetOptions :: default ( ) . cdc_min_chunk_size
1354- ) ;
1355- assert_eq ! (
1356- recovered. global. cdc_max_chunk_size,
1357- ParquetOptions :: default ( ) . cdc_max_chunk_size
1358- ) ;
1355+ assert ! ( recovered. global. use_content_defined_chunking. is_none( ) ) ;
13591356 }
13601357}
0 commit comments