-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Migrate subtraits tests to insta, part1 #15444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate subtraits tests to insta, part1 #15444
Conversation
|
Just to clarify this PR is NOT FINISHED YET. I need more clarification of the scope of this issue. Update: |
This reverts commit c3be2eb.
…insta` mapping to `assert!`
|
This PR is mostly done. There are still some areas (non-trivial test cases migration) where I'm not sure if I should or how should I migrate them to The And there are many more functions like this, I can't simply change them as they accepts dynamically generated Just want to know if I need to migrate those non-trivial test cases as well, thanks. |
In general I suggest we get the basic easy to port tests done and then work on the others as a follow on PR For those changes, I think you would have to restructure the tests From let expected_plan_str = format!(
"Projection: count(Int64(1)) AS {syntax}\
\n Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]\
\n Projection: \
\n LeftSemi Join: data.a = data2.a\
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\
\n TableScan: data projection=[a]\
\n TableScan: data2 projection=[a]"
);
assert_expected_plan(
&format!("SELECT {syntax} FROM (SELECT data.a FROM data INTERSECT SELECT data2.a FROM data2);"),
&expected_plan_str,
true
).awaitPerhaps something more like assert_snapshot!(
do_conversion(&format!("SELECT {syntax} FROM (SELECT data.a FROM data INTERSECT SELECT data2.a FROM data2);),
@r#"
"Projection: count(Int64(1)) AS {syntax}\
\n Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]\
\n Projection: \
\n LeftSemi Join: data.a = data2.a\
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\
\n TableScan: data projection=[a]\
\n TableScan: data2 projection=[a]"
);
"#
);
Ok(())Where async fn do_conversion(
sql: &str,
assert_schema: bool,
) -> Result<String> {
let ctx = create_context().await?;
let df = ctx.sql(sql).await?;
let plan = df.into_optimized_plan()?;
let proto = to_substrait_plan(&plan, &ctx.state())?;
let plan2 = from_substrait_plan(&ctx.state(), &proto).await?;
let plan2 = ctx.state().optimize(&plan2)?;
if assert_schema {
assert_eq!(plan.schema(), plan2.schema());
}
Ok(format!("{plan2}");)
} |
If you plan to do more prs, consider changing it to "related", so the ticket won't get auto closed |
…t_eq!` and remove `format!` for `assert_snapshot!`
Got it, thanks @alamb and @blaginin for the help. I think I've finished migrating all the "easy" portion now, please review this PR. The only thing left are the non-trivial cases in I will create another PR for that as suggested. |
blaginin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks 🙏
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank ou @qstommyshu and @blaginin
* add `cargo insta` to dev dependencies * migrate `consumer_intergration.rs` tests to `insta` * Revert "migrate `consumer_intergration.rs` tests to `insta`" This reverts commit c3be2eb. * migrate `consumer_integration.rs` to `insta` inline snapshot * migrate logical plans tests to use `insta` snapshots * migrate emit_kind_tests to use `insta` snapshots * migrate function_test to use `insta` snapshots for assertions * migrate substrait_validations tests to use insta snapshots, missing `insta` mapping to `assert!` * revert `handle_emit_as_project_without_volatile_exprs` back to `assert_eq!` and remove `format!` for `assert_snapshot!` * migrate function and validation tests to use plan directly in assert_snapshot! * migrate serialize tests to use insta snapshots for assertions * migrate logical_plans test to use insta snapshots for assertions
* add `cargo insta` to dev dependencies * migrate `consumer_intergration.rs` tests to `insta` * Revert "migrate `consumer_intergration.rs` tests to `insta`" This reverts commit c3be2eb. * migrate `consumer_integration.rs` to `insta` inline snapshot * migrate logical plans tests to use `insta` snapshots * migrate emit_kind_tests to use `insta` snapshots * migrate function_test to use `insta` snapshots for assertions * migrate substrait_validations tests to use insta snapshots, missing `insta` mapping to `assert!` * revert `handle_emit_as_project_without_volatile_exprs` back to `assert_eq!` and remove `format!` for `assert_snapshot!` * migrate function and validation tests to use plan directly in assert_snapshot! * migrate serialize tests to use insta snapshots for assertions * migrate logical_plans test to use insta snapshots for assertions
Which issue does this PR close?
insta#15398.Rationale for this change
What changes are included in this PR?
Migrated tests in datafusion/core/tests/subtrait to use insta.
Are these changes tested?
Yes, I manually tested the before/after changes.
Are there any user-facing changes?
No.