//===----------------------------------------------------------------------===// // DuckDB // // duckdb/execution/operator/aggregate/physical_window.hpp // // //===----------------------------------------------------------------------===// #pragma once #include "duckdb/common/types/chunk_collection.hpp" #include "duckdb/execution/physical_operator.hpp" #include "duckdb/parallel/pipeline.hpp" namespace duckdb { //! PhysicalWindow implements window functions //! It assumes that all functions have a common partitioning and ordering class PhysicalWindow : public PhysicalOperator { public: static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::WINDOW; public: PhysicalWindow(vector types, vector> select_list, idx_t estimated_cardinality, PhysicalOperatorType type = PhysicalOperatorType::WINDOW); //! The projection list of the WINDOW statement (may contain aggregates) vector> select_list; //! Whether or not the window is order dependent (only true if all window functions contain neither an order nor a //! partition clause) bool is_order_dependent; public: // Source interface unique_ptr GetLocalSourceState(ExecutionContext &context, GlobalSourceState &gstate) const override; unique_ptr GetGlobalSourceState(ClientContext &context) const override; SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override; bool IsSource() const override { return true; } bool ParallelSource() const override { return true; } OrderPreservationType SourceOrder() const override { return OrderPreservationType::NO_ORDER; } public: // Sink interface SinkResultType Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const override; void Combine(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate) const override; SinkFinalizeType Finalize(Pipeline &pipeline, Event &event, ClientContext &context, GlobalSinkState &gstate) const override; unique_ptr GetLocalSinkState(ExecutionContext &context) const override; unique_ptr GetGlobalSinkState(ClientContext &context) const override; bool IsSink() const override { return true; } bool ParallelSink() const override { return !is_order_dependent; } bool SinkOrderDependent() const override { return is_order_dependent; } public: idx_t MaxThreads(ClientContext &context); string ParamsToString() const override; }; } // namespace duckdb