Skip to content

Commit

Permalink
Handle serde for ScalarUDF (#9395)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyy1000 authored Mar 2, 2024
1 parent 1b924ff commit b87cde1
Show file tree
Hide file tree
Showing 10 changed files with 1,171 additions and 851 deletions.
1 change: 1 addition & 0 deletions datafusion/proto/proto/datafusion.proto
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ message AggregateUDFExprNode {
message ScalarUDFExprNode {
string fun_name = 1;
repeated LogicalExprNode args = 2;
optional bytes fun_definition = 3;
}

enum BuiltInWindowFunction {
Expand Down
8 changes: 5 additions & 3 deletions datafusion/proto/src/bytes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

//! Serialization / Deserialization to Bytes
use crate::logical_plan::to_proto::serialize_expr;
use crate::logical_plan::{
self, AsLogicalPlan, DefaultLogicalExtensionCodec, LogicalExtensionCodec,
};
Expand Down Expand Up @@ -87,8 +88,8 @@ pub trait Serializeable: Sized {
impl Serializeable for Expr {
fn to_bytes(&self) -> Result<Bytes> {
let mut buffer = BytesMut::new();
let protobuf: protobuf::LogicalExprNode = self
.try_into()
let extension_codec = DefaultLogicalExtensionCodec {};
let protobuf: protobuf::LogicalExprNode = serialize_expr(self, &extension_codec)
.map_err(|e| plan_datafusion_err!("Error encoding expr as protobuf: {e}"))?;

protobuf
Expand Down Expand Up @@ -177,7 +178,8 @@ impl Serializeable for Expr {
let protobuf = protobuf::LogicalExprNode::decode(bytes)
.map_err(|e| plan_datafusion_err!("Error decoding expr as protobuf: {e}"))?;

logical_plan::from_proto::parse_expr(&protobuf, registry)
let extension_codec = DefaultLogicalExtensionCodec {};
logical_plan::from_proto::parse_expr(&protobuf, registry, &extension_codec)
.map_err(|e| plan_datafusion_err!("Error parsing protobuf into Expr: {e}"))
}
}
Expand Down
21 changes: 21 additions & 0 deletions datafusion/proto/src/generated/pbjson.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions datafusion/proto/src/generated/prost.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b87cde1

Please sign in to comment.