Skip to content

Commit

Permalink
Merge pull request ClickHouse#58723 from ClickHouse/fix-analyzer-coun…
Browse files Browse the repository at this point in the history
…t-distinct-pass

Analyzer: Fix LOGICAL_ERROR in CountDistinctPass
  • Loading branch information
novikd authored Jan 12, 2024
2 parents c0da616 + f41c6b0 commit a3dcd35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Analyzer/Passes/CountDistinctPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class CountDistinctVisitor : public InDepthQueryTreeVisitorWithContext<CountDist
return;

auto & count_distinct_argument_column = count_distinct_arguments_nodes[0];
if (count_distinct_argument_column->getNodeType() != QueryTreeNodeType::COLUMN)
return;
auto & count_distinct_argument_column_typed = count_distinct_argument_column->as<ColumnNode &>();

/// Build subquery SELECT count_distinct_argument_column FROM table_expression GROUP BY count_distinct_argument_column
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set count_distinct_optimization = 1;

SELECT uniqExact('257')
FROM
(SELECT
number, CAST(number / 9223372036854775806, 'UInt64') AS m
FROM numbers(3)
);

0 comments on commit a3dcd35

Please sign in to comment.