Skip to content

Commit 99d80dd

Browse files
committed
Revert "Account for constant equivalence properties in union, tests (apache#12562)"
This reverts commit 577e4bb.
1 parent 5618b66 commit 99d80dd

File tree

3 files changed

+81
-408
lines changed

3 files changed

+81
-408
lines changed

datafusion/physical-expr-common/src/sort_expr.rs

-7
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,6 @@ impl PhysicalSortExpr {
118118
}
119119
}
120120

121-
/// Access the PhysicalSortExpr as a PhysicalExpr
122-
impl AsRef<dyn PhysicalExpr> for PhysicalSortExpr {
123-
fn as_ref(&self) -> &(dyn PhysicalExpr + 'static) {
124-
self.expr.as_ref()
125-
}
126-
}
127-
128121
impl PartialEq for PhysicalSortExpr {
129122
fn eq(&self, other: &PhysicalSortExpr) -> bool {
130123
self.options == other.options && self.expr.eq(&other.expr)

datafusion/physical-expr/src/equivalence/class.rs

+4-45
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use datafusion_physical_expr_common::physical_expr::format_physical_expr_list;
2929

3030
use indexmap::{IndexMap, IndexSet};
3131

32+
#[derive(Debug, Clone)]
3233
/// A structure representing a expression known to be constant in a physical execution plan.
3334
///
3435
/// The `ConstExpr` struct encapsulates an expression that is constant during the execution
@@ -39,10 +40,9 @@ use indexmap::{IndexMap, IndexSet};
3940
///
4041
/// - `expr`: Constant expression for a node in the physical plan.
4142
///
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.
4646
///
4747
/// # Example
4848
///
@@ -55,21 +55,11 @@ use indexmap::{IndexMap, IndexSet};
5555
/// // create a constant expression from a physical expression
5656
/// let const_expr = ConstExpr::from(col);
5757
/// ```
58-
#[derive(Debug, Clone)]
5958
pub struct ConstExpr {
60-
/// The expression that is known to be constant (e.g. a `Column`)
6159
expr: Arc<dyn PhysicalExpr>,
62-
/// Does the constant have the same value across all partitions? See
63-
/// struct docs for more details
6460
across_partitions: bool,
6561
}
6662

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-
7363
impl ConstExpr {
7464
/// Create a new constant expression from a physical expression.
7565
///
@@ -83,17 +73,11 @@ impl ConstExpr {
8373
}
8474
}
8575

86-
/// Set the `across_partitions` flag
87-
///
88-
/// See struct docs for more details
8976
pub fn with_across_partitions(mut self, across_partitions: bool) -> Self {
9077
self.across_partitions = across_partitions;
9178
self
9279
}
9380

94-
/// Is the expression the same across all partitions?
95-
///
96-
/// See struct docs for more details
9781
pub fn across_partitions(&self) -> bool {
9882
self.across_partitions
9983
}
@@ -116,31 +100,6 @@ impl ConstExpr {
116100
across_partitions: self.across_partitions,
117101
})
118102
}
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-
}
144103
}
145104

146105
/// Display implementation for `ConstExpr`

0 commit comments

Comments
 (0)