1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/planner/operator/logical_limit.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/planner/logical_operator.hpp" |
12 | |
13 | namespace duckdb { |
14 | |
15 | //! LogicalLimit represents a LIMIT clause |
16 | class LogicalLimit : public LogicalOperator { |
17 | public: |
18 | static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_LIMIT; |
19 | |
20 | public: |
21 | LogicalLimit(int64_t limit_val, int64_t offset_val, unique_ptr<Expression> limit, unique_ptr<Expression> offset); |
22 | |
23 | //! Limit and offset values in case they are constants, used in optimizations. |
24 | int64_t limit_val; |
25 | int64_t offset_val; |
26 | //! The maximum amount of elements to emit |
27 | unique_ptr<Expression> limit; |
28 | //! The offset from the start to begin emitting elements |
29 | unique_ptr<Expression> offset; |
30 | |
31 | public: |
32 | vector<ColumnBinding> GetColumnBindings() override; |
33 | idx_t EstimateCardinality(ClientContext &context) override; |
34 | |
35 | void Serialize(FieldWriter &writer) const override; |
36 | static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader); |
37 | |
38 | protected: |
39 | void ResolveTypes() override; |
40 | }; |
41 | } // namespace duckdb |
42 |