Skip to content

[Bug] grouping sets + case when or coalesce get wrong result  #14043

@htyoung

Description

@htyoung

Search before asking

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

Version

version:1.1.3-rc02

What's Wrong?

Test SQL:
select
coalesce(col1,"all") as col1
,count(*) as cnt
from (
select null as col1
union all
select "a" as col1
) t
group by
grouping sets
(
(col1)
,()
)
;

What You Expected?

The expected result is:

col1 cnt
all 2
all 1
a 1

but the actual result is :
col1 cnt
NULL 2
all 1
a 1

image

so, I test the similar sql with hive, mysql(8.0+ and 5.7+) also get the expected result.
image
image
image

How to Reproduce?

just run the test sql directly

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions