| 76 | |
| 77 | impl Serializeable for Expr { |
| 78 | fn to_bytes(&self) -> Result<Bytes> { |
| 79 | let mut buffer = BytesMut::new(); |
| 80 | let extension_codec = DefaultLogicalExtensionCodec {}; |
| 81 | let protobuf: protobuf::LogicalExprNode = serialize_expr(self, &extension_codec) |
| 82 | .map_err(|e| plan_datafusion_err!("Error encoding expr as protobuf: {e}"))?; |
| 83 | |
| 84 | protobuf |
| 85 | .encode(&mut buffer) |
| 86 | .map_err(|e| plan_datafusion_err!("Error encoding protobuf as bytes: {e}"))?; |
| 87 | |
| 88 | let bytes: Bytes = buffer.into(); |
| 89 | |
| 90 | // The produced byte stream may lead to "recursion limit" errors, see |
| 91 | // https://github.com/apache/datafusion/issues/3968 |
| 92 | // Until the underlying prost issue ( https://github.com/tokio-rs/prost/issues/736 ) |
| 93 | // is fixed, verify the bytes can be decoded without hitting that limit. |
| 94 | protobuf::LogicalExprNode::decode(bytes.as_ref()) |
| 95 | .map_err(|e| plan_datafusion_err!("Error decoding expr as protobuf: {e}"))?; |
| 96 | |
| 97 | Ok(bytes) |
| 98 | } |
| 99 | |
| 100 | fn from_bytes_with_ctx(bytes: &[u8], ctx: &TaskContext) -> Result<Self> { |
| 101 | let protobuf = protobuf::LogicalExprNode::decode(bytes) |