Skip to content

Commit 96d1f7a

Browse files
authored
Merge pull request ClickHouse#62274 from ClickHouse/analyzer-fix-param-view-alias
Analyzer: Fix alias to parametrized view resolution
2 parents d12608f + 951fa67 commit 96d1f7a

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/Analyzer/Passes/QueryAnalysisPass.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7164,7 +7164,9 @@ void QueryAnalyzer::resolveTableFunction(QueryTreeNodePtr & table_function_node,
71647164
auto parametrized_view_storage = scope_context->getQueryContext()->buildParametrizedViewStorage(function_ast, database_name, table_name);
71657165
if (parametrized_view_storage)
71667166
{
7167-
table_function_node = std::make_shared<TableNode>(parametrized_view_storage, scope_context);
7167+
auto fake_table_node = std::make_shared<TableNode>(parametrized_view_storage, scope_context);
7168+
fake_table_node->setAlias(table_function_node->getAlias());
7169+
table_function_node = fake_table_node;
71687170
return;
71697171
}
71707172

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
0
2+
1
3+
2
4+
3
5+
4
6+
5
7+
6
8+
7
9+
8
10+
9
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CREATE TABLE raw_data
2+
(
3+
`id` UInt8,
4+
`data` String
5+
)
6+
ENGINE = MergeTree
7+
ORDER BY id;
8+
9+
10+
INSERT INTO raw_data SELECT number, number
11+
FROM numbers(10);
12+
13+
CREATE VIEW raw_data_parametrized AS
14+
SELECT *
15+
FROM raw_data
16+
WHERE (id >= {id_from:UInt8}) AND (id <= {id_to:UInt8});
17+
18+
SELECT t1.id
19+
FROM raw_data_parametrized(id_from = 0, id_to = 50000) t1
20+
ORDER BY t1.id;

0 commit comments

Comments
 (0)