mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #70759 from ClickHouse/backport/24.9/70695
Backport #70695 to 24.9: Fixed crash in filling of missed arrays
This commit is contained in:
commit
ae3c795385
@ -156,13 +156,21 @@ void IMergeTreeReader::evaluateMissingDefaults(Block additional_columns, Columns
|
||||
auto it = original_requested_columns.begin();
|
||||
for (size_t pos = 0; pos < num_columns; ++pos, ++it)
|
||||
{
|
||||
auto name_in_storage = it->getNameInStorage();
|
||||
|
||||
if (full_requested_columns_set.emplace(name_in_storage).second)
|
||||
full_requested_columns.emplace_back(name_in_storage, it->getTypeInStorage());
|
||||
|
||||
if (res_columns[pos])
|
||||
{
|
||||
/// If column is already read, request it as is.
|
||||
if (full_requested_columns_set.emplace(it->name).second)
|
||||
full_requested_columns.emplace_back(it->name, it->type);
|
||||
|
||||
additional_columns.insert({res_columns[pos], it->type, it->name});
|
||||
}
|
||||
else
|
||||
{
|
||||
/// If column or subcolumn is missed, request full column for correct evaluation of defaults of subcolumns.
|
||||
auto name_in_storage = it->getNameInStorage();
|
||||
if (full_requested_columns_set.emplace(name_in_storage).second)
|
||||
full_requested_columns.emplace_back(name_in_storage, it->getTypeInStorage());
|
||||
}
|
||||
}
|
||||
|
||||
auto dag = DB::evaluateMissingDefaults(
|
||||
@ -183,6 +191,12 @@ void IMergeTreeReader::evaluateMissingDefaults(Block additional_columns, Columns
|
||||
it = original_requested_columns.begin();
|
||||
for (size_t pos = 0; pos < num_columns; ++pos, ++it)
|
||||
{
|
||||
if (additional_columns.has(it->name))
|
||||
{
|
||||
res_columns[pos] = additional_columns.getByName(it->name).column;
|
||||
continue;
|
||||
}
|
||||
|
||||
auto name_in_storage = it->getNameInStorage();
|
||||
res_columns[pos] = additional_columns.getByName(name_in_storage).column;
|
||||
|
||||
|
@ -27,5 +27,5 @@
|
||||
2 ('aaa','bbb') [1,NULL,3]
|
||||
3 ('ccc','ddd') [4,5,6]
|
||||
1 foo bar 3 [0,1,0]
|
||||
2 foo bar 3 [0,1,0]
|
||||
2 aaa bbb 3 [0,1,0]
|
||||
3 ccc ddd 3 [0,0,0]
|
||||
|
@ -0,0 +1 @@
|
||||
20000
|
22
tests/queries/0_stateless/03252_fill_missed_arrays.sql
Normal file
22
tests/queries/0_stateless/03252_fill_missed_arrays.sql
Normal file
@ -0,0 +1,22 @@
|
||||
DROP TABLE IF EXISTS t_fill_arrays;
|
||||
|
||||
CREATE TABLE t_fill_arrays
|
||||
(
|
||||
`id` String,
|
||||
`mapCol` Map(String, Array(String)),
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
ORDER BY id
|
||||
SETTINGS vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 1, min_bytes_for_full_part_storage = 0;
|
||||
|
||||
INSERT INTO t_fill_arrays (id) SELECT hex(number) FROM numbers(10000);
|
||||
|
||||
ALTER TABLE t_fill_arrays ADD COLUMN arrCol Array(String) DEFAULT [];
|
||||
|
||||
INSERT INTO t_fill_arrays (id) SELECT hex(number) FROM numbers(10000);
|
||||
|
||||
SELECT count() FROM t_fill_arrays WHERE NOT ignore(arrCol, mapCol.values);
|
||||
|
||||
OPTIMIZE TABLE t_fill_arrays FINAL;
|
||||
|
||||
DROP TABLE t_fill_arrays;
|
Loading…
Reference in New Issue
Block a user