Skip to content

Vector Filtered Aggregates return the default buffer init values when no rows match the filter predicate #10644

@damnMeddlingKid

Description

@damnMeddlingKid

Affected Version

Tested on 0.20.0

Description

Not sure if this is a bug
When executing a filtered aggregate that doesn't match any rows druid will return the init value of the aggregate involved. For example for the LongMaxVectorAggregator druid will return Long.MIN as the result of the aggregation because this is what the aggregator was initialized to https://github.com/apache/druid/blob/master/processing/src/main/java/org/apache/druid/query/aggregation/LongMaxVectorAggregator.java#L39

Steps to reproduce

  1. set druid.generic.useDefaultValueForNull=true
  2. Run a query like
SELECT MAX(__time) as t1, MAX(__time) FILTER(WHERE dim1 = 'non_existing') as t2 FROM druid.foo

this is a filtered aggregate on a time column where the filter doesn't match anything. I'm not sure what the expected result should be here, but i was surprised to find that the actual result is

"t1":"2001-01-03T00:00:00.000Z", "t2":"-292275055-05-16T16:47:04.192Z"

It sounds like according to the documentation LongMax should return 0 as a default value when theres nothing to aggregate.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions