Skip to content

fix aggregation (avg and quantiles) over empty decimal columns.#7431

Merged
4ertus2 merged 12 commits intoClickHouse:masterfrom
arenadata:master
Oct 23, 2019
Merged

fix aggregation (avg and quantiles) over empty decimal columns.#7431
4ertus2 merged 12 commits intoClickHouse:masterfrom
arenadata:master

Conversation

@akonyaev90
Copy link
Contributor

@akonyaev90 akonyaev90 commented Oct 22, 2019

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Category (leave one):

  • Bug Fix

Short description (up to few sentences):
fix aggregation (avg and quantiles) over empty decimal columns.

CREATE TABLE test
(
    `x` Int32, 
    `d` Decimal(10, 3)
)
ENGINE = MergeTree()
ORDER BY x;

SELECT avg(d)
FROM test

↑ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Received exception from server (version 19.14.3):
Code: 49. DB::Exception: Received from localhost:9000. DB::Exception: AggregateFunctionAvg with zero values. 

SELECT quantiles(0.1, 0.5, 0.9)(d)
FROM test

┌─quantiles(0.1, 0.5, 0.9)(d)────────────────────────────────────────────┐
│ [--9223372036854775.808,--9223372036854775.808,--9223372036854775.808] │
└────────────────────────────────────────────────────────────────────────┘


With this fix:


SELECT avg(d)
FROM test

┌─avg(d)─┐
│  0.000 │
└────────┘

SELECT quantiles(0.1, 0.5, 0.9)(d)
FROM test

┌─quantiles(0.1, 0.5, 0.9)(d)─┐
│ [0.000,0.000,0.000]         │
└─────────────────────────────┘


Tests added.

akonyaev and others added 4 commits October 22, 2019 18:31
fix result type for avg aggregation
add test returned datatype from quantile and median result for empty …
@akonyaev90 akonyaev90 requested a review from 4ertus2 October 22, 2019 15:56
akonyaev and others added 2 commits October 23, 2019 11:22
@4ertus2 4ertus2 self-requested a review October 23, 2019 11:11
Copy link
Contributor

@4ertus2 4ertus2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@4ertus2 4ertus2 merged commit bb1c1d0 into ClickHouse:master Oct 23, 2019
@akuzm akuzm added the pr-improvement Pull request with some product improvements label Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants