Skip to content

Commit

Permalink
Merge pull request #62274 from ClickHouse/analyzer-fix-param-view-alias
Browse files Browse the repository at this point in the history
Analyzer: Fix alias to parametrized view resolution
  • Loading branch information
novikd committed Apr 17, 2024
2 parents d12608f + 951fa67 commit 96d1f7a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Analyzer/Passes/QueryAnalysisPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
0
1
2
3
4
5
6
7
8
9
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 96d1f7a

Please sign in to comment.