Skip to content

Commit 812b9e0

Browse files
committed
Improve NotExpr proto decode error
Signed-off-by: Herrtian <70463940+Herrtian@users.noreply.github.com>
1 parent 15800c7 commit 812b9e0

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

  • datafusion/physical-expr/src/expressions

datafusion/physical-expr/src/expressions/not.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ use crate::PhysicalExpr;
2525

2626
use arrow::datatypes::{DataType, FieldRef, Schema};
2727
use arrow::record_batch::RecordBatch;
28-
use datafusion_common::{Result, ScalarValue, cast::as_boolean_array, internal_err};
28+
use datafusion_common::{
29+
Result, ScalarValue, cast::as_boolean_array, internal_datafusion_err, internal_err,
30+
};
2931
use datafusion_expr::ColumnarValue;
3032
use datafusion_expr::interval_arithmetic::Interval;
3133
#[expect(deprecated)]
@@ -214,8 +216,9 @@ impl NotExpr {
214216
_ => return internal_err!("PhysicalExprNode is not a NotExpr"),
215217
};
216218
let expr = expr.as_deref().ok_or_else(|| {
217-
datafusion_common::DataFusionError::Internal(
218-
"NotExpr is missing required field 'expr'".to_string(),
219+
internal_datafusion_err!(
220+
"NotExpr is missing required field 'expr' (expr_id: {:?}, expr_type: NotExpr)",
221+
node.expr_id
219222
)
220223
})?;
221224

@@ -262,7 +265,7 @@ mod tests {
262265
}
263266

264267
let node = PhysicalExprNode {
265-
expr_id: None,
268+
expr_id: Some(42),
266269
expr_type: Some(physical_expr_node::ExprType::NotExpr(Box::new(
267270
PhysicalNot { expr: None },
268271
))),
@@ -272,9 +275,10 @@ mod tests {
272275
let ctx = PhysicalExprDecodeCtx::new(&schema, &decoder);
273276

274277
let err = NotExpr::try_from_proto(&node, &ctx).unwrap_err();
275-
assert!(
276-
matches!(err, DataFusionError::Internal(msg) if msg == "NotExpr is missing required field 'expr'")
277-
);
278+
assert!(matches!(err, DataFusionError::Internal(msg)
279+
if msg.contains("NotExpr is missing required field 'expr'")
280+
&& msg.contains("expr_id: Some(42)")
281+
&& msg.contains("expr_type: NotExpr")));
278282
}
279283

280284
#[test]

0 commit comments

Comments
 (0)