fix merges of wide parts with type Object

This commit is contained in:
Anton Popov 2022-04-25 16:44:24 +00:00
parent 2106a7b895
commit d28b1559e6
3 changed files with 32 additions and 5 deletions

View File

@ -44,12 +44,11 @@ bool injectRequiredColumnsRecursively(
if (alter_conversions.isColumnRenamed(column_name_in_part))
column_name_in_part = alter_conversions.getColumnOldName(column_name_in_part);
auto column_in_part = NameAndTypePair(
column_name_in_part, column_in_storage->getSubcolumnName(),
column_in_storage->getTypeInStorage(), column_in_storage->type);
auto column_in_part = part->getColumns().tryGetByName(column_name_in_part);
/// column has files and hence does not require evaluation
if (part->hasColumnFiles(column_in_part))
if (column_in_part
&& (!column_in_storage->isSubcolumn()
|| column_in_part->type->tryGetSubcolumnType(column_in_storage->getSubcolumnName())))
{
/// ensure each column is added only once
if (!required_columns.contains(column_name))

View File

@ -0,0 +1,3 @@
{"data":{"k1":0,"k2":2}}
{"data":{"k1":1,"k2":0}}
Tuple(k1 Int8, k2 Int8)

View File

@ -0,0 +1,25 @@
-- Tags: no-fasttest
SET allow_experimental_object_type = 1;
SET output_format_json_named_tuples_as_objects = 1;
DROP TABLE IF EXISTS t_json_wide_parts;
CREATE TABLE t_json_wide_parts (data JSON)
ENGINE MergeTree ORDER BY tuple()
SETTINGS min_bytes_for_wide_part = 0;
SYSTEM STOP MERGES t_json_wide_parts;
INSERT INTO t_json_wide_parts VALUES ('{"k1": 1}');
INSERT INTO t_json_wide_parts VALUES ('{"k2": 2}');
SYSTEM START MERGES t_json_wide_parts;
OPTIMIZE TABLE t_json_wide_parts FINAL;
SELECT data FROM t_json_wide_parts ORDER BY data.k1 FORMAT JSONEachRow;
SELECT type FROM system.parts_columns
WHERE table = 't_json_wide_parts' AND database = currentDatabase() AND active;
DROP TABLE t_json_wide_parts;