@@ -29,6 +29,7 @@ use datafusion_physical_expr_common::physical_expr::format_physical_expr_list;
29
29
30
30
use indexmap:: { IndexMap , IndexSet } ;
31
31
32
+ #[ derive( Debug , Clone ) ]
32
33
/// A structure representing a expression known to be constant in a physical execution plan.
33
34
///
34
35
/// The `ConstExpr` struct encapsulates an expression that is constant during the execution
@@ -39,10 +40,9 @@ use indexmap::{IndexMap, IndexSet};
39
40
///
40
41
/// - `expr`: Constant expression for a node in the physical plan.
41
42
///
42
- /// - `across_partitions`: A boolean flag indicating whether the constant
43
- /// expression is the same across partitions. If set to `true`, the constant
44
- /// expression has same value for all partitions. If set to `false`, the
45
- /// constant expression may have different values for different partitions.
43
+ /// - `across_partitions`: A boolean flag indicating whether the constant expression is
44
+ /// valid across partitions. If set to `true`, the constant expression has same value for all partitions.
45
+ /// If set to `false`, the constant expression may have different values for different partitions.
46
46
///
47
47
/// # Example
48
48
///
@@ -55,21 +55,11 @@ use indexmap::{IndexMap, IndexSet};
55
55
/// // create a constant expression from a physical expression
56
56
/// let const_expr = ConstExpr::from(col);
57
57
/// ```
58
- #[ derive( Debug , Clone ) ]
59
58
pub struct ConstExpr {
60
- /// The expression that is known to be constant (e.g. a `Column`)
61
59
expr : Arc < dyn PhysicalExpr > ,
62
- /// Does the constant have the same value across all partitions? See
63
- /// struct docs for more details
64
60
across_partitions : bool ,
65
61
}
66
62
67
- impl PartialEq for ConstExpr {
68
- fn eq ( & self , other : & Self ) -> bool {
69
- self . across_partitions == other. across_partitions && self . expr . eq ( & other. expr )
70
- }
71
- }
72
-
73
63
impl ConstExpr {
74
64
/// Create a new constant expression from a physical expression.
75
65
///
@@ -83,17 +73,11 @@ impl ConstExpr {
83
73
}
84
74
}
85
75
86
- /// Set the `across_partitions` flag
87
- ///
88
- /// See struct docs for more details
89
76
pub fn with_across_partitions ( mut self , across_partitions : bool ) -> Self {
90
77
self . across_partitions = across_partitions;
91
78
self
92
79
}
93
80
94
- /// Is the expression the same across all partitions?
95
- ///
96
- /// See struct docs for more details
97
81
pub fn across_partitions ( & self ) -> bool {
98
82
self . across_partitions
99
83
}
@@ -116,31 +100,6 @@ impl ConstExpr {
116
100
across_partitions : self . across_partitions ,
117
101
} )
118
102
}
119
-
120
- /// Returns true if this constant expression is equal to the given expression
121
- pub fn eq_expr ( & self , other : impl AsRef < dyn PhysicalExpr > ) -> bool {
122
- self . expr . as_ref ( ) == other. as_ref ( )
123
- }
124
-
125
- /// Returns a [`Display`]able list of `ConstExpr`.
126
- pub fn format_list ( input : & [ ConstExpr ] ) -> impl Display + ' _ {
127
- struct DisplayableList < ' a > ( & ' a [ ConstExpr ] ) ;
128
- impl Display for DisplayableList < ' _ > {
129
- fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
130
- let mut first = true ;
131
- for const_expr in self . 0 {
132
- if first {
133
- first = false ;
134
- } else {
135
- write ! ( f, "," ) ?;
136
- }
137
- write ! ( f, "{}" , const_expr) ?;
138
- }
139
- Ok ( ( ) )
140
- }
141
- }
142
- DisplayableList ( input)
143
- }
144
103
}
145
104
146
105
/// Display implementation for `ConstExpr`
0 commit comments