jackwener commented on code in PR #7428:
URL: https://github.com/apache/arrow-datafusion/pull/7428#discussion_r1306840029
##########
datafusion/core/src/physical_plan/projection.rs:
##########
@@ -410,12 +415,39 @@ fn stats_projection(
.collect()
});
- Statistics {
- is_exact: stats.is_exact,
- num_rows: stats.num_rows,
- column_statistics,
- // TODO stats: knowing the type of the new columns we can guess the
output size
- total_byte_size: None,
+ let primitive_row_size = inner_exprs
+ .clone()
+ .into_iter()
+ .map(|e| match e.data_type(schema.as_ref()) {
+ Ok(data_type) => data_type.primitive_width(),
+ Err(_) => None,
+ })
+ .fold(Some(0usize), |init, v| match (init, v) {
+ (Some(l), Some(r)) => Some(l + r),
+ _ => None,
+ });
+
+ match (primitive_row_size, stats.num_rows) {
+ (Some(row_size), Some(row_count)) => {
+ Statistics {
+ is_exact: stats.is_exact,
+ num_rows: stats.num_rows,
+ column_statistics,
+ // Use the row_size * row_count as the total byte size
+ total_byte_size: Some(row_size * row_count),
+ }
+ }
+ _ => {
+ Statistics {
+ is_exact: stats.is_exact,
Review Comment:
Should we use false here? I'm not sure
--
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]