adriangb commented on code in PR #22463:
URL: https://github.com/apache/datafusion/pull/22463#discussion_r3320105797
##########
datafusion/physical-expr/src/expressions/not.rs:
##########
@@ -198,6 +241,46 @@ mod tests {
use arrow::{array::BooleanArray, datatypes::*};
use datafusion_physical_expr_common::physical_expr::fmt_sql;
+ #[cfg(feature = "proto")]
+ #[test]
+ fn test_from_proto_missing_child() {
+ use datafusion_common::DataFusionError;
+ use datafusion_physical_expr_common::physical_expr::proto_decode::{
+ PhysicalExprDecode, PhysicalExprDecodeCtx,
+ };
+ use datafusion_proto_models::protobuf::{
+ PhysicalExprNode, PhysicalNot, physical_expr_node,
+ };
+
+ struct NoopDecoder;
+
+ impl PhysicalExprDecode for NoopDecoder {
+ fn decode(
+ &self,
+ _node: &PhysicalExprNode,
+ _schema: &Schema,
+ ) -> Result<Arc<dyn PhysicalExpr>> {
+ unreachable!("missing child should be rejected before
decoding")
+ }
+ }
+
+ let node = PhysicalExprNode {
+ expr_id: Some(42),
+ expr_type: Some(physical_expr_node::ExprType::NotExpr(Box::new(
+ PhysicalNot { expr: None },
+ ))),
+ };
+ let schema = Schema::empty();
+ let decoder = NoopDecoder;
+ let ctx = PhysicalExprDecodeCtx::new(&schema, &decoder);
+
+ let err = NotExpr::try_from_proto(&node, &ctx).unwrap_err();
+ assert!(matches!(err, DataFusionError::Internal(msg)
+ if msg.contains("NotExpr is missing required field 'expr'")
Review Comment:
I don't think `expr_id` would be very helpful, it's mostly for deduplication
of expressions / not useful in identifying them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]