Merge pull request #68784 from ClickHouse/backport/24.5/68731

Backport #68731 to 24.5: Fix regression in `sipHash(64/128)Keyed`
This commit is contained in:
robot-ch-test-poll 2024-08-23 13:38:41 +02:00 committed by GitHub
commit dc62b44219
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View File

@ -93,9 +93,9 @@ namespace impl
if (is_const)
i = 0;
assert(key0->size() == key1->size());
if (offsets != nullptr)
if (offsets != nullptr && i > 0)
{
const auto * const begin = offsets->begin();
const auto * const begin = std::upper_bound(offsets->begin(), offsets->end(), i - 1);
const auto * upper = std::upper_bound(begin, offsets->end(), i);
if (upper != offsets->end())
i = upper - begin;

View File

@ -239,10 +239,15 @@ Check bug found fuzzing
Test arrays and maps
608E1FF030C9E206185B112C2A25F1A7
ABB65AE97711A2E053E324ED88B1D08B
Test emtpy arrays and maps
Test empty arrays and maps
4761183170873013810
0AD04BFD000000000000000000000000
4761183170873013810
0AD04BFD000000000000000000000000
Test maps with arrays as keys
16734549324845627102
D675BB3D687973A238AB891DD99C7047
1D03941D808D04810D2363A6C107D622
16734549324845627102
16734549324845627102
1D03941D808D04810D2363A6C107D622
1D03941D808D04810D2363A6C107D622

View File

@ -346,10 +346,13 @@ INSERT INTO sipHashKeyed_keys FORMAT VALUES ({'a':'b', 'c':'d'}), ({'e':'f', 'g'
SELECT hex(sipHash128ReferenceKeyed((0::UInt64, materialize(0::UInt64)), a)) FROM sipHashKeyed_keys ORDER BY a;
DROP TABLE sipHashKeyed_keys;
SELECT 'Test emtpy arrays and maps';
SELECT 'Test empty arrays and maps';
SELECT sipHash64Keyed((1::UInt64, 2::UInt64), []);
SELECT hex(sipHash128Keyed((1::UInt64, 2::UInt64), []));
SELECT sipHash64Keyed((1::UInt64, 2::UInt64), mapFromArrays([], []));
SELECT hex(sipHash128Keyed((1::UInt64, 2::UInt64), mapFromArrays([], [])));
SELECT 'Test maps with arrays as keys';
SELECT sipHash64Keyed((1::UInt64, 2::UInt64), map([0], 1, [2], 3));
SELECT hex(sipHash128Keyed((0::UInt64, 0::UInt64), map([0], 1, [2], 3)));
SELECT hex(sipHash128Keyed((1::UInt64, 2::UInt64), map([0], 1, [2], 3)));
SELECT sipHash64Keyed((materialize(1::UInt64), 2::UInt64), map([0], 1, [2], 3)) FROM numbers(2);
SELECT hex(sipHash128Keyed((materialize(1::UInt64), 2::UInt64), map([0], 1, [2], 3))) FROM numbers(2);