Apache DataFusion SQL Query Engine
Change remove from swap to shift in index map (#9049)
Mustafa Akur92104a54469c
diff --git a/datafusion/physical-expr/src/equivalence/properties.rs b/datafusion/physical-expr/src/equivalence/properties.rsindex 6f3f2aa99b..cd0ae09a92 100644--- a/datafusion/physical-expr/src/equivalence/properties.rs+++ b/datafusion/physical-expr/src/equivalence/properties.rs@@ -730,7 +730,7 @@ impl EquivalenceProperties {for (PhysicalSortExpr { expr, .. }, idx) in &ordered_exprs {eq_properties =eq_properties.add_constants(std::iter::once(expr.clone()));- search_indices.swap_remove(idx);+ search_indices.shift_remove(idx);}// Add new ordered section to the state.result.extend(ordered_exprs);@@ -1779,6 +1779,7 @@ mod tests {let col_c = &col("c", &test_schema)?;let col_d = &col("d", &test_schema)?;let col_e = &col("e", &test_schema)?;+ let col_f = &col("f", &test_schema)?;let col_h = &col("h", &test_schema)?;// a + dlet a_plus_d = Arc::new(BinaryExpr::new(@@ -1795,7 +1796,7 @@ mod tests {descending: true,nulls_first: true,};- // [d ASC, h ASC] also satisfies schema.+ // [d ASC, h DESC] also satisfies schema.eq_properties.add_new_orderings([vec![PhysicalSortExpr {expr: col_d.clone(),@@ -1836,6 +1837,39 @@ mod tests {vec![col_c, col_e],vec![(col_c, option_asc), (col_e, option_desc)],),+ // TEST CASE 7+ (+ vec![col_d, col_h, col_e, col_f, col_b],+ vec![+ (col_d, option_asc),+ (col_e, option_desc),+ (col_h, option_desc),+ (col_f, option_asc),+ (col_b, option_asc),+ ],+ ),+ // TEST CASE 8+ (+ vec![col_e, col_d, col_h, col_f, col_b],+ vec![+ (col_e, option_desc),+ (col_d, option_asc),+ (col_h, option_desc),+ (col_f, option_asc),+ (col_b, option_asc),+ ],+ ),+ // TEST CASE 9+ (+ vec![col_e, col_d, col_b, col_h, col_f],+ vec![+ (col_e, option_desc),+ (col_d, option_asc),+ (col_b, option_asc),+ (col_h, option_desc),+ (col_f, option_asc),+ ],+ ),];for (exprs, expected) in test_cases {let exprs = exprs.into_iter().cloned().collect::<Vec<_>>();