Skip to content

[Bug] SELECT DISTINCT returns wrong value for UNIQUE model #36343

@malwaregarry

Description

@malwaregarry

Search before asking

  • I had searched in the issues and found no similar issues.

Version

2.1.4

What's Wrong?

Could be related to #36072

CREATE TABLE t0(c0 INT) UNIQUE KEY(c0) DISTRIBUTED BY HASH (c0) PROPERTIES ("replication_num" = "1");
CREATE TABLE t1(c0 INT NOT NULL) DISTRIBUTED BY HASH (c0) PROPERTIES ("replication_num" = "1");
INSERT INTO t0 (c0) VALUES (1);

This returns value 0, but there is no value 0 in t1.c0:
SELECT DISTINCT t1.c0 FROM t0 LEFT JOIN t1 ON (true) WHERE ((t1.c0) IS NULL);

What You Expected?

This returns null:
SELECT DISTINCT t1.c0 FROM t0 LEFT JOIN t1 ON (true) WHERE ((t1.c0) IS NULL);

How to Reproduce?

DROP DATABASE IF EXISTS doris2;
CREATE DATABASE doris2;
USE doris2;
CREATE TABLE t0(c0 INT) UNIQUE KEY(c0) DISTRIBUTED BY HASH (c0) PROPERTIES ("replication_num" = "1");
CREATE TABLE t1(c0 INT NOT NULL) DISTRIBUTED BY HASH (c0) PROPERTIES ("replication_num" = "1");
INSERT INTO t0 (c0) VALUES (1);
SELECT DISTINCT t1.c0 FROM  t0 LEFT JOIN t1 ON (true); 
SELECT DISTINCT t1.c0 FROM  t0 LEFT JOIN t1 ON (true) WHERE ((t1.c0) IS NULL);

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions