Conversation
Rebased and squashed commits from ClickHouse#48625 with some minor style changes. Co-authored-by: zhanglistar <[email protected]>
|
This is an automated comment for commit ca25f36 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
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
src/Functions/FunctionsHashing.h
Outdated
| column->getName(), getName()); | ||
| } | ||
|
|
||
| template <bool first> |
There was a problem hiding this comment.
Is it possible to add a SQL test which exercised this code?
src/Functions/FunctionsHashing.h
Outdated
| void executeNothing(const KeyColumnsType & key_cols, const IColumn * column, typename ColumnVector<ToType>::Container & vec_to) const | ||
| { | ||
| KeyType key{}; | ||
| if constexpr (Keyed) |
There was a problem hiding this comment.
Here and in l. 1188, please make sure to add a test with a keyed hash function.
| } | ||
|
|
||
| template <bool first> | ||
| void executeNothing(const KeyColumnsType & key_cols, const IColumn * column, typename ColumnVector<ToType>::Container & vec_to) const |
There was a problem hiding this comment.
Is there a SQL test which exercises this function?
| void executeNothing(const KeyColumnsType & key_cols, const IColumn * column, typename ColumnVector<ToType>::Container & vec_to) const | ||
| { | ||
| KeyType key{}; | ||
| if constexpr (Keyed) |
There was a problem hiding this comment.
For here and in l. 1188: we should have a SQL test with a keyed hash function.
| vec_to.assign(vec_to.size(), static_cast<ToType>(NULL_HASH)); | ||
| else | ||
| for (size_t i = 0; i < vec_to.size(); ++i) | ||
| vec_to[i] = combineHashes(key, vec_to[i], static_cast<ToType>(NULL_HASH)); |
There was a problem hiding this comment.
Please pull static_cast<ToType>(NULL_HASH) (here, l. 1211) out as as constant, and rewrite it to the form in l. 1201.
| { | ||
| const auto & nested_col = col_from->getNestedColumn(); | ||
| typename ColumnVector<ToType>::Container vec_temp(nested_col.size()); | ||
| bool nested_is_first = true; |
There was a problem hiding this comment.
Why don't we use template parameter first (l. 1184) instead of nested_is_first?
EDIT: Ah, I see.
| for (size_t i = 0; i < vec_to.size(); ++i) | ||
| { | ||
| ToType hash{NULL_HASH}; | ||
| if (!col_from->isNullAt(i)) |
There was a problem hiding this comment.
Non-null values are likely more common, suggest to write:
ToType hash = vec_temp[i];
if (col_from->isNullAt(i))
hash = NULL_HASH;| @@ -0,0 +1,15 @@ | |||
| select xxHash32(NULL); | |||
There was a problem hiding this comment.
Cosmetic: could we please put SQL keywords in all-lowercase or all UPPERCASE but not a mix of both?
|
|
||
| DROP TABLE IF EXISTS test_hash_on_null; | ||
| CREATE TABLE test_hash_on_null (a Array(Nullable(Int64))) ENGINE = Memory; | ||
| insert into test_hash_on_null values (NULL) ([NULL, NULL]); |
There was a problem hiding this comment.
The column type is Array(Nullable(T)). What is the actually stored value if NULL is inserted? (also wondering, how that is even possible?)
|
|
||
| DROP TABLE IF EXISTS test_hash_on_null; | ||
| CREATE TABLE test_hash_on_null (a Array(Nullable(Int64))) ENGINE = Memory; | ||
| insert into test_hash_on_null values (NULL) ([NULL, NULL]); |
There was a problem hiding this comment.
Can we add a test case which mixes non-NULL and NULL values inside an Array?
@aiven-sal For future reference and for my curiosity, which backward-compatibility issues were addressed exactly and how? |
Currently, hashing |
|
@aiven-sal Would you like to merge from master and have a look at the comments? I'd be happy to merge this one. |
|
Looks abandoned. |
|
Please reopen once the comments have been addressed |
Closes #48623
This is a re-submit of #48625 with minor changes to make it backwards-compatible (see #48625 (comment))
NULLs are assumed to have a hash value of 42, settling the question of life, the universe and everything.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
It is now possible to hash
NULLvalues in arbitraryNullabletypes, e.g.,SELECT xxHash32([toNullable(NULL)]);