Merge pull request #45987 from CurtizJ/fix-sparse-columns-crash

Fix `INTERSECT` and `EXCEPT` with sparse columns
This commit is contained in:
Anton Popov 2023-02-06 23:01:02 +01:00 committed by GitHub
commit 3ad5a085da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View File

@ -124,6 +124,8 @@ size_t IntersectOrExceptTransform::buildFilter(
void IntersectOrExceptTransform::accumulate(Chunk chunk)
{
convertToFullIfSparse(chunk);
auto num_rows = chunk.getNumRows();
auto columns = chunk.detachColumns();
@ -160,6 +162,8 @@ void IntersectOrExceptTransform::accumulate(Chunk chunk)
void IntersectOrExceptTransform::filter(Chunk & chunk)
{
convertToFullIfSparse(chunk);
auto num_rows = chunk.getNumRows();
auto columns = chunk.detachColumns();

View File

@ -0,0 +1,2 @@
0
2000

View File

@ -0,0 +1,14 @@
DROP TABLE IF EXISTS t_sparse_intersect;
CREATE TABLE t_sparse_intersect (a UInt64, c Int64) ENGINE = MergeTree
ORDER BY tuple() SETTINGS ratio_of_defaults_for_sparse_serialization = 0.8;
SYSTEM STOP MERGES t_sparse_intersect;
INSERT INTO t_sparse_intersect SELECT if (number % 10 = 0, number, 0), number FROM numbers(1000);
INSERT INTO t_sparse_intersect SELECT number, number FROM numbers(1000);
SELECT count() FROM (SELECT * FROM t_sparse_intersect EXCEPT SELECT * FROM t_sparse_intersect);
SELECT count() FROM (SELECT * FROM t_sparse_intersect INTERSECT SELECT * FROM t_sparse_intersect);
DROP TABLE t_sparse_intersect;