Skip to content

Commit

Permalink
propagate error instead of panicking on out of bounds in physical-exp…
Browse files Browse the repository at this point in the history
…r/src/analysis.rs (apache#10992)

* propogate error instead of panicking

* use macro for creating internal df error
  • Loading branch information
LorrensP-2158466 authored and findepi committed Jul 16, 2024
1 parent 19e13b8 commit 9943740
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions datafusion/physical-expr/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use crate::PhysicalExpr;

use arrow::datatypes::Schema;
use datafusion_common::stats::Precision;
use datafusion_common::{internal_err, ColumnStatistics, Result, ScalarValue};
use datafusion_common::{
internal_datafusion_err, internal_err, ColumnStatistics, Result, ScalarValue,
};
use datafusion_expr::interval_arithmetic::{cardinality_ratio, Interval};

/// The shared context used during the analysis of an expression. Includes
Expand Down Expand Up @@ -92,7 +94,13 @@ impl ExprBoundaries {
col_stats: &ColumnStatistics,
col_index: usize,
) -> Result<Self> {
let field = &schema.fields()[col_index];
let field = schema.fields().get(col_index).ok_or_else(|| {
internal_datafusion_err!(
"Could not create `ExprBoundaries`: in `try_from_column` `col_index`
has gone out of bounds with a value of {col_index}, the schema has {} columns.",
schema.fields.len()
)
})?;
let empty_field =
ScalarValue::try_from(field.data_type()).unwrap_or(ScalarValue::Null);
let interval = Interval::try_new(
Expand Down

0 comments on commit 9943740

Please sign in to comment.