@@ -145,6 +145,69 @@ impl PhysicalExpr for LikeExpr {
145145 write ! ( f, " {} " , self . op_name( ) ) ?;
146146 self . pattern . fmt_sql ( f)
147147 }
148+
149+ #[ cfg( feature = "proto" ) ]
150+ fn try_to_proto (
151+ & self ,
152+ ctx : & datafusion_physical_expr_common:: physical_expr:: proto_encode:: PhysicalExprEncodeCtx < ' _ > ,
153+ ) -> Result < Option < datafusion_proto_models:: protobuf:: PhysicalExprNode > > {
154+ use datafusion_proto_models:: protobuf;
155+
156+ Ok ( Some ( protobuf:: PhysicalExprNode {
157+ expr_id : None ,
158+ expr_type : Some ( protobuf:: physical_expr_node:: ExprType :: LikeExpr ( Box :: new (
159+ protobuf:: PhysicalLikeExprNode {
160+ negated : self . negated ,
161+ case_insensitive : self . case_insensitive ,
162+ expr : Some ( Box :: new ( ctx. encode_child ( & self . expr ) ?) ) ,
163+ pattern : Some ( Box :: new ( ctx. encode_child ( & self . pattern ) ?) ) ,
164+ } ,
165+ ) ) ) ,
166+ } ) )
167+ }
168+ }
169+
170+ #[ cfg( feature = "proto" ) ]
171+ impl LikeExpr {
172+ /// Reconstruct a [`LikeExpr`] from its protobuf representation.
173+ ///
174+ /// Takes the whole [`PhysicalExprNode`] so the decode signature matches
175+ /// other migrated expressions and can inspect outer-node metadata if
176+ /// needed in the future.
177+ ///
178+ /// [`PhysicalExprNode`]: datafusion_proto_models::protobuf::PhysicalExprNode
179+ pub fn try_from_proto (
180+ node : & datafusion_proto_models:: protobuf:: PhysicalExprNode ,
181+ ctx : & datafusion_physical_expr_common:: physical_expr:: proto_decode:: PhysicalExprDecodeCtx < ' _ > ,
182+ ) -> Result < Arc < dyn PhysicalExpr > > {
183+ use datafusion_common:: internal_err;
184+ use datafusion_proto_models:: protobuf;
185+
186+ let like_expr = match & node. expr_type {
187+ Some ( protobuf:: physical_expr_node:: ExprType :: LikeExpr ( like_expr) ) => {
188+ like_expr. as_ref ( )
189+ }
190+ _ => return internal_err ! ( "PhysicalExprNode is not a LikeExpr" ) ,
191+ } ;
192+
193+ let expr = like_expr. expr . as_deref ( ) . ok_or_else ( || {
194+ datafusion_common:: DataFusionError :: Internal (
195+ "LikeExpr is missing required field 'expr'" . to_string ( ) ,
196+ )
197+ } ) ?;
198+ let pattern = like_expr. pattern . as_deref ( ) . ok_or_else ( || {
199+ datafusion_common:: DataFusionError :: Internal (
200+ "LikeExpr is missing required field 'pattern'" . to_string ( ) ,
201+ )
202+ } ) ?;
203+
204+ Ok ( Arc :: new ( LikeExpr :: new (
205+ like_expr. negated ,
206+ like_expr. case_insensitive ,
207+ ctx. decode ( expr) ?,
208+ ctx. decode ( pattern) ?,
209+ ) ) )
210+ }
148211}
149212
150213/// used for optimize Dictionary like
0 commit comments