Skip to content

Commit 498cec1

Browse files
Ian LaiIan Lai
authored andcommitted
refactor: rename function
1 parent 9bc3b86 commit 498cec1

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

datafusion/core/tests/physical_optimizer/combine_partial_final_agg.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ use datafusion_physical_plan::ExecutionPlan;
4545
/// Runs the CombinePartialFinalAggregate optimizer and asserts the plan against the expected
4646
macro_rules! assert_optimized {
4747
($PLAN: expr, @ $EXPECTED_LINES: literal $(,)?) => {
48-
// let expected_lines: Vec<&str> = $EXPECTED_LINES.iter().map(|s| *s).collect();
49-
5048
// run optimizer
5149
let optimizer = CombinePartialFinalAggregate {};
5250
let config = ConfigOptions::new();

datafusion/core/tests/physical_optimizer/limited_distinct_aggregation.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use insta::assert_snapshot;
2121
use std::sync::Arc;
2222

2323
use crate::physical_optimizer::test_utils::{
24-
build_group_by, mock_data, parquet_exec_with_sort, plan_matches_expected, schema,
24+
build_group_by, get_optimized_plan, mock_data, parquet_exec_with_sort, schema,
2525
TestAggregate,
2626
};
2727

@@ -40,7 +40,7 @@ use datafusion_physical_plan::{
4040
ExecutionPlan,
4141
};
4242

43-
async fn assert_results_match_expected(plan: Arc<dyn ExecutionPlan>) -> Result<String> {
43+
async fn run_plan_and_format(plan: Arc<dyn ExecutionPlan>) -> Result<String> {
4444
let cfg = SessionConfig::new().with_target_partitions(1);
4545
let ctx = SessionContext::new_with_config(cfg);
4646
let batches = collect(plan, ctx.task_ctx()).await?;
@@ -75,7 +75,7 @@ async fn test_partial_final() -> Result<()> {
7575
4, // fetch
7676
);
7777
let plan: Arc<dyn ExecutionPlan> = Arc::new(limit_exec);
78-
let formatted = plan_matches_expected(&plan)?;
78+
let formatted = get_optimized_plan(&plan)?;
7979
let actual = formatted.trim();
8080
assert_snapshot!(
8181
actual,
@@ -86,7 +86,7 @@ async fn test_partial_final() -> Result<()> {
8686
DataSourceExec: partitions=1, partition_sizes=[1]
8787
"
8888
);
89-
let expected = assert_results_match_expected(plan).await?;
89+
let expected = run_plan_and_format(plan).await?;
9090
let actual = expected.trim();
9191
assert_snapshot!(
9292
actual,
@@ -125,7 +125,7 @@ async fn test_single_local() -> Result<()> {
125125
);
126126
// expected to push the limit to the AggregateExec
127127
let plan: Arc<dyn ExecutionPlan> = Arc::new(limit_exec);
128-
let formatted = plan_matches_expected(&plan)?;
128+
let formatted = get_optimized_plan(&plan)?;
129129
let actual = formatted.trim();
130130
assert_snapshot!(
131131
actual,
@@ -135,7 +135,7 @@ async fn test_single_local() -> Result<()> {
135135
DataSourceExec: partitions=1, partition_sizes=[1]
136136
"
137137
);
138-
let expected = assert_results_match_expected(plan).await?;
138+
let expected = run_plan_and_format(plan).await?;
139139
let actual = expected.trim();
140140
assert_snapshot!(
141141
actual,
@@ -174,7 +174,7 @@ async fn test_single_global() -> Result<()> {
174174
);
175175
// expected to push the skip+fetch limit to the AggregateExec
176176
let plan: Arc<dyn ExecutionPlan> = Arc::new(limit_exec);
177-
let formatted = plan_matches_expected(&plan)?;
177+
let formatted = get_optimized_plan(&plan)?;
178178
let actual = formatted.trim();
179179
assert_snapshot!(
180180
actual,
@@ -184,7 +184,7 @@ async fn test_single_global() -> Result<()> {
184184
DataSourceExec: partitions=1, partition_sizes=[1]
185185
"
186186
);
187-
let expected = assert_results_match_expected(plan).await?;
187+
let expected = run_plan_and_format(plan).await?;
188188
let actual = expected.trim();
189189
assert_snapshot!(
190190
actual,
@@ -229,7 +229,7 @@ async fn test_distinct_cols_different_than_group_by_cols() -> Result<()> {
229229
);
230230
// expected to push the limit to the outer AggregateExec only
231231
let plan: Arc<dyn ExecutionPlan> = Arc::new(limit_exec);
232-
let formatted = plan_matches_expected(&plan)?;
232+
let formatted = get_optimized_plan(&plan)?;
233233
let actual = formatted.trim();
234234
assert_snapshot!(
235235
actual,
@@ -240,7 +240,7 @@ async fn test_distinct_cols_different_than_group_by_cols() -> Result<()> {
240240
DataSourceExec: partitions=1, partition_sizes=[1]
241241
"
242242
);
243-
let expected = assert_results_match_expected(plan).await?;
243+
let expected = run_plan_and_format(plan).await?;
244244
let actual = expected.trim();
245245
assert_snapshot!(
246246
actual,
@@ -284,7 +284,7 @@ fn test_has_order_by() -> Result<()> {
284284
);
285285
// expected not to push the limit to the AggregateExec
286286
let plan: Arc<dyn ExecutionPlan> = Arc::new(limit_exec);
287-
let formatted = plan_matches_expected(&plan)?;
287+
let formatted = get_optimized_plan(&plan)?;
288288
let actual = formatted.trim();
289289
assert_snapshot!(
290290
actual,
@@ -317,7 +317,7 @@ fn test_no_group_by() -> Result<()> {
317317
);
318318
// expected not to push the limit to the AggregateExec
319319
let plan: Arc<dyn ExecutionPlan> = Arc::new(limit_exec);
320-
let formatted = plan_matches_expected(&plan)?;
320+
let formatted = get_optimized_plan(&plan)?;
321321
let actual = formatted.trim();
322322
assert_snapshot!(
323323
actual,
@@ -351,7 +351,7 @@ fn test_has_aggregate_expression() -> Result<()> {
351351
);
352352
// expected not to push the limit to the AggregateExec
353353
let plan: Arc<dyn ExecutionPlan> = Arc::new(limit_exec);
354-
let formatted = plan_matches_expected(&plan)?;
354+
let formatted = get_optimized_plan(&plan)?;
355355
let actual = formatted.trim();
356356
assert_snapshot!(
357357
actual,
@@ -393,7 +393,7 @@ fn test_has_filter() -> Result<()> {
393393
// expected not to push the limit to the AggregateExec
394394
// TODO(msirek): open an issue for `filter_expr` of `AggregateExec` not printing out
395395
let plan: Arc<dyn ExecutionPlan> = Arc::new(limit_exec);
396-
let formatted = plan_matches_expected(&plan)?;
396+
let formatted = get_optimized_plan(&plan)?;
397397
let actual = formatted.trim();
398398
assert_snapshot!(
399399
actual,

datafusion/core/tests/physical_optimizer/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ pub fn build_group_by(input_schema: &SchemaRef, columns: Vec<String>) -> Physica
622622
PhysicalGroupBy::new_single(group_by_expr.clone())
623623
}
624624

625-
pub fn plan_matches_expected(plan: &Arc<dyn ExecutionPlan>) -> Result<String> {
625+
pub fn get_optimized_plan(plan: &Arc<dyn ExecutionPlan>) -> Result<String> {
626626
let config = ConfigOptions::new();
627627

628628
let optimized =

0 commit comments

Comments
 (0)