@@ -27,6 +27,7 @@ use datafusion_common::tree_node::{Transformed, TransformedResult, TreeNode};
27
27
use datafusion_common:: { IndexSet , JoinType } ;
28
28
use datafusion_physical_expr_common:: physical_expr:: format_physical_expr_list;
29
29
30
+ #[ derive( Debug , Clone ) ]
30
31
/// A structure representing a expression known to be constant in a physical execution plan.
31
32
///
32
33
/// 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;
37
38
///
38
39
/// - `expr`: Constant expression for a node in the physical plan.
39
40
///
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.
44
44
///
45
45
/// # Example
46
46
///
@@ -53,21 +53,11 @@ use datafusion_physical_expr_common::physical_expr::format_physical_expr_list;
53
53
/// // create a constant expression from a physical expression
54
54
/// let const_expr = ConstExpr::from(col);
55
55
/// ```
56
- #[ derive( Debug , Clone ) ]
57
56
pub struct ConstExpr {
58
- /// The expression that is known to be constant (e.g. a `Column`)
59
57
expr : Arc < dyn PhysicalExpr > ,
60
- /// Does the constant have the same value across all partitions? See
61
- /// struct docs for more details
62
58
across_partitions : bool ,
63
59
}
64
60
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
-
71
61
impl ConstExpr {
72
62
/// Create a new constant expression from a physical expression.
73
63
///
@@ -81,17 +71,11 @@ impl ConstExpr {
81
71
}
82
72
}
83
73
84
- /// Set the `across_partitions` flag
85
- ///
86
- /// See struct docs for more details
87
74
pub fn with_across_partitions ( mut self , across_partitions : bool ) -> Self {
88
75
self . across_partitions = across_partitions;
89
76
self
90
77
}
91
78
92
- /// Is the expression the same across all partitions?
93
- ///
94
- /// See struct docs for more details
95
79
pub fn across_partitions ( & self ) -> bool {
96
80
self . across_partitions
97
81
}
@@ -114,31 +98,6 @@ impl ConstExpr {
114
98
across_partitions : self . across_partitions ,
115
99
} )
116
100
}
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
- }
142
101
}
143
102
144
103
/// Display implementation for `ConstExpr`
0 commit comments