diff --git a/datafusion/core/tests/sql/joins.rs b/datafusion/core/tests/sql/joins.rs index 1e690b45a09e0..fad9b94b01120 100644 --- a/datafusion/core/tests/sql/joins.rs +++ b/datafusion/core/tests/sql/joins.rs @@ -235,47 +235,3 @@ async fn join_change_in_planner_without_sort_not_allowed() -> Result<()> { } Ok(()) } - -#[tokio::test] -async fn test_smj_right_filtered() -> Result<()> { - let ctx: SessionContext = SessionContext::new(); - - let sql = "set datafusion.optimizer.prefer_hash_join = false;"; - let _ = ctx.sql(sql).await?.collect().await?; - - let sql = "set datafusion.execution.batch_size = 100"; - let _ = ctx.sql(sql).await?.collect().await?; - - let sql = " - select * from ( - with t as ( - select id, id % 5 id1 from (select unnest(range(0,10)) id) - ), t1 as ( - select id % 10 id, id + 2 id1 from (select unnest(range(0,10)) id) - ) - select * from t right join t1 on t.id1 = t1.id and t.id > t1.id1 - ) order by 1, 2, 3, 4 - "; - - let actual = ctx.sql(sql).await?.collect().await?; - - let expected: Vec<&str> = vec![ - "+----+-----+----+-----+", - "| id | id1 | id | id1 |", - "+----+-----+----+-----+", - "| 5 | 0 | 0 | 2 |", - "| 6 | 1 | 1 | 3 |", - "| 7 | 2 | 2 | 4 |", - "| 8 | 3 | 3 | 5 |", - "| 9 | 4 | 4 | 6 |", - "| | | 5 | 7 |", - "| | | 6 | 8 |", - "| | | 7 | 9 |", - "| | | 8 | 10 |", - "| | | 9 | 11 |", - "+----+-----+----+-----+", - ]; - datafusion_common::assert_batches_eq!(expected, &actual); - - Ok(()) -} diff --git a/datafusion/sqllogictest/test_files/sort_merge_join.slt b/datafusion/sqllogictest/test_files/sort_merge_join.slt index d120d366ce83f..5a6334602c22f 100644 --- a/datafusion/sqllogictest/test_files/sort_merge_join.slt +++ b/datafusion/sqllogictest/test_files/sort_merge_join.slt @@ -605,6 +605,27 @@ select t1.* from t1 where not exists (select 1 from t2 where t2.a = t1.a and t1. ) order by 1, 2 ---- +query IIII +select * from ( +with t as ( + select id, id % 5 id1 from (select unnest(range(0,10)) id) +), t1 as ( + select id % 10 id, id + 2 id1 from (select unnest(range(0,10)) id) +) +select * from t right join t1 on t.id1 = t1.id and t.id > t1.id1 +) order by 1, 2, 3, 4 +---- +5 0 0 2 +6 1 1 3 +7 2 2 4 +8 3 3 5 +9 4 4 6 +NULL NULL 5 7 +NULL NULL 6 8 +NULL NULL 7 9 +NULL NULL 8 10 +NULL NULL 9 11 + # return sql params back to default values statement ok set datafusion.optimizer.prefer_hash_join = true;