1#pragma once
2
3#include "catch.hpp"
4#include "duckdb.hpp"
5#include "duckdb/optimizer/expression_rewriter.hpp"
6#include "duckdb/parser/parsed_expression.hpp"
7#include "duckdb/planner/expression.hpp"
8#include "duckdb/planner/planner.hpp"
9
10namespace duckdb {
11
12class ClientContext;
13
14class ExpressionHelper {
15public:
16 ExpressionHelper();
17
18 unique_ptr<Expression> ParseExpression(string expression);
19 unique_ptr<Expression> ApplyExpressionRule(unique_ptr<Expression> root);
20
21 unique_ptr<LogicalOperator> ParseLogicalTree(string query);
22
23 template <class T> void AddRule() {
24 rewriter.rules.push_back(make_unique<T>(rewriter));
25 }
26
27 bool VerifyRewrite(string input, string expected_output, bool silent = false);
28
29 string AddColumns(string columns);
30
31 DuckDB db;
32 Connection con;
33
34private:
35 ExpressionRewriter rewriter;
36
37 string from_clause;
38};
39
40} // namespace duckdb
41