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

Bug(planner): wrong output in hash join #5522

Closed
xudong963 opened this issue May 23, 2022 · 5 comments · Fixed by #5538 or #5539
Closed

Bug(planner): wrong output in hash join #5522

xudong963 opened this issue May 23, 2022 · 5 comments · Fixed by #5538 or #5539
Assignees
Labels
A-planner Area: planner/optimizer C-bug Category: something isn't working

Comments

@xudong963
Copy link
Member

The result is not correct in my case:

create table t1(a int, b int);
create table t2(a int, b int);
create table t3(a int, b int);

insert into t1 select number, number+1 from numbers(100000000);
insert into t2 select number, number+1 from numbers(20000000);
insert into t3 select number, number+1 from numbers(10000000);

select count(*) from t1 inner join t2 on t1.a=t2.a inner join t3 on t2.b=t3.b;

+----------+
| COUNT(*) |
+----------+
|        0 |
+----------+
1 row in set (6.45 sec)

Result should be:

┌──count()─┐
│ 10000000 │
└──────────┘

Originally posted by @BohuTANG in #5497 (comment)

@xudong963 xudong963 self-assigned this May 23, 2022
@xudong963 xudong963 added C-bug Category: something isn't working A-planner Area: planner/optimizer labels May 23, 2022
@sundy-li
Copy link
Member

fn visit_read_data_source(&mut self, plan: &ReadDataSourcePlan) -> Result<Pipeline> {
        // Bind plan partitions to context.
 self.ctx.try_set_partitions(plan.parts.clone())?;

I believe it's because we set the partition to the ctx. Since we read two different tables, the partition info are overridden.

cc @zhang2014

:) select count(*) from (select to_int32(a) as a from t1 order by a limit 10) t1 inner join (select to_int32(number) as a from numbers(10)) t2 on t1.a=t2.a;
ERROR 1105 (HY000): Code: 1015, displayText = Cannot downcast from PartInfo to FusePartInfo. (while in processor thread 5).

@leiysky
Copy link
Contributor

leiysky commented May 23, 2022

@zhang2014
Copy link
Member

zhang2014 commented May 23, 2022

@sundy-li This should have been fixed by

https://github.com/datafuselabs/databend/blob/eb07b393c769b152ef742c0b8f91032de5c98562/query/src/sql/exec/mod.rs#L310-L332

We still use self.ctx in build_physical_scan CC: @leiysky

@leiysky
Copy link
Contributor

leiysky commented May 23, 2022

@zhang2014 You are right, I will fix this in #5538 as well.

@leiysky
Copy link
Contributor

leiysky commented May 23, 2022

I missed the related commit in #5538, thus I opened #5539 to fix this.

@leiysky leiysky reopened this May 23, 2022
@mergify mergify bot closed this as completed in #5539 May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-planner Area: planner/optimizer C-bug Category: something isn't working
Projects
None yet
4 participants