Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClickHouse appears to run into an overflow on Q3 #49

Closed
Mytherin opened this issue Nov 13, 2022 · 2 comments
Closed

ClickHouse appears to run into an overflow on Q3 #49

Mytherin opened this issue Nov 13, 2022 · 2 comments
Labels
wontfix This will not be worked on

Comments

@Mytherin
Copy link
Contributor

Ran into this while adding result verification, the result produced by ClickHouse for Q3 appears to be incorrect - likely due to an internal overflow:

SELECT AVG(UserID) FROM hits;
┌─────────avg(UserID)─┐
│ -55945124888.916016 │
└─────────────────────┘

I'm not sure if this is intended behavior - it does not appear to be listed on the documentation.

Adding a cast to INT128 or DOUBLE fixes the problem:

SELECT AVG(toInt128(UserID)) FROM hits;
┌─avg(toInt128(UserID))─┐
│   2528953029789716000 │
└───────────────────────┘

SELECT AVG(CAST(UserID AS DOUBLE)) FROM hits;
┌─avg(CAST(UserID, 'DOUBLE'))─┐
│         2528953029789716000 │
└─────────────────────────────┘
@sundy-li
Copy link
Contributor

sundy-li commented Nov 15, 2022

Yes, it's by intended behavior. Duckdb uses hugeint_t for aggregation sum(int64_t) yet ClickHouse uses UInt64 for NearestFieldTypeImpl<UInt64>.

@alexey-milovidov alexey-milovidov added the wontfix This will not be worked on label Feb 14, 2023
@alexey-milovidov
Copy link
Member

alexey-milovidov commented Feb 14, 2023

The docs have to be improved.

@alexey-milovidov alexey-milovidov changed the title Clickhouse appears to run into an overflow on Q3 ClickHouse appears to run into an overflow on Q3 Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants