#pragma once #include #include namespace DB { /// Execute DISTINCT for specified columns. class DistinctStep : public ITransformingStep { public: DistinctStep( const Header & input_header_, const SizeLimits & set_size_limits_, UInt64 limit_hint_, const Names & columns_, /// If is enabled, execute distinct for separate streams, otherwise for merged streams. bool pre_distinct_); String getName() const override { return "Distinct"; } const Names & getColumnNames() const { return columns; } void transformPipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &) override; void describeActions(JSONBuilder::JSONMap & map) const override; void describeActions(FormatSettings & settings) const override; bool isPreliminary() const { return pre_distinct; } UInt64 getLimitHint() const { return limit_hint; } const SizeLimits & getSetSizeLimits() const { return set_size_limits; } void applyOrder(SortDescription sort_desc) { distinct_sort_desc = std::move(sort_desc); } const SortDescription & getSortDescription() const override { return distinct_sort_desc; } private: void updateOutputHeader() override; SizeLimits set_size_limits; UInt64 limit_hint; const Names columns; bool pre_distinct; SortDescription distinct_sort_desc; }; }