Skip to content

Commit 1282170

Browse files
authored
Minor: simplify code in datafusion-proto (#15752)
1 parent 57a99e4 commit 1282170

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

datafusion/proto-common/src/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
use datafusion_common::{internal_datafusion_err, DataFusionError};
1919

20+
/// Return a `DataFusionError::Internal` with the given message
2021
pub fn proto_error<S: Into<String>>(message: S) -> DataFusionError {
2122
internal_datafusion_err!("{}", message.into())
2223
}

datafusion/proto/src/logical_plan/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,7 @@ impl AsLogicalPlan for LogicalPlanNode {
355355
.as_ref()
356356
.map(|expr| from_proto::parse_expr(expr, ctx, extension_codec))
357357
.transpose()?
358-
.ok_or_else(|| {
359-
DataFusionError::Internal("expression required".to_string())
360-
})?;
361-
// .try_into()?;
358+
.ok_or_else(|| proto_error("expression required"))?;
362359
LogicalPlanBuilder::from(input).filter(expr)?.build()
363360
}
364361
LogicalPlanType::Window(window) => {
@@ -464,7 +461,7 @@ impl AsLogicalPlan for LogicalPlanNode {
464461
.map(|col| {
465462
let Some(arrow_type) = col.arrow_type.as_ref() else {
466463
return Err(proto_error(
467-
"Missing Arrow type in partition columns".to_string(),
464+
"Missing Arrow type in partition columns",
468465
));
469466
};
470467
let arrow_type = DataType::try_from(arrow_type).map_err(|e| {

0 commit comments

Comments
 (0)