Skip to content

druid sql bug of having  #4957

Closed
Closed

Description

@hellobabygogo

I found a bug of druid sql about having. when I add having condition of "count(distinct uid)". It will return []. if I replace it for "having count(uid)", it will return right result.for example:
{
"query": "select (count(distinct("uid")) filter (where binlog_event='i')) as __y,Floor(__time to MINUTE) as __time from "test_dataSource" where __time > TIMESTAMP '2017-10-12 00:00:00' and __time < TIMESTAMP '2017-10-12 23:59:59' group by Floor(__time to MINUTE) having (count("uid") filter (where binlog_event='i')) >0",
"context": {
"sqlTimeZone": "Asia/Shanghai",
"skipEmptyBuckets": "false"
}
}
the reasult is:
[
{
"__y": 1,
"__time": "2017-10-12T01:54:00.000+08:00"
},
{
"__y": 2,
"__time": "2017-10-12T02:23:00.000+08:00"
}
]

but when I used having (count(distinct("uid")) filter (where binlog_event='i')) >0
the result is:
[]

Activity

  1. gianm commented on Oct 13, 2017

    @gianm
    Contributor

    Thanks for the report. This looks related to #4883 and can be fixed after that patch is committed.

  2. self-assigned this
    on Oct 13, 2017
  3. gianm commented on Oct 16, 2017

    @gianm
    Contributor

    There are some utilities in #4890 that would help with fixing this bug too, so I'll try to get that one committed first.

  4. added a commit that references this issue on Nov 1, 2017
    6c725a7
  5. added a commit that references this issue on Jun 12, 2026
    b570061
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions