Backport #67146 to 24.6: Remove constants from StorageMerge header in Complete stage

This commit is contained in:
robot-clickhouse 2024-07-29 13:14:38 +00:00
parent dddd8e2695
commit 9345adf9c4
3 changed files with 54 additions and 0 deletions

View File

@ -368,6 +368,14 @@ void StorageMerge::read(
/// What will be result structure depending on query processed stage in source tables?
Block common_header = getHeaderForProcessingStage(column_names, storage_snapshot, query_info, local_context, processed_stage);
if (local_context->getSettingsRef().allow_experimental_analyzer && processed_stage == QueryProcessingStage::Complete)
{
/// Remove constants.
/// For StorageDistributed some functions like `hostName` that are constants only for local queries.
for (auto & column : common_header)
column.column = column.column->convertToFullColumnIfConst();
}
auto step = std::make_unique<ReadFromMerge>(
column_names,
query_info,

View File

@ -1,2 +1,3 @@
0 Value_0 02563_db test_merge_table_1
1 Value_1 02563_db test_merge_table_2
91138316-5127-45ac-9c25-4ad8779777b4 160

View File

@ -35,4 +35,49 @@ SELECT id, value, _database, _table FROM 02563_db.test_merge_table ORDER BY id;
DROP TABLE 02563_db.test_merge_table;
DROP TABLE 02563_db.test_merge_table_1;
DROP TABLE 02563_db.test_merge_table_2;
CREATE TABLE 02563_db.t_1
(
timestamp DateTime64(9),
a String,
b String
)
ENGINE = MergeTree
PARTITION BY formatDateTime(toStartOfMinute(timestamp), '%Y%m%d%H', 'UTC')
ORDER BY (timestamp, a, b);
CREATE TABLE 02563_db.dist_t_1 (timestamp DateTime64(9), a String, b String) ENGINE = Distributed('test_shard_localhost', '02563_db', 't_1');
CREATE TABLE 02563_db.m ENGINE = Merge('02563_db', '^dist_');
INSERT INTO 02563_db.t_1 (timestamp, a, b)
select
addMinutes(toDateTime64('2024-07-13 22:00:00', 9, 'UTC'), number),
randomString(5),
randomString(5)
from numbers(30);
INSERT INTO 02563_db.t_1 (timestamp, a, b)
select
addMinutes(toDateTime64('2024-07-13 23:00:00', 9, 'UTC'), number),
randomString(5),
randomString(5)
from numbers(30);
INSERT INTO 02563_db.t_1 (timestamp, a, b)
select
addMinutes(toDateTime64('2024-07-14 00:00:00', 9, 'UTC'), number),
randomString(5),
randomString(5)
from numbers(100);
SELECT '91138316-5127-45ac-9c25-4ad8779777b4',
count()
FROM 02563_db.m;
DROP TABLE 02563_db.t_1;
DROP TABLE 02563_db.dist_t_1;
DROP TABLE 02563_db.m;
DROP DATABASE 02563_db;