Repository navigation
Fix sumMapFiltered with NaN values - #58959
Conversation
|
This is an automated comment for commit f5ffe4e with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page Successful checks
|
There was a problem hiding this comment.
std::hash is very bad for integers, see:
https://presentations.clickhouse.com/hash_tables/#8
Xor of hashes is very bad for hash combining, see:
https://presentations.clickhouse.com/hash_tables/#11
There was a problem hiding this comment.
Reimplementing with intHash and hash(x) ^ y.
There was a problem hiding this comment.
After implementing it I've decided to instead fix Field::operator<(). I might keep the implementation in a separate file in case we want to use it in the future (although in a different file, to avoid pushing even more deps to Field.h
f082027 to
f6f30eb
Compare
| @@ -0,0 +1,147 @@ | |||
| #pragma once | |||
There was a problem hiding this comment.
I introduced this but it's not used. We could remove it or keep it in case we want to use std::unordered_map / std::unordered_set of DB::Field. I did not include it into Field.h itself to avoid adding more dependencies to a file that's used in almost 3000 other files.
There was a problem hiding this comment.
Nevermind, the style did not like it, so I've removed it.
alexey-milovidov
left a comment
There was a problem hiding this comment.
It looks like the newly added test is passed on the old version.
|
It looks like the check is broken. I don’t see it running the tests. Here is fiddle: https://fiddle.clickhouse.com/7720d824-6c43-46b7-b708-20538042bd2a |
|
Need to investigate the perf failures. Something odd is going on |
|
Unrelated failures. The perf failures ( |
|
Failures:
|
|
This PR indeed breaks perf tests, see #59287 for details, though maybe it worth to fix the behavior of |
| throw Exception( | ||
| ErrorCodes::SIZES_OF_ARRAYS_DONT_MATCH, | ||
| "Arrays passed to {} must have equal size", getName()); | ||
| "Arrays passed to {} must have equal size. Argument {} has size {}, but expected {}", |
There was a problem hiding this comment.
This works incorrectly, it will always match, since this is the number of rows in the column, not number of elements in array.
TBH, I don't understand why sumMap doesn't return zeroes (positive or now negative). It's not documented anywhere and it seems to be caused by bad code design. This doesn't make any sense to me: It seems it was added as a bug and then people started to rely on it |
The `Float64` branch of `Field::operator<=` read both operands from `*this`, so it compared a value with itself and returned `true` for every `rhs`. `Field::operator>=` is implemented as `rhs <= *this`, so it inherited the same defect. Read the second operand from `rhs`, and pin the ordering of `Float64` fields - including `NaN`, which is ordered after every number and is equal to itself - with unit tests. There are no `Field`-to-`Field` uses of `<=` or `>=` in the codebase today, so no query result can change; this removes a trap for the first caller. Closes: ClickHouse#112778 Caused by: ClickHouse#58959 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
-0is now also treated as equal to0; since 0 values are discarded,-0values are discarded too.Documentation entry for user-facing changes
Implement NaN handling in
DB::Field::operator<, which is used bystd::set<DB::Field>Closes #58741