1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/optimizer/rule.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/optimizer/matcher/expression_matcher.hpp"
12#include "duckdb/optimizer/matcher/logical_operator_matcher.hpp"
13
14namespace duckdb {
15class ExpressionRewriter;
16
17class Rule {
18public:
19 explicit Rule(ExpressionRewriter &rewriter) : rewriter(rewriter) {
20 }
21 virtual ~Rule() {
22 }
23
24 //! The expression rewriter this rule belongs to
25 ExpressionRewriter &rewriter;
26 //! The root
27 unique_ptr<LogicalOperatorMatcher> logical_root;
28 //! The expression matcher of the rule
29 unique_ptr<ExpressionMatcher> root;
30
31 ClientContext &GetContext() const;
32 virtual unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
33 bool &fixed_point, bool is_root) = 0;
34};
35
36} // namespace duckdb
37