33
44use std:: any:: Any ;
55use std:: fmt;
6- use std:: fmt:: { Display , Formatter } ;
6+ use std:: fmt:: { Debug , Display , Formatter } ;
77use std:: hash:: { Hash , Hasher } ;
88use std:: sync:: Arc ;
99
@@ -18,7 +18,7 @@ use crate::expr::{ChildName, ExprId, ExprVTable, ExpressionView, StatsCatalog, V
1818///
1919/// Expressions represent scalar computations that can be performed on data. Each
2020/// expression consists of an encoding (vtable), heap-allocated metadata, and child expressions.
21- #[ derive( Clone , Debug ) ]
21+ #[ derive( Clone ) ]
2222pub struct Expression {
2323 /// The vtable for this expression.
2424 vtable : ExprVTable ,
@@ -270,6 +270,33 @@ impl Display for Expression {
270270 }
271271}
272272
273+ struct FormatExpressionData < ' a > {
274+ vtable : & ' a ExprVTable ,
275+ data : & ' a Arc < dyn Any + Send + Sync > ,
276+ }
277+
278+ impl < ' a > Debug for FormatExpressionData < ' a > {
279+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
280+ self . vtable . as_dyn ( ) . fmt_data ( self . data . as_ref ( ) , f)
281+ }
282+ }
283+
284+ impl Debug for Expression {
285+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
286+ f. debug_struct ( "Expression" )
287+ . field ( "vtable" , & self . vtable )
288+ . field (
289+ "data" ,
290+ & FormatExpressionData {
291+ vtable : & self . vtable ,
292+ data : & self . data ,
293+ } ,
294+ )
295+ . field ( "children" , & self . children )
296+ . finish ( )
297+ }
298+ }
299+
273300impl PartialEq for Expression {
274301 fn eq ( & self , other : & Self ) -> bool {
275302 self . vtable . as_dyn ( ) . id ( ) == other. vtable . as_dyn ( ) . id ( )
0 commit comments