Skip to content

[Bug] min function not work well. #8991

@gj-zhang

Description

@gj-zhang

Search before asking

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

Version

0.15.0 trunk-a1d1bd8
merge the code #8822 #8841

What's Wrong?

return the wrong result

What You Expected?

return the correct result.

How to Reproduce?

create table test_window_func
(
    id string,
    grade string,
    class string,
    math_score int,
    english_score int
) ENGINE=OLAP
UNIQUE KEY(`id`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`id`) BUCKETS 4
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"in_memory" = "false",
"storage_format" = "V2"
);

insert into test_window_func
values
('1', '一年级', '一班', null, 7),
       ('2', null, '一班', 8, 7),
       ('3', '一年级', '二班', 9, 9),
       ('4', '一年级', '一班', 10, 1),
       ('5', '一年级', '一班', 5, 3);

sql:
select grade, min(math_score) from test_window_func group by grade order by grade;
+-----------+-------------------+
| grade     | min(`math_score`) |
+-----------+-------------------+
| NULL      |                 8 |
| 一年级    |                 5 |
+-----------+-------------------+
the result is correct.

then insert one row.
insert into test_window_func values ('6', null, '三班', null, null);

then delete one row that id = '2';
delete from test_window_func where id = '2';

query again

select grade, min(math_score) from test_window_func group by grade order by grade;
+-----------+-------------------+
| grade     | min(`math_score`) |
+-----------+-------------------+
| NULL      |        2147483647 |
| 一年级    |                 5 |
+-----------+-------------------+

the min result is Int.MAX

Anything Else?

min window function has same error.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions