Skip to content

Commit b87cde1

Browse files
authored
Handle serde for ScalarUDF (#9395)
1 parent 1b924ff commit b87cde1

File tree

10 files changed

+1171
-851
lines changed

10 files changed

+1171
-851
lines changed

datafusion/proto/proto/datafusion.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ message AggregateUDFExprNode {
751751
message ScalarUDFExprNode {
752752
string fun_name = 1;
753753
repeated LogicalExprNode args = 2;
754+
optional bytes fun_definition = 3;
754755
}
755756

756757
enum BuiltInWindowFunction {

datafusion/proto/src/bytes/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
//! Serialization / Deserialization to Bytes
19+
use crate::logical_plan::to_proto::serialize_expr;
1920
use crate::logical_plan::{
2021
self, AsLogicalPlan, DefaultLogicalExtensionCodec, LogicalExtensionCodec,
2122
};
@@ -87,8 +88,8 @@ pub trait Serializeable: Sized {
8788
impl Serializeable for Expr {
8889
fn to_bytes(&self) -> Result<Bytes> {
8990
let mut buffer = BytesMut::new();
90-
let protobuf: protobuf::LogicalExprNode = self
91-
.try_into()
91+
let extension_codec = DefaultLogicalExtensionCodec {};
92+
let protobuf: protobuf::LogicalExprNode = serialize_expr(self, &extension_codec)
9293
.map_err(|e| plan_datafusion_err!("Error encoding expr as protobuf: {e}"))?;
9394

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

180-
logical_plan::from_proto::parse_expr(&protobuf, registry)
181+
let extension_codec = DefaultLogicalExtensionCodec {};
182+
logical_plan::from_proto::parse_expr(&protobuf, registry, &extension_codec)
181183
.map_err(|e| plan_datafusion_err!("Error parsing protobuf into Expr: {e}"))
182184
}
183185
}

datafusion/proto/src/generated/pbjson.rs

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion/proto/src/generated/prost.rs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)