Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
berkaysynnada committed Feb 21, 2025
1 parent d1c1b09 commit ace28b6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 38 deletions.
15 changes: 8 additions & 7 deletions datafusion/core/tests/physical_optimizer/enforce_sorting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ use std::sync::Arc;
use crate::physical_optimizer::test_utils::{
aggregate_exec, bounded_window_exec, check_integrity, coalesce_batches_exec,
coalesce_partitions_exec, create_test_schema, create_test_schema2,
create_test_schema3, create_test_schema4, filter_exec, global_limit_exec,
hash_join_exec, limit_exec, local_limit_exec, memory_exec, parquet_exec,
repartition_exec, sort_exec, sort_expr, sort_expr_options, sort_merge_join_exec,
sort_preserving_merge_exec, sort_preserving_merge_exec_with_fetch,
spr_repartition_exec, stream_exec_ordered, union_exec, RequirementsTestExec,
create_test_schema3, filter_exec, global_limit_exec, hash_join_exec, limit_exec,
local_limit_exec, memory_exec, parquet_exec, repartition_exec, sort_exec, sort_expr,
sort_expr_options, sort_merge_join_exec, sort_preserving_merge_exec,
sort_preserving_merge_exec_with_fetch, spr_repartition_exec, stream_exec_ordered,
union_exec, RequirementsTestExec,
};

use datafusion_physical_plan::{displayable, InputOrderMode};
use arrow::compute::SortOptions;
use arrow::datatypes::SchemaRef;
use datafusion_common::Result;
use datafusion_expr::JoinType;
use arrow_schema::DataType;
use datafusion_common::{Result, ScalarValue};
use datafusion_expr::{JoinType, WindowFrame, WindowFrameBound, WindowFrameUnits, WindowFunctionDefinition};
use datafusion_physical_expr::expressions::{col, Column, NotExpr};
use datafusion_physical_optimizer::PhysicalOptimizerRule;
use datafusion_physical_expr::Partitioning;
Expand Down
17 changes: 2 additions & 15 deletions datafusion/core/tests/physical_optimizer/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,33 +194,20 @@ pub fn bounded_window_exec(
col_name: &str,
sort_exprs: impl IntoIterator<Item = PhysicalSortExpr>,
input: Arc<dyn ExecutionPlan>,
) -> Arc<dyn ExecutionPlan> {
bounded_window_exec_with_partition(col_name, sort_exprs, &[], input, false)
}

pub fn bounded_window_exec_with_partition(
col_name: &str,
sort_exprs: impl IntoIterator<Item = PhysicalSortExpr>,
partition_by: &[Arc<dyn PhysicalExpr>],
input: Arc<dyn ExecutionPlan>,
should_reverse: bool,
) -> Arc<dyn ExecutionPlan> {
let sort_exprs: LexOrdering = sort_exprs.into_iter().collect();
let schema = input.schema();
let mut window_expr = create_window_expr(
let window_expr = create_window_expr(
&WindowFunctionDefinition::AggregateUDF(count_udaf()),
"count".to_owned(),
&[col(col_name, &schema).unwrap()],
partition_by,
&[],
sort_exprs.as_ref(),
Arc::new(WindowFrame::new(Some(false))),
schema.as_ref(),
false,
)
.unwrap();
if should_reverse {
window_expr = window_expr.get_reverse_expr().unwrap();
}

Arc::new(
BoundedWindowAggExec::try_new(
Expand Down
6 changes: 1 addition & 5 deletions datafusion/physical-expr/src/equivalence/ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,7 @@ impl OrderingEquivalenceClass {
count += 1;
}
}
if count == 4 {
true
} else {
false
}
count == 4
}
}

Expand Down
9 changes: 4 additions & 5 deletions datafusion/physical-expr/src/equivalence/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1464,11 +1464,10 @@ fn update_properties(
let normalized_expr = eq_properties
.eq_group
.normalize_expr(Arc::clone(&node.expr));
if eq_properties.is_expr_constant(&normalized_expr) {
node.data.sort_properties = SortProperties::Singleton;
} else if eq_properties
.normalized_oeq_class()
.singleton_options(&normalized_expr)
if eq_properties.is_expr_constant(&normalized_expr)
|| eq_properties
.normalized_oeq_class()
.singleton_options(&normalized_expr)
{
node.data.sort_properties = SortProperties::Singleton;
} else if let Some(options) = eq_properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ use crate::utils::{

use arrow::datatypes::SchemaRef;
use datafusion_common::tree_node::{
ConcreteTreeNode, Transformed, TreeNode, TreeNodeRecursion, TreeNodeVisitor,
ConcreteTreeNode, Transformed, TreeNode, TreeNodeRecursion,
};
use datafusion_common::{plan_err, HashSet, JoinSide, Result};
use datafusion_expr::JoinType;
use datafusion_physical_expr::expressions::Column;
use datafusion_physical_expr::utils::collect_columns;
use datafusion_physical_expr::PhysicalSortRequirement;
use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
use datafusion_physical_expr_common::sort_expr::{LexOrdering, LexRequirement};
use datafusion_physical_plan::filter::FilterExec;
use datafusion_physical_plan::joins::utils::{
Expand Down
9 changes: 5 additions & 4 deletions datafusion/physical-plan/src/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use crate::{
};

use arrow::datatypes::{DataType, Field, Schema, SchemaRef};
use arrow_schema::SortOptions;
use datafusion_common::{exec_err, Result};
use datafusion_expr::{
PartitionEvaluator, ReversedUDWF, SetMonotonicity, WindowFrame,
Expand Down Expand Up @@ -359,7 +360,7 @@ pub(crate) fn window_equivalence_properties(
partition_by_order.into_iter().multi_cartesian_product();
let mut all_lexs = all_orders_cartesian
.into_iter()
.map(|inner| LexOrdering::new(inner))
.map(LexOrdering::new)
.collect::<Vec<_>>();
if !expr.partition_by().is_empty()
&& all_lexs
Expand Down Expand Up @@ -498,15 +499,15 @@ pub(crate) fn window_equivalence_properties(
.map(|pb| {
vec![
PhysicalSortExpr::new(
pb.clone(),
Arc::clone(&pb),
SortOptions::new(false, false),
),
PhysicalSortExpr::new(
pb.clone(),
Arc::clone(&pb),
SortOptions::new(false, true),
),
PhysicalSortExpr::new(
pb.clone(),
Arc::clone(&pb),
SortOptions::new(true, false),
),
PhysicalSortExpr::new(pb, SortOptions::new(true, true)),
Expand Down

0 comments on commit ace28b6

Please sign in to comment.