ygf11 commented on code in PR #4862: URL: https://github.com/apache/arrow-datafusion/pull/4862#discussion_r1067936212
########## datafusion/core/tests/sql/union.rs: ########## @@ -140,3 +140,85 @@ async fn union_schemas() -> Result<()> { assert_batches_eq!(expected, &result); Ok(()) } + +#[tokio::test] +async fn union_with_except_input() -> Result<()> { + let ctx = create_union_context()?; + let sql = "( + SELECT name FROM t1 + EXCEPT + SELECT name FROM t2 + ) + UNION ALL + ( + SELECT name FROM t2 + EXCEPT + SELECT name FROM t1 + )"; + let msg = format!("Creating logical plan for '{sql}'"); + let dataframe = ctx.sql(&("explain ".to_owned() + sql)).await.expect(&msg); + let plan = dataframe.into_optimized_plan()?; + let expected = vec![ + "Explain [plan_type:Utf8, plan:Utf8]", + " Union [name:UInt8;N]", + " LeftAnti Join: t1.name = t2.name [name:UInt8;N]", + " Distinct: [name:UInt8;N]", + " TableScan: t1 projection=[name] [name:UInt8;N]", + " Projection: t2.name [name:UInt8;N]", + " TableScan: t2 projection=[name] [name:UInt8;N]", + " LeftAnti Join: t2.name = t1.name [name:UInt8;N]", + " Distinct: [name:UInt8;N]", + " TableScan: t2 projection=[name] [name:UInt8;N]", + " Projection: t1.name [name:UInt8;N]", + " TableScan: t1 projection=[name] [name:UInt8;N]", + ]; Review Comment: This plan is changed after merging master, cause #4849 enable the `projection push down` of `DISTINCT`. Before merge: ``` " Distinct: [name:UInt8;N]", " Projection: t1.name [name:UInt8;N]", " TableScan: t1 projection=[name] [name:UInt8;N]", ``` After merge: ``` " Distinct: [name:UInt8;N]", " TableScan: t1 projection=[name] [name:UInt8;N]", ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org