Backport #62274 to 24.3: Analyzer: Fix alias to parametrized view resolution

This commit is contained in:
robot-clickhouse 2024-04-17 17:06:03 +00:00
parent 74b73ee987
commit d9528ffad5
3 changed files with 33 additions and 1 deletions

View File

@ -7164,7 +7164,9 @@ void QueryAnalyzer::resolveTableFunction(QueryTreeNodePtr & table_function_node,
auto parametrized_view_storage = scope_context->getQueryContext()->buildParametrizedViewStorage(function_ast, database_name, table_name);
if (parametrized_view_storage)
{
table_function_node = std::make_shared<TableNode>(parametrized_view_storage, scope_context);
auto fake_table_node = std::make_shared<TableNode>(parametrized_view_storage, scope_context);
fake_table_node->setAlias(table_function_node->getAlias());
table_function_node = fake_table_node;
return;
}

View File

@ -0,0 +1,10 @@
0
1
2
3
4
5
6
7
8
9

View File

@ -0,0 +1,20 @@
CREATE TABLE raw_data
(
`id` UInt8,
`data` String
)
ENGINE = MergeTree
ORDER BY id;
INSERT INTO raw_data SELECT number, number
FROM numbers(10);
CREATE VIEW raw_data_parametrized AS
SELECT *
FROM raw_data
WHERE (id >= {id_from:UInt8}) AND (id <= {id_to:UInt8});
SELECT t1.id
FROM raw_data_parametrized(id_from = 0, id_to = 50000) t1
ORDER BY t1.id;