mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #13887 from ClickHouse/fix-fixed-string-partial-sort
Fix fixed string partial sort
This commit is contained in:
commit
322cb241b9
@ -189,7 +189,7 @@ void ColumnFixedString::updatePermutation(bool reverse, size_t limit, int, Permu
|
||||
auto new_first = first;
|
||||
for (auto j = first + 1; j < last; ++j)
|
||||
{
|
||||
if (memcmpSmallAllowOverflow15(chars.data() + j * n, chars.data() + new_first * n, n) != 0)
|
||||
if (memcmpSmallAllowOverflow15(chars.data() + res[j] * n, chars.data() + res[new_first] * n, n) != 0)
|
||||
{
|
||||
if (j - new_first > 1)
|
||||
new_ranges.emplace_back(new_first, j);
|
||||
@ -210,7 +210,7 @@ void ColumnFixedString::updatePermutation(bool reverse, size_t limit, int, Permu
|
||||
auto new_first = first;
|
||||
for (auto j = first + 1; j < limit; ++j)
|
||||
{
|
||||
if (memcmpSmallAllowOverflow15(chars.data() + j * n, chars.data() + new_first * n, n) != 0)
|
||||
if (memcmpSmallAllowOverflow15(chars.data() + res[j] * n, chars.data() + res[new_first] * n, n) != 0)
|
||||
{
|
||||
if (j - new_first > 1)
|
||||
new_ranges.emplace_back(new_first, j);
|
||||
@ -221,7 +221,7 @@ void ColumnFixedString::updatePermutation(bool reverse, size_t limit, int, Permu
|
||||
auto new_last = limit;
|
||||
for (auto j = limit; j < last; ++j)
|
||||
{
|
||||
if (memcmpSmallAllowOverflow15(chars.data() + j * n, chars.data() + new_first * n, n) == 0)
|
||||
if (memcmpSmallAllowOverflow15(chars.data() + res[j] * n, chars.data() + res[new_first] * n, n) == 0)
|
||||
{
|
||||
std::swap(res[new_last], res[j]);
|
||||
++new_last;
|
||||
|
12
tests/queries/0_stateless/01453_fixsed_string_sort.reference
Normal file
12
tests/queries/0_stateless/01453_fixsed_string_sort.reference
Normal file
@ -0,0 +1,12 @@
|
||||
8AD8FC5EA49E544C98E61140AFD79F80 1
|
||||
8AD8FC5EA49E544C98E61140AFD79F80 1
|
||||
8AD8FC5EA49E544C98E61140AFD79F80 2
|
||||
8AD8FC5EA49E544C98E61140AFD79F80 2
|
||||
999E114066EF56109C3AB3FB33E0FDA9 1
|
||||
999E114066EF56109C3AB3FB33E0FDA9 1
|
||||
999E114066EF56109C3AB3FB33E0FDA9 1
|
||||
999E114066EF56109C3AB3FB33E0FDA9 1
|
||||
999E114066EF56109C3AB3FB33E0FDA9 2
|
||||
999E114066EF56109C3AB3FB33E0FDA9 2
|
||||
999E114066EF56109C3AB3FB33E0FDA9 2
|
||||
999E114066EF56109C3AB3FB33E0FDA9 2
|
22
tests/queries/0_stateless/01453_fixsed_string_sort.sql
Normal file
22
tests/queries/0_stateless/01453_fixsed_string_sort.sql
Normal file
@ -0,0 +1,22 @@
|
||||
drop table if exists badFixedStringSort;
|
||||
CREATE TABLE IF NOT EXISTS badFixedStringSort (uuid5_old FixedString(16), subitem String) engine=MergeTree order by tuple();
|
||||
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '1');
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '2');
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '1');
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '2');
|
||||
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('8ad8fc5e-a49e-544c-98e6-1140afd79f80'), '2');
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('8ad8fc5e-a49e-544c-98e6-1140afd79f80'), '1');
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('8ad8fc5e-a49e-544c-98e6-1140afd79f80'), '2');
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('8ad8fc5e-a49e-544c-98e6-1140afd79f80'), '1');
|
||||
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '1');
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '2');
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '1');
|
||||
INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '2');
|
||||
|
||||
optimize table badFixedStringSort final;
|
||||
select hex(uuid5_old), subitem from badFixedStringSort ORDER BY uuid5_old, subitem;
|
||||
|
||||
drop table if exists badFixedStringSort;
|
Loading…
Reference in New Issue
Block a user