ccoffline opened a new issue #4772:
URL: https://github.com/apache/incubator-doris/issues/4772
**Describe the bug**
```sql
-- create table
DROP TABLE IF EXISTS `test_t`;
CREATE TABLE `test_t` (
`name` VARCHAR(1000) NULL COMMENT "string"
) ENGINE=OLAP
DUPLICATE KEY(`name`)
DISTRIBUTED BY HASH(`name`) BUCKETS 5
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "DEFAULT"
);
-- insert data
INSERT INTO test_t (`name`)
VALUES ('aaaaa'), ('ccccc')
;
-- returns wrong empty set
SELECT `t1`.`name`
FROM (
SELECT `name`
FROM `test_t`
GROUP BY `name`
) `t1`
UNION ALL
SELECT `t2`.`name`
FROM (
SELECT `name`,
-1 as `bool`
FROM `test_t`
GROUP BY `name`
) `t2`
WHERE `t2`.`bool` = 1
;
-- returns correct result ‘aaaaa’ and ‘ccccc’
SELECT `t2`.`name`
FROM (
SELECT `name`,
-1 as `bool`
FROM `test_t`
GROUP BY `name`
) `t2`
WHERE `t2`.`bool` = 1
UNION ALL
SELECT `t1`.`name`
FROM (
SELECT `name`
FROM `test_t`
GROUP BY `name`
) `t1`
;
```
**Additional context**
Fixing, may need some help QAQ.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]