Fix issue with maps with arrays as keys

This commit is contained in:
Salvatore Mesoraca 2024-08-22 16:42:14 +02:00
parent 185c1f790e
commit 1ea0163dfe
3 changed files with 12 additions and 4 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

@ -244,5 +244,10 @@ Test emtpy arrays and maps
0AD04BFD000000000000000000000000
4761183170873013810
0AD04BFD000000000000000000000000
Test maps with arrays as keys
16734549324845627102
D675BB3D687973A238AB891DD99C7047
1D03941D808D04810D2363A6C107D622
16734549324845627102
16734549324845627102
1D03941D808D04810D2363A6C107D622
1D03941D808D04810D2363A6C107D622

View File

@ -351,5 +351,8 @@ 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);