Skip to content

Commit f8caef6

Browse files
committed
ungrouped aggregate has cardinality of 1
1 parent 2301d9f commit f8caef6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/optimizer/join_order/relation_statistics_helper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ RelationStats RelationStatisticsHelper::ExtractAggregationStats(LogicalAggregate
350350
// most likely we are running on parquet files. Therefore we divide by 2.
351351
new_card = (double)child_stats.cardinality / 2;
352352
}
353-
stats.cardinality = LossyNumericCast<idx_t>(new_card);
353+
// an ungrouped aggregate has 1 row
354+
stats.cardinality = aggr.groups.empty() ? 1 : LossyNumericCast<idx_t>(new_card);
354355
stats.column_names = child_stats.column_names;
355356
stats.stats_initialized = true;
356357
auto num_child_columns = aggr.GetColumnBindings().size();

0 commit comments

Comments
 (0)