mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #40020 from canhld94/ch_canh_fix_hash
fix HashMethodOneNumber with const column
This commit is contained in:
commit
4c7222d938
@ -6,11 +6,9 @@
|
||||
#include <Common/Arena.h>
|
||||
#include <Common/LRUCache.h>
|
||||
#include <Common/assert_cast.h>
|
||||
#include "Columns/IColumn.h"
|
||||
#include <base/unaligned.h>
|
||||
|
||||
#include <Columns/ColumnString.h>
|
||||
#include <Columns/ColumnConst.h>
|
||||
#include <Columns/ColumnFixedString.h>
|
||||
#include <Columns/ColumnLowCardinality.h>
|
||||
|
||||
@ -85,11 +83,8 @@ struct HashMethodString
|
||||
|
||||
HashMethodString(const ColumnRawPtrs & key_columns, const Sizes & /*key_sizes*/, const HashMethodContextPtr &)
|
||||
{
|
||||
const IColumn * column = key_columns[0];
|
||||
if (isColumnConst(*column))
|
||||
column = &assert_cast<const ColumnConst &>(*column).getDataColumn();
|
||||
|
||||
const ColumnString & column_string = assert_cast<const ColumnString &>(*column);
|
||||
const IColumn & column = *key_columns[0];
|
||||
const ColumnString & column_string = assert_cast<const ColumnString &>(column);
|
||||
offsets = column_string.getOffsets().data();
|
||||
chars = column_string.getChars().data();
|
||||
}
|
||||
|
@ -128,7 +128,11 @@ void IntersectOrExceptTransform::accumulate(Chunk chunk)
|
||||
column_ptrs.reserve(key_columns_pos.size());
|
||||
|
||||
for (auto pos : key_columns_pos)
|
||||
{
|
||||
/// Hash methods expect non-const column
|
||||
columns[pos] = columns[pos]->convertToFullColumnIfConst();
|
||||
column_ptrs.emplace_back(columns[pos].get());
|
||||
}
|
||||
|
||||
if (!data)
|
||||
data.emplace();
|
||||
@ -160,8 +164,11 @@ void IntersectOrExceptTransform::filter(Chunk & chunk)
|
||||
column_ptrs.reserve(key_columns_pos.size());
|
||||
|
||||
for (auto pos : key_columns_pos)
|
||||
{
|
||||
/// Hash methods expect non-const column
|
||||
columns[pos] = columns[pos]->convertToFullColumnIfConst();
|
||||
column_ptrs.emplace_back(columns[pos].get());
|
||||
|
||||
}
|
||||
if (!data)
|
||||
data.emplace();
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
fooooo
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
@ -0,0 +1,13 @@
|
||||
-- Test: crash the server
|
||||
SELECT 'fooooo' INTERSECT SELECT 'fooooo';
|
||||
SELECT 'fooooo' EXCEPT SELECT 'fooooo';
|
||||
|
||||
-- Test: intersect return incorrect result for const column
|
||||
SELECT 1 FROM numbers(10) INTERSECT SELECT 1 FROM numbers(10);
|
||||
SELECT toString(1) FROM numbers(10) INTERSECT SELECT toString(1) FROM numbers(10);
|
||||
SELECT '1' FROM numbers(10) INTERSECT SELECT '1' FROM numbers(10);
|
||||
|
||||
-- Test: except return incorrect result for const column
|
||||
SELECT 2 FROM numbers(10) EXCEPT SELECT 1 FROM numbers(5);
|
||||
SELECT toString(2) FROM numbers(10) EXCEPT SELECT toString(1) FROM numbers(5);
|
||||
SELECT '2' FROM numbers(10) EXCEPT SELECT '1' FROM numbers(5);
|
Loading…
Reference in New Issue
Block a user