@@ -41,11 +41,10 @@ use crate::{
4141use arrow:: array:: { RecordBatch , RecordBatchOptions } ;
4242use arrow:: compute:: concat_batches;
4343use arrow:: datatypes:: { Fields , Schema , SchemaRef } ;
44- use arrow_schema:: DataType ;
4544use datafusion_common:: { internal_err, JoinType , Result , ScalarValue } ;
4645use datafusion_execution:: memory_pool:: { MemoryConsumer , MemoryReservation } ;
4746use datafusion_execution:: TaskContext ;
48- use datafusion_expr:: statistics:: { new_generic_from_binary_op , ColumnStatistics , ProbabilityDistribution , TableStatistics } ;
47+ use datafusion_expr:: statistics:: { ColumnStatistics , ProbabilityDistribution , TableStatistics } ;
4948use datafusion_expr:: Operator ;
5049use datafusion_physical_expr:: equivalence:: join_equivalence_properties;
5150
@@ -397,11 +396,14 @@ fn stats_cartesian_product(
397396 let right_row_count = right_stats. num_rows ;
398397
399398 // calculate global stats
400- let num_rows = new_generic_from_binary_op ( & Operator :: Multiply , & left_row_count, & right_row_count) ?;
399+ let num_rows: ProbabilityDistribution =
400+ ProbabilityDistribution :: combine_distributions ( & Operator :: Multiply , & left_row_count, & right_row_count) ?;
401401 // the result size is two times a*b because you have the columns of both left and right
402- let total_byte_size = new_generic_from_binary_op ( & Operator :: Multiply , & left_stats. total_byte_size , & right_stats. total_byte_size ) ?;
402+ let total_byte_size =
403+ ProbabilityDistribution :: combine_distributions ( & Operator :: Multiply , & left_stats. total_byte_size , & right_stats. total_byte_size ) ?;
403404 let right = ProbabilityDistribution :: new_exact ( ScalarValue :: UInt64 ( Some ( 2 ) ) ) ?;
404- let total_byte_size = new_generic_from_binary_op ( & Operator :: Multiply , & total_byte_size, & right) ?;
405+ let total_byte_size =
406+ ProbabilityDistribution :: combine_distributions ( & Operator :: Multiply , & total_byte_size, & right) ?;
405407
406408 let left_col_stats = left_stats. column_statistics ;
407409 let right_col_stats = right_stats. column_statistics ;
@@ -411,7 +413,8 @@ fn stats_cartesian_product(
411413 let cross_join_stats = left_col_stats
412414 . into_iter ( )
413415 . map ( |s| {
414- let null_count = new_generic_from_binary_op ( & Operator :: Multiply , & s. null_count , & right_row_count) . unwrap_or_default ( ) ;
416+ let null_count =
417+ ProbabilityDistribution :: combine_distributions ( & Operator :: Multiply , & s. null_count , & right_row_count) . unwrap_or_default ( ) ;
415418
416419 ColumnStatistics {
417420 null_count,
@@ -423,13 +426,14 @@ fn stats_cartesian_product(
423426 . get_value ( )
424427 . map ( |row_count| {
425428 let row_count = ProbabilityDistribution :: new_exact ( row_count. clone ( ) ) . unwrap_or_default ( ) ;
426- new_generic_from_binary_op ( & Operator :: Multiply , & s. sum_value , & row_count) . unwrap_or_default ( )
429+ ProbabilityDistribution :: combine_distributions ( & Operator :: Multiply , & s. sum_value , & row_count) . unwrap_or_default ( )
427430 } )
428431 . unwrap_or ( ProbabilityDistribution :: new_unknown ( & s. sum_value . data_type ( ) ) . unwrap_or_default ( ) ) ,
429432 }
430433 } )
431434 . chain ( right_col_stats. into_iter ( ) . map ( |s| {
432- let null_count = new_generic_from_binary_op ( & Operator :: Multiply , & s. null_count , & left_row_count) . unwrap_or_default ( ) ;
435+ let null_count =
436+ ProbabilityDistribution :: combine_distributions ( & Operator :: Multiply , & s. null_count , & left_row_count) . unwrap_or_default ( ) ;
433437
434438 ColumnStatistics {
435439 null_count,
@@ -441,7 +445,7 @@ fn stats_cartesian_product(
441445 . get_value ( )
442446 . map ( |row_count| {
443447 let row_count = ProbabilityDistribution :: new_exact ( row_count. clone ( ) ) . unwrap_or_default ( ) ;
444- new_generic_from_binary_op ( & Operator :: Multiply , & s. sum_value , & row_count) . unwrap_or_default ( )
448+ ProbabilityDistribution :: combine_distributions ( & Operator :: Multiply , & s. sum_value , & row_count) . unwrap_or_default ( )
445449 } )
446450 . unwrap_or ( ProbabilityDistribution :: new_unknown ( & s. sum_value . data_type ( ) ) . unwrap_or_default ( ) ) ,
447451 }
0 commit comments