@@ -27,6 +27,7 @@ use datafusion_common::tree_node::{Transformed, TransformedResult, TreeNode};
2727use datafusion_common:: { IndexSet , JoinType } ;
2828use datafusion_physical_expr_common:: physical_expr:: format_physical_expr_list;
2929
30+ #[ derive( Debug , Clone ) ]
3031/// A structure representing a expression known to be constant in a physical execution plan.
3132///
3233/// The `ConstExpr` struct encapsulates an expression that is constant during the execution
@@ -37,10 +38,9 @@ use datafusion_physical_expr_common::physical_expr::format_physical_expr_list;
3738///
3839/// - `expr`: Constant expression for a node in the physical plan.
3940///
40- /// - `across_partitions`: A boolean flag indicating whether the constant
41- /// expression is the same across partitions. If set to `true`, the constant
42- /// expression has same value for all partitions. If set to `false`, the
43- /// constant expression may have different values for different partitions.
41+ /// - `across_partitions`: A boolean flag indicating whether the constant expression is
42+ /// valid across partitions. If set to `true`, the constant expression has same value for all partitions.
43+ /// If set to `false`, the constant expression may have different values for different partitions.
4444///
4545/// # Example
4646///
@@ -53,21 +53,11 @@ use datafusion_physical_expr_common::physical_expr::format_physical_expr_list;
5353/// // create a constant expression from a physical expression
5454/// let const_expr = ConstExpr::from(col);
5555/// ```
56- #[ derive( Debug , Clone ) ]
5756pub struct ConstExpr {
58- /// The expression that is known to be constant (e.g. a `Column`)
5957 expr : Arc < dyn PhysicalExpr > ,
60- /// Does the constant have the same value across all partitions? See
61- /// struct docs for more details
6258 across_partitions : bool ,
6359}
6460
65- impl PartialEq for ConstExpr {
66- fn eq ( & self , other : & Self ) -> bool {
67- self . across_partitions == other. across_partitions && self . expr . eq ( & other. expr )
68- }
69- }
70-
7161impl ConstExpr {
7262 /// Create a new constant expression from a physical expression.
7363 ///
@@ -81,17 +71,11 @@ impl ConstExpr {
8171 }
8272 }
8373
84- /// Set the `across_partitions` flag
85- ///
86- /// See struct docs for more details
8774 pub fn with_across_partitions ( mut self , across_partitions : bool ) -> Self {
8875 self . across_partitions = across_partitions;
8976 self
9077 }
9178
92- /// Is the expression the same across all partitions?
93- ///
94- /// See struct docs for more details
9579 pub fn across_partitions ( & self ) -> bool {
9680 self . across_partitions
9781 }
@@ -114,31 +98,6 @@ impl ConstExpr {
11498 across_partitions : self . across_partitions ,
11599 } )
116100 }
117-
118- /// Returns true if this constant expression is equal to the given expression
119- pub fn eq_expr ( & self , other : impl AsRef < dyn PhysicalExpr > ) -> bool {
120- self . expr . as_ref ( ) == other. as_ref ( )
121- }
122-
123- /// Returns a [`Display`]able list of `ConstExpr`.
124- pub fn format_list ( input : & [ ConstExpr ] ) -> impl Display + ' _ {
125- struct DisplayableList < ' a > ( & ' a [ ConstExpr ] ) ;
126- impl Display for DisplayableList < ' _ > {
127- fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
128- let mut first = true ;
129- for const_expr in self . 0 {
130- if first {
131- first = false ;
132- } else {
133- write ! ( f, "," ) ?;
134- }
135- write ! ( f, "{}" , const_expr) ?;
136- }
137- Ok ( ( ) )
138- }
139- }
140- DisplayableList ( input)
141- }
142101}
143102
144103/// Display implementation for `ConstExpr`
0 commit comments