| 1 | //===----------------------------------------------------------------------===// |
| 2 | // DuckDB |
| 3 | // |
| 4 | // duckdb/optimizer/rule/constant_folding.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "duckdb/optimizer/rule.hpp" |
| 12 | |
| 13 | namespace duckdb { |
| 14 | |
| 15 | // Fold any constant scalar expressions into a single constant (i.e. [2 + 2] => [4], [2 = 2] => [True], etc...) |
| 16 | class ConstantFoldingRule : public Rule { |
| 17 | public: |
| 18 | explicit ConstantFoldingRule(ExpressionRewriter &rewriter); |
| 19 | |
| 20 | unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made, |
| 21 | bool is_root) override; |
| 22 | }; |
| 23 | |
| 24 | } // namespace duckdb |
| 25 | |