Please answer these questions before submitting your issue. Thanks!
-- test data
drop table test_a;
create table test_a(user_config_id bigint(20) primary key, user_id bigint(20), tenant_id bigint(20), default_company_id bigint(20));
insert into test_a(user_config_id, user_id, tenant_id, default_company_id) values (120003, 1, 0, 0);
insert into test_a(user_config_id, user_id, tenant_id, default_company_id) values (120008, 1, 1, null);
select * from test_a;
drop table test_b;
create table test_b (company_id bigint(20) primary key, company_num varchar(30), tenant_id bigint(20));
insert into test_b(company_id, company_num, tenant_id) values (0, 'HZERO', 0);
select * from test_b;
-- test SQL
select huc.*, hc.company_id from test_a huc left join test_b hc on ((hc.company_id = huc.default_company_id or (hc.company_id is null and huc.default_company_id is null)) and hc.tenant_id = huc.tenant_id) where user_id = 1; -- No.1 result correct count 2
select huc.*, hc.company_id from test_a huc left join test_b hc on (hc.company_id = huc.default_company_id and hc.tenant_id = huc.tenant_id) where user_id = 1; -- No.2 result not correct 3
Bug Report
Please answer these questions before submitting your issue. Thanks!
If possible, provide a recipe for reproducing the error.
What did you expect to see?
expect No.2 query result size 2 not 3, because data of table
test_ahas only 2 row, and left join should not be duplicate.What did you see instead?

No.2 query result size 3, has duplicate
What version of TiDB are you using (
tidb-server -Vor runselect tidb_version();on TiDB)?Release Version: None
Git Commit Hash: 508f5dd
Git Branch: master
UTC Build Time: 2018-10-27 09:59:28
GoVersion: go version go1.11 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false