-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
propagate error instead of panicking on out of bounds in physical-expr/src/analysis.rs #10992
Conversation
let field = schema.fields() | ||
.get(col_index) | ||
.ok_or_else(|| DataFusionError::Internal( | ||
format!("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 while.", schema.fields.len()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using internal_datafusion_err
could simplify it.
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 while.",
schema.fields.len()
)
})?;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, that's much more nicer. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks @LorrensP-2158466
…r/src/analysis.rs (apache#10992) * propogate error instead of panicking * use macro for creating internal df error
…r/src/analysis.rs (apache#10992) * propogate error instead of panicking * use macro for creating internal df error
…r/src/analysis.rs (apache#10992) * propogate error instead of panicking * use macro for creating internal df error
Which issue does this PR close?
Closes #10536.
Rationale for this change
In
datafusion/datafusion/physical-expr/src/analysis.rs
Line 95 in cafbc9d
The function panics when
col_index
is out of bounds when returning an internal error with extra context is much more convenient.What changes are included in this PR?
Propagate the error as en
DataFusionError::Internal.
Are these changes tested?
Are there any user-facing changes?
Users may need to handle that error case