You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by al...@apache.org on 2025/08/15 13:58:02 UTC
(datafusion) branch main updated: Refactor: Do not silently ignore errors in `stats_projection` (#17154)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 7e38714fa9 Refactor: Do not silently ignore errors in `stats_projection` (#17154)
7e38714fa9 is described below
commit 7e38714fa9821f0fdc99d50728620969fe1eb72a
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Fri Aug 15 06:57:58 2025 -0700
Refactor: Do not silently ignore errors in `stats_projection` (#17154)
---
datafusion/physical-plan/src/projection.rs | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/datafusion/physical-plan/src/projection.rs b/datafusion/physical-plan/src/projection.rs
index 4c0c103a37..d9dbbef5b5 100644
--- a/datafusion/physical-plan/src/projection.rs
+++ b/datafusion/physical-plan/src/projection.rs
@@ -246,11 +246,11 @@ impl ExecutionPlan for ProjectionExec {
fn partition_statistics(&self, partition: Option<usize>) -> Result<Statistics> {
let input_stats = self.input.partition_statistics(partition)?;
- Ok(stats_projection(
+ stats_projection(
input_stats,
self.expr.iter().map(|(e, _)| Arc::clone(e)),
Arc::clone(&self.input.schema()),
- ))
+ )
}
fn supports_limit_pushdown(&self) -> bool {
@@ -279,7 +279,7 @@ fn stats_projection(
mut stats: Statistics,
exprs: impl Iterator<Item = Arc<dyn PhysicalExpr>>,
schema: SchemaRef,
-) -> Statistics {
+) -> Result<Statistics> {
let mut primitive_row_size = 0;
let mut primitive_row_size_possible = true;
let mut column_statistics = vec![];
@@ -292,11 +292,10 @@ fn stats_projection(
ColumnStatistics::new_unknown()
};
column_statistics.push(col_stats);
- if let Ok(data_type) = expr.data_type(&schema) {
- if let Some(value) = data_type.primitive_width() {
- primitive_row_size += value;
- continue;
- }
+ let data_type = expr.data_type(&schema)?;
+ if let Some(value) = data_type.primitive_width() {
+ primitive_row_size += value;
+ continue;
}
primitive_row_size_possible = false;
}
@@ -306,7 +305,7 @@ fn stats_projection(
Precision::Exact(primitive_row_size).multiply(&stats.num_rows);
}
stats.column_statistics = column_statistics;
- stats
+ Ok(stats)
}
impl ProjectionStream {
@@ -1171,7 +1170,8 @@ mod tests {
Arc::new(Column::new("col0", 0)),
];
- let result = stats_projection(source, exprs.into_iter(), Arc::new(schema));
+ let result =
+ stats_projection(source, exprs.into_iter(), Arc::new(schema)).unwrap();
let expected = Statistics {
num_rows: Precision::Exact(5),
@@ -1207,7 +1207,8 @@ mod tests {
Arc::new(Column::new("col0", 0)),
];
- let result = stats_projection(source, exprs.into_iter(), Arc::new(schema));
+ let result =
+ stats_projection(source, exprs.into_iter(), Arc::new(schema)).unwrap();
let expected = Statistics {
num_rows: Precision::Exact(5),
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org