Skip to content
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

Fix SortMergeJoin with join filter filtering all rows out #10495

Merged
merged 3 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions datafusion/core/tests/sql/joins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,32 +231,3 @@ async fn join_change_in_planner_without_sort_not_allowed() -> Result<()> {
}
Ok(())
}

#[tokio::test]
async fn test_smj_with_join_filter_fitering_all() -> 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 = 1";
let _ = ctx.sql(sql).await?.collect().await?;

let sql = "
select * from (
with
t1 as (
select 12 a, 12 b
),
t2 as (
select 12 a, 12 b
)
select t1.* from t1 join t2 on t1.a = t2.b where t1.a > t2.b
) order by 1, 2;
";

let results = ctx.sql(sql).await?.collect().await?;
assert_eq!(results.len(), 0);

Ok(())
}
17 changes: 17 additions & 0 deletions datafusion/sqllogictest/test_files/sort_merge_join.slt
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,22 @@ DROP TABLE t1;
statement ok
DROP TABLE t2;

# Set batch size to 1 for sort merge join
comphead marked this conversation as resolved.
Show resolved Hide resolved
statement ok
set datafusion.execution.batch_size = 1;

query II
SELECT * FROM (
WITH
t1 AS (
SELECT 12 a, 12 b
),
t2 AS (
SELECT 12 a, 12 b
)
SELECT t1.* FROM t1 JOIN t2 on t1.a = t2.b WHERE t1.a > t2.b
) ORDER BY 1, 2;
----

statement ok
set datafusion.optimizer.prefer_hash_join = true;
Loading