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

Sort Merge Join. LeftAnti issues #10380

Closed
Tracked by #9846
comphead opened this issue May 4, 2024 · 4 comments · Fixed by #10724
Closed
Tracked by #9846

Sort Merge Join. LeftAnti issues #10380

comphead opened this issue May 4, 2024 · 4 comments · Fixed by #10724
Assignees
Labels
bug Something isn't working

Comments

@comphead
Copy link
Contributor

comphead commented May 4, 2024

Describe the bug

SMJ LeftAnti join returns the wrong result

To Reproduce

#[tokio::test]
    async fn test_anti() -> Result<()> {
        let ctx: SessionContext = SessionContext::new();

        let sql = "set datafusion.optimizer.prefer_hash_join = false;";
        let _ = ctx.sql(sql).await?.collect().await?;

        println!("=============================================================================");
        let sql = "set datafusion.execution.batch_size = 1";
        let _ = ctx.sql(sql).await?.collect().await?;

        let sql = "
            select * from (
            with
            t1 as (
                select 11 a, 12 b),
            t2 as (
                select 11 a, 13 b union all
                select 11 a, 14 b
                )
            select t1.* from t1 where not exists (select 1 from t2 where t2.a = t1.a and t2.b < t1.b)
            ) order by 1, 2;
        ";

        let actual = ctx.sql(sql).await?.collect().await?;
        let expected: Vec<&str> = vec![
            "+----+----+",
            "| a  | b  |",
            "+----+----+",
            "| 11 | 12 |",
            "+----+----+",
        ];
        datafusion_common::assert_batches_eq!(expected, &actual);

        Ok(())
    }

Expected behavior

Test should pass

Additional context

No response

@comphead comphead added the bug Something isn't working label May 4, 2024
@comphead comphead changed the title Sort Merge Join. LeftAnti problems Sort Merge Join. LeftAnti issues May 4, 2024
@comphead
Copy link
Contributor Author

Check the LeftAnti issue reported in HJ #10583 to be handled also in SMJ

@edmondop
Copy link
Contributor

@comphead can I pick this or are you arleady working on a solution?

@comphead
Copy link
Contributor Author

comphead commented May 24, 2024

Thanks @edmondop I'm already working on it, if you have spare time and would like to work on SMJ its really needed to add fuzz tests for SMJ when the filter set, I'll create a ticket

Filed #10659

@comphead comphead self-assigned this May 24, 2024
@edmondop
Copy link
Contributor

Thanks. Will work on #10659 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants