Skip to content

Commit e4dd102

Browse files
committed
branch 49
1 parent 45dd3f9 commit e4dd102

16 files changed

Lines changed: 66 additions & 112 deletions

File tree

datafusion/expr/src/expr.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,8 @@ pub enum Expr {
284284
Column(Column),
285285
/// A named reference to a variable in a registry.
286286
ScalarVariable(DataType, Vec<String>),
287-
<<<<<<< HEAD
288-
/// A constant value along with associated metadata
289-
Literal(ScalarValue, Option<BTreeMap<String, String>>),
290-
=======
291287
/// A constant value along with associated [`FieldMetadata`].
292288
Literal(ScalarValue, Option<FieldMetadata>),
293-
>>>>>>> upstream/branch-49
294289
/// A binary expression such as "age > 21"
295290
BinaryExpr(BinaryExpr),
296291
/// LIKE expression

datafusion/expr/src/literal.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use crate::expr::FieldMetadata;
2121
use crate::Expr;
2222
use datafusion_common::ScalarValue;
23-
use std::collections::HashMap;
2423

2524
/// Create a literal expression
2625
pub fn lit<T: Literal>(n: T) -> Expr {

datafusion/optimizer/src/push_down_filter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use datafusion_expr::{
4040
};
4141

4242
use crate::optimizer::ApplyOrder;
43-
use crate::simplify_expressions::simplify_predicates;
4443
use crate::utils::{has_all_column_refs, is_restrict_null_predicate};
4544
use crate::{simplify_predicates::simplify_predicates, OptimizerConfig, OptimizerRule};
4645

datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//! Expression simplification API
1919
2020
use std::borrow::Cow;
21-
use std::collections::{BTreeMap, HashSet};
21+
use std::collections::HashSet;
2222
use std::ops::Not;
2323

2424
use arrow::{

datafusion/optimizer/src/simplify_predicates.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ pub(crate) fn simplify_predicates(predicates: Vec<Expr>) -> Result<Vec<Expr>> {
4343
{
4444
let left_col = extract_column_from_expr(left);
4545
let right_col = extract_column_from_expr(right);
46-
let left_lit = left.is_literal();
47-
let right_lit = right.is_literal();
46+
let left_lit = left.as_literal().is_some();
47+
let right_lit = right.as_literal().is_some();
4848
if let (Some(col), true) = (&left_col, right_lit) {
4949
column_predicates.entry(col.clone()).or_default().push(pred);
5050
} else if let (true, Some(col)) = (left_lit, &right_col) {
@@ -80,7 +80,7 @@ fn simplify_column_predicates(predicates: Vec<Expr>) -> Result<Vec<Expr>> {
8080
for pred in predicates {
8181
match &pred {
8282
Expr::BinaryExpr(BinaryExpr { left: _, op, right }) => {
83-
let right_is_literal = right.is_literal();
83+
let right_is_literal = right.as_literal().is_some();
8484
match (op, right_is_literal) {
8585
(Operator::Gt, true)
8686
| (Operator::Lt, false)
@@ -149,14 +149,11 @@ fn find_most_restrictive_predicate(
149149
if let Expr::BinaryExpr(BinaryExpr { left, op: _, right }) = pred {
150150
// Extract the literal value based on which side has it
151151
let mut scalar_value = None;
152-
if right.is_literal() {
153-
if let Expr::Literal(scalar, _) = right.as_ref() {
154-
scalar_value = Some(scalar.clone());
155-
}
156-
} else if left.is_literal() {
157-
if let Expr::Literal(scalar, _) = left.as_ref() {
158-
scalar_value = Some(scalar.clone());
159-
}
152+
if let Some(scalar) = right.as_literal() {
153+
scalar_value = Some(scalar.clone());
154+
}
155+
if let Some(scalar) = left.as_literal() {
156+
scalar_value = Some(scalar.clone());
160157
}
161158

162159
if let Some(scalar) = scalar_value {

datafusion/physical-expr/src/expressions/in_list.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,11 +1451,7 @@ mod tests {
14511451
let sql_string = fmt_sql(expr.as_ref()).to_string();
14521452
let display_string = expr.to_string();
14531453
assert_eq!(sql_string, "a IN (a, b)");
1454-
<<<<<<< HEAD
1455-
assert_eq!(display_string, "Use a@0 IN (SET) ([Literal { value: Utf8(\"a\"), field: Field { name: \"a\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} } }, Literal { value: Utf8(\"b\"), field: Field { name: \"b\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} } }])");
1456-
=======
14571454
assert_eq!(display_string, "Use a@0 IN (SET) ([Literal { value: Utf8(\"a\"), field: Field { name: \"lit\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} } }, Literal { value: Utf8(\"b\"), field: Field { name: \"lit\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} } }])");
1458-
>>>>>>> upstream/branch-49
14591455

14601456
// Test: a NOT IN ('a', 'b')
14611457
let list = vec![lit("a"), lit("b")];

datafusion/physical-expr/src/expressions/literal.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
//! Literal expressions for physical operations
1919
2020
use std::any::Any;
21-
use std::collections::HashMap;
2221
use std::hash::Hash;
2322
use std::sync::Arc;
2423

datafusion/physical-expr/src/planner.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use std::collections::HashMap;
1918
use std::sync::Arc;
2019

2120
use crate::ScalarFunctionExpr;

datafusion/physical-expr/src/window/aggregate.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub struct PlainAggregateWindowExpr {
4646
partition_by: Vec<Arc<dyn PhysicalExpr>>,
4747
order_by: Vec<PhysicalSortExpr>,
4848
window_frame: Arc<WindowFrame>,
49+
is_constant_in_partition: bool,
4950
}
5051

5152
impl PlainAggregateWindowExpr {
@@ -56,11 +57,14 @@ impl PlainAggregateWindowExpr {
5657
order_by: &[PhysicalSortExpr],
5758
window_frame: Arc<WindowFrame>,
5859
) -> Self {
60+
let is_constant_in_partition =
61+
Self::is_window_constant_in_partition(order_by, &window_frame);
5962
Self {
6063
aggregate,
6164
partition_by: partition_by.to_vec(),
6265
order_by: order_by.to_vec(),
6366
window_frame,
67+
is_constant_in_partition,
6468
}
6569
}
6670

@@ -246,4 +250,8 @@ impl AggregateWindowExpr for PlainAggregateWindowExpr {
246250
accumulator.evaluate()
247251
}
248252
}
253+
254+
fn is_constant_in_partition(&self) -> bool {
255+
self.is_constant_in_partition
256+
}
249257
}

datafusion/physical-expr/src/window/sliding_aggregate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,8 @@ impl AggregateWindowExpr for SlidingAggregateWindowExpr {
217217
accumulator.evaluate()
218218
}
219219
}
220+
221+
fn is_constant_in_partition(&self) -> bool {
222+
false
223+
}
220224
}

0 commit comments

Comments
 (0)