Merge pull request #48517 from CurtizJ/fix-memory-compressed-tables

Fix storage `Memory` with enabled compression
This commit is contained in:
Anton Popov 2023-04-13 19:52:49 +02:00 committed by GitHub
commit 5f01b8a2b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 9 deletions

View File

@ -15,23 +15,18 @@ ColumnPtr tryGetColumnFromBlock(const Block & block, const NameAndTypePair & req
if (!elem)
return nullptr;
DataTypePtr elem_type;
ColumnPtr elem_column;
auto elem_type = elem->type;
auto elem_column = elem->column->decompress();
if (requested_column.isSubcolumn())
{
auto subcolumn_name = requested_column.getSubcolumnName();
elem_type = elem->type->tryGetSubcolumnType(subcolumn_name);
elem_column = elem->type->tryGetSubcolumn(subcolumn_name, elem->column);
elem_column = elem_type->tryGetSubcolumn(subcolumn_name, elem_column);
elem_type = elem_type->tryGetSubcolumnType(subcolumn_name);
if (!elem_type || !elem_column)
return nullptr;
}
else
{
elem_type = elem->type;
elem_column = elem->column;
}
return castColumn({elem_column, elem_type, ""}, requested_column.type);
}

View File

@ -0,0 +1,2 @@
1 foo ['0','1','2','3','4'] {'k1':'v1'}
2 bar ['0','1','2','3','4'] {'k2':'v2'}

View File

@ -0,0 +1,11 @@
DROP TABLE IF EXISTS t_memory_compressed;
CREATE TABLE t_memory_compressed (id UInt64, s String, arr Array(LowCardinality(String)), m Map(String, String))
ENGINE = Memory SETTINGS compress = 1;
INSERT INTO t_memory_compressed VALUES (1, 'foo', range(5), map('k1', 'v1'));
INSERT INTO t_memory_compressed VALUES (2, 'bar', range(5), map('k2', 'v2'));
SELECT * FROM t_memory_compressed ORDER BY id;
DROP TABLE t_memory_compressed;