1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/optimizer/rule/distributivity.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/optimizer/rule.hpp" |
12 | #include "duckdb/parser/expression_map.hpp" |
13 | |
14 | namespace duckdb { |
15 | |
16 | // (X AND B) OR (X AND C) OR (X AND D) = X AND (B OR C OR D) |
17 | class DistributivityRule : public Rule { |
18 | public: |
19 | explicit DistributivityRule(ExpressionRewriter &rewriter); |
20 | |
21 | unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made, |
22 | bool is_root) override; |
23 | |
24 | private: |
25 | void AddExpressionSet(Expression &expr, expression_set_t &set); |
26 | unique_ptr<Expression> ExtractExpression(BoundConjunctionExpression &conj, idx_t idx, Expression &expr); |
27 | }; |
28 | |
29 | } // namespace duckdb |
30 |