bert-beyondloops opened a new pull request, #24027:
URL: https://github.com/apache/datafusion/pull/24027

   
   ## Which issue does this PR close?
   
   - Closes #24026
   
   ## Rationale for this change
   
   `Statistics::calculate_total_byte_size `is meant to derive `total_byte_size` 
from `num_rows` and the schema's fixed-width columns. When all columns have a 
primitive width but `num_rows` is `Precision::Absent`, the old code computed    
     `self.num_rows.multiply(&Precision::Exact(size))`, and 
`Precision::multiply` returns `Precision::Absent` whenever either operand is 
`Absent`. This silently overwrote any previously known `total_byte_size` (exact 
or inexact) with       
     `Absent`, even though the non-primitive-width branch already handled this 
situation correctly by downgrading the existing value to inexact instead of 
discarding it.  
   
   ## What changes are included in this PR?
   
     - In `Statistics::calculate_total_byte_size`, when the schema is all 
fixed-width but num_rows is` Precision::Absent,` keep the existing 
`total_byte_size` and downgrade it to inexact via `to_inexact(),` instead of 
overwriting it with 
     `Absent`.                                                                  
                                                                                
                                                                        
     - Updated the doc comment on `calculate_total_byte_size` to describe this 
behavior.                                                                       
                                                                         
     - Added `test_calculate_total_byte_size` covering: an all-primitive schema 
with known row count (exact size), an all-primitive schema with unknown row 
count (preserved but downgraded to inexact), and a non-primitive schema     
     (always downgraded to inexact regardless of row count).    
   
   ## Are these changes tested?
   
   Yes — added `stats::tests::test_calculate_total_byte_size, exercising all 
three branches of the updated match.  
   
   ## Are there any user-facing changes?
   
     No public API changes. Statistics propagation is more accurate (previously 
known total_byte_size estimates are no longer dropped to Absent when num_rows 
is unknown), which may result in slightly better cost-based planning    
     decisions in some cases.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to