mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #61847 from ClickHouse/fix-distinct-in-subquery-analyzer
Fix: DISTINCT in subquery with analyzer
This commit is contained in:
commit
f9bff8bd79
@ -148,6 +148,13 @@ void RemoveUnusedProjectionColumnsPass::run(QueryTreeNodePtr & query_tree_node,
|
||||
|
||||
for (auto & [query_or_union_node, used_columns] : visitor.query_or_union_node_to_used_columns)
|
||||
{
|
||||
/// can't remove columns from distinct, see example - 03023_remove_unused_column_distinct.sql
|
||||
if (auto * query_node = query_or_union_node->as<QueryNode>())
|
||||
{
|
||||
if (query_node->isDistinct())
|
||||
continue;
|
||||
}
|
||||
|
||||
auto used_projection_indexes = convertUsedColumnNamesToUsedProjectionIndexes(query_or_union_node, used_columns);
|
||||
updateUsedProjectionIndexes(query_or_union_node, used_projection_indexes);
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
product_0
|
||||
product_1
|
||||
product_0
|
||||
product_1
|
||||
product_0
|
||||
product_1
|
@ -0,0 +1,15 @@
|
||||
SELECT product_id
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
product_id,
|
||||
section_id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
concat('product_', number % 2) AS product_id,
|
||||
concat('section_', number % 3) AS section_id
|
||||
FROM numbers(10)
|
||||
)
|
||||
)
|
||||
SETTINGS allow_experimental_analyzer = 1;
|
Loading…
Reference in New Issue
Block a user