You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2025/10/09 17:53:50 UTC
(datafusion) branch main updated: Migrate join_selection tests to snapshot-based testing (#17974)
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 5609447450 Migrate join_selection tests to snapshot-based testing (#17974)
5609447450 is described below
commit 56094474502e8c97acdec94492b2d010a78975ff
Author: Dmitrii Blaginin <dm...@blaginin.me>
AuthorDate: Thu Oct 9 18:53:28 2025 +0100
Migrate join_selection tests to snapshot-based testing (#17974)
This commit migrates the join_selection test file to use insta
snapshot testing instead of macro-based assertions for better
maintainability and clearer test output.
Co-authored-by: Chen-Yuan-Lai <si...@gmail.com>
Co-authored-by: Andrew Lamb <an...@nerdnetworks.org>
---
.../tests/physical_optimizer/join_selection.rs | 36 +++++++++++-----------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/datafusion/core/tests/physical_optimizer/join_selection.rs b/datafusion/core/tests/physical_optimizer/join_selection.rs
index 551fde5d7f..f9d3a04546 100644
--- a/datafusion/core/tests/physical_optimizer/join_selection.rs
+++ b/datafusion/core/tests/physical_optimizer/join_selection.rs
@@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.
+use insta::assert_snapshot;
use std::sync::Arc;
use std::{
any::Any,
@@ -426,8 +427,7 @@ async fn test_join_with_swap_mark() {
/// Compare the input plan with the plan after running the probe order optimizer.
macro_rules! assert_optimized {
- ($EXPECTED_LINES: expr, $PLAN: expr) => {
- let expected_lines = $EXPECTED_LINES.iter().map(|s| *s).collect::<Vec<&str>>();
+ ($PLAN: expr, @$EXPECTED_LINES: literal $(,)?) => {
let plan = Arc::new($PLAN);
let optimized = JoinSelection::new()
@@ -435,12 +435,11 @@ macro_rules! assert_optimized {
.unwrap();
let plan_string = displayable(optimized.as_ref()).indent(true).to_string();
- let actual_lines = plan_string.split("\n").collect::<Vec<&str>>();
+ let actual = plan_string.trim();
- assert_eq!(
- &expected_lines, &actual_lines,
- "\n\nexpected:\n\n{:#?}\nactual:\n\n{:#?}\n\n",
- expected_lines, actual_lines
+ assert_snapshot!(
+ actual,
+ @$EXPECTED_LINES
);
};
}
@@ -489,17 +488,18 @@ async fn test_nested_join_swap() {
// The first hash join's left is 'small' table (with 1000 rows), and the second hash join's
// left is the F(small IJ big) which has an estimated cardinality of 2000 rows (vs medium which
// has an exact cardinality of 10_000 rows).
- let expected = [
- "ProjectionExec: expr=[medium_col@2 as medium_col, big_col@0 as big_col, small_col@1 as small_col]",
- " HashJoinExec: mode=CollectLeft, join_type=Right, on=[(small_col@1, medium_col@0)]",
- " ProjectionExec: expr=[big_col@1 as big_col, small_col@0 as small_col]",
- " HashJoinExec: mode=CollectLeft, join_type=Inner, on=[(small_col@0, big_col@0)]",
- " StatisticsExec: col_count=1, row_count=Inexact(1000)",
- " StatisticsExec: col_count=1, row_count=Inexact(100000)",
- " StatisticsExec: col_count=1, row_count=Inexact(10000)",
- "",
- ];
- assert_optimized!(expected, join);
+ assert_optimized!(
+ join,
+ @r"
+ ProjectionExec: expr=[medium_col@2 as medium_col, big_col@0 as big_col, small_col@1 as small_col]
+ HashJoinExec: mode=CollectLeft, join_type=Right, on=[(small_col@1, medium_col@0)]
+ ProjectionExec: expr=[big_col@1 as big_col, small_col@0 as small_col]
+ HashJoinExec: mode=CollectLeft, join_type=Inner, on=[(small_col@0, big_col@0)]
+ StatisticsExec: col_count=1, row_count=Inexact(1000)
+ StatisticsExec: col_count=1, row_count=Inexact(100000)
+ StatisticsExec: col_count=1, row_count=Inexact(10000)
+ "
+ );
}
#[tokio::test]
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org